Skip to content

Commit 95dc853

Browse files
committed
un-attach funcs aren't used outside plotly_util as private funcs
1 parent 8b602e4 commit 95dc853

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

shelly/plotlyjs/static/plotlyjs/src/plotly_util.js

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

33
// ---external global dependencies
4-
/* global d3:false, MathJax:false
5-
Promise:false */
4+
/* global d3:false, MathJax:false, Promise:false */
65

76
var util = module.exports = {},
87
Plotly = require('./plotly');
@@ -139,15 +138,13 @@ util.jsHook = function(_el){
139138
// text converter
140139
/////////////////////////////
141140

142-
util.getSize = function(_selection, _dimension){
141+
function getSize(_selection, _dimension){
143142
return _selection.node().getBoundingClientRect()[_dimension];
144-
};
145-
146-
143+
}
147144

148145
util.convertToTspans = function(_context, _callback){
149146
var str = _context.text();
150-
var converted = Plotly.util.convertToSvg(str);
147+
var converted = convertToSVG(str);
151148
var that = _context;
152149
// Until we get tex integrated more fully (so it can be used along with non-tex)
153150
// allow some elements to prohibit it by attaching 'data-notex' to the original
@@ -193,7 +190,8 @@ util.convertToTspans = function(_context, _callback){
193190
((td && td._promises)||[]).push(new Promise(function(resolve) {
194191
that.style({visibility: 'hidden'});
195192
var config = {fontSize: parseInt(that.style('font-size'), 10)};
196-
Plotly.util.texToSVG(tex[2], config, function(_svgEl, _glyphDefs, _svgBBox){
193+
194+
texToSVG(tex[2], config, function(_svgEl, _glyphDefs, _svgBBox) {
197195
parent.selectAll('svg.' + svgClass).remove();
198196
parent.selectAll('g.' + svgClass + '-group').remove();
199197

@@ -225,13 +223,13 @@ util.convertToTspans = function(_context, _callback){
225223
var fill = that.style('fill') || 'black';
226224
newSvg.select('g').attr({fill: fill, stroke: fill});
227225

228-
var newSvgW = Plotly.util.getSize(newSvg, 'width'),
229-
newSvgH = Plotly.util.getSize(newSvg, 'height'),
226+
var newSvgW = getSize(newSvg, 'width'),
227+
newSvgH = getSize(newSvg, 'height'),
230228
newX = +that.attr('x') - newSvgW *
231229
{start:0, middle:0.5, end:1}[that.attr('text-anchor') || 'start'],
232230
// font baseline is about 1/4 fontSize below centerline
233231
textHeight = parseInt(that.style('font-size'), 10) ||
234-
Plotly.util.getSize(that, 'height'),
232+
getSize(that, 'height'),
235233
dy = -textHeight/4;
236234

237235
if(svgClass[0] === 'y'){
@@ -270,7 +268,7 @@ function cleanEscapesForTex(s) {
270268
.replace(/(>|>|>)/g, '\\gt ');
271269
}
272270

273-
util.texToSVG = function(_texString, _config, _callback){
271+
function texToSVG(_texString, _config, _callback){
274272
var randomID = 'math-output-' + Plotly.Lib.randstr([],64);
275273
var tmpDiv = d3.select('body').append('div')
276274
.attr({id: randomID})
@@ -292,7 +290,7 @@ util.texToSVG = function(_texString, _config, _callback){
292290

293291
tmpDiv.remove();
294292
});
295-
};
293+
}
296294

297295
var TAG_STYLES = {
298296
// would like to use baseline-shift but FF doesn't support it yet
@@ -316,7 +314,7 @@ util.plainText = function(_str){
316314
return (_str||'').replace(STRIP_TAGS, ' ');
317315
};
318316

319-
util.convertToSvg = function(_str){
317+
function convertToSVG(_str){
320318
var htmlEntitiesDecoded = Plotly.util.html_entity_decode(_str);
321319
var result = htmlEntitiesDecoded
322320
.split(/(<[^<>]*>)/).map(function(d){
@@ -410,10 +408,9 @@ util.convertToSvg = function(_str){
410408
}
411409

412410
return result.join('');
413-
};
414-
411+
}
415412

416-
util.alignHTMLWith = function (_base, container, options){
413+
function alignHTMLWith(_base, container, options){
417414
var alignH = options.horizontalAlign,
418415
alignV = options.verticalAlign || 'top',
419416
bRect = _base.node().getBoundingClientRect(),
@@ -447,7 +444,7 @@ util.alignHTMLWith = function (_base, container, options){
447444
});
448445
return this;
449446
};
450-
};
447+
}
451448

452449
// Editable title
453450
/////////////////////////////
@@ -504,7 +501,7 @@ util.makeEditable = function(context, _delegate, options){
504501
})
505502
.attr({contenteditable: true})
506503
.text(options.text || that.attr('data-unformatted'))
507-
.call(util.alignHTMLWith(that, container, options))
504+
.call(alignHTMLWith(that, container, options))
508505
.on('blur', function(){
509506
that.text(this.textContent)
510507
.style({opacity: 1});
@@ -538,7 +535,7 @@ util.makeEditable = function(context, _delegate, options){
538535
}
539536
else{
540537
dispatch.input.call(that, this.textContent);
541-
d3.select(this).call(util.alignHTMLWith(that, container, options));
538+
d3.select(this).call(alignHTMLWith(that, container, options));
542539
}
543540
})
544541
.on('keydown', function(){

0 commit comments

Comments
 (0)