jsxgraph 1.4.5 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/build/Readme.md +17 -0
  2. package/build/bin/jsxcompressor.js +1 -0
  3. package/build/bin/jsxgraphcore-min.js +7 -0
  4. package/build/bin/jsxgraphcore.js +83017 -0
  5. package/build/bin/jsxgraphcore.min.js +67 -0
  6. package/build/compressor.build.json +14 -0
  7. package/build/compressor.deps.js +8 -0
  8. package/build/core-amd.build.json +14 -0
  9. package/build/core-amd.deps.js +81 -0
  10. package/build/core.build.json +14 -0
  11. package/build/core.deps.js +102 -0
  12. package/build/plot.build.json +15 -0
  13. package/distrib/geogebra.min.js +1 -1
  14. package/distrib/geonext.min.js +1 -1
  15. package/distrib/index.d.ts +1 -0
  16. package/distrib/intergeo.min.js +1 -1
  17. package/distrib/jsxgraph.css +6 -0
  18. package/distrib/jsxgraphcore.js +3 -3
  19. package/distrib/jsxgraphsrc.js +3326 -1816
  20. package/distrib/sketch.min.js +1 -1
  21. package/package.json +1 -1
  22. package/src/3d/box3d.js +43 -38
  23. package/src/3d/curve3d.js +157 -53
  24. package/src/3d/element3d.js +84 -0
  25. package/src/3d/linspace3d.js +427 -146
  26. package/src/3d/point3d.js +352 -153
  27. package/src/3d/surface3d.js +140 -42
  28. package/src/3d/view3d.js +319 -164
  29. package/src/base/board.js +42 -26
  30. package/src/base/constants.js +8 -1
  31. package/src/base/curve.js +51 -9
  32. package/src/base/polygon.js +111 -69
  33. package/src/base/text.js +125 -51
  34. package/src/base/ticks.js +11 -2
  35. package/src/element/button.js +7 -3
  36. package/src/element/checkbox.js +8 -4
  37. package/src/element/composition.js +7 -1
  38. package/src/element/conic.js +2 -2
  39. package/src/element/input.js +9 -5
  40. package/src/jsxgraph.js +2 -0
  41. package/src/loadjsxgraph.js +13 -8
  42. package/src/math/clip.js +34 -134
  43. package/src/math/geometry.js +204 -3
  44. package/src/math/math.js +1 -2
  45. package/src/math/nlp.js +789 -730
  46. package/src/options.js +159 -8
  47. package/src/options3d.js +24 -7
  48. package/src/parser/jessiecode.js +8 -2
  49. package/src/renderer/abstract.js +26 -15
  50. package/src/renderer/canvas.js +2 -2
  51. package/src/renderer/svg.js +15 -2
  52. package/src/utils/env.js +29 -46
  53. package/src/utils/type.js +75 -2
  54. package/src/3d/threed.js +0 -38
package/src/base/text.js CHANGED
@@ -196,49 +196,63 @@ define([
196
196
  var updateText, resolvedText,
197
197
  ev_p = Type.evaluate(this.visProp.parse),
198
198
  ev_um = Type.evaluate(this.visProp.usemathjax),
199
- ev_uk = Type.evaluate(this.visProp.usekatex);
199
+ ev_uk = Type.evaluate(this.visProp.usekatex),
200
+ convertJessieCode = false;
200
201
 
201
202
  this.orgText = text;
203
+
202
204
  if (Type.isFunction(text)) {
203
- // <value> tags will not be evaluated.
205
+ // <value> tags will not be evaluated if text is provided by a function
204
206
  this.updateText = function () {
205
- resolvedText = text().toString();
207
+ resolvedText = text().toString(); // Evaluate function
206
208
  if (ev_p && !ev_um && !ev_uk) {
207
209
  this.plaintext = this.replaceSub(this.replaceSup(this.convertGeonextAndSketchometry2CSS(resolvedText)));
208
210
  } else {
209
211
  this.plaintext = resolvedText;
210
212
  }
211
213
  };
212
- } else if (Type.isString(text) && !ev_p) { // Do not parse
213
- this.updateText = function () {
214
- this.plaintext = text;
215
- };
216
- } else { // Parse
214
+
215
+ } else {
216
+
217
217
  if (Type.isNumber(text)) {
218
218
  this.content = Type.toFixed(text, Type.evaluate(this.visProp.digits));
219
- } else {
220
- if (Type.evaluate(this.visProp.useasciimathml)) {
221
- // Convert via ASCIIMathML
219
+ } else if (Type.isString(text) && ev_p) {
220
+
221
+ if (Type.evaluate(this.visProp.useasciimathml)) { // ASCIIMathML
222
222
  this.content = "'`" + text + "`'";
223
- } else if (ev_um || ev_uk) {
224
- if (ev_p) {
225
- this.content = this.generateTerm(text, true, true, true); // Replace value-tags
226
- this.content = this.content.replace(/\\/g, "\\\\");
227
- } else {
228
- this.content = "'" + text + "'";
229
- }
223
+
224
+ } else if (ev_um || ev_uk) { // MathJax or KaTeX
225
+ // Replace value-tags by functions
226
+ this.content = this.valueTagToJessieCode(text);
227
+ this.content = this.content.replace(/\\/g, "\\\\"); // Replace single backshlash by double
228
+
230
229
  } else {
230
+ // No TeX involved.
231
231
  // Converts GEONExT syntax into JavaScript string
232
232
  // Short math is allowed
233
+ // Replace value-tags by functions
233
234
  // Avoid geonext2JS calls
234
- this.content = this.generateTerm(text, true, true, false);
235
+ this.content = this.poorMansTeX(this.valueTagToJessieCode(text));
235
236
  }
237
+ convertJessieCode = true;
238
+ }
239
+
240
+ // Generate function which returns the text to be displayed
241
+ if (convertJessieCode) {
242
+
243
+ // Convert JessieCode to JS function
244
+ updateText = this.board.jc.snippet(this.content, true, '', false);
245
+
246
+ // Ticks have been esacped in valueTagToJessieCode
247
+ this.updateText = function () {
248
+ this.plaintext = this.unescapeTicks(updateText());
249
+ };
250
+ } else {
251
+ this.updateText = function () {
252
+ this.plaintext = text;
253
+ };
254
+
236
255
  }
237
- // Convert JessieCode to JS function
238
- updateText = this.board.jc.snippet(this.content, true, '', false);
239
- this.updateText = function () {
240
- this.plaintext = updateText();
241
- };
242
256
  }
243
257
  },
244
258
 
@@ -590,26 +604,24 @@ define([
590
604
  /**
591
605
  * Converts the GEONExT syntax of the <value> terms into JavaScript.
592
606
  * Also, all Objects whose name appears in the term are searched and
593
- * the text is added as child to these objects.
607
+ * the text is added as child to these objects.
594
608
  * This method is called if the attribute parse==true is set.
595
609
  *
596
610
  * @param{String} contentStr String to be parsed
597
611
  * @param{Boolean} [expand] Optional flag if shortened math syntax is allowed (e.g. 3x instead of 3*x).
598
612
  * @param{Boolean} [avoidGeonext2JS] Optional flag if geonext2JS should be called. For backwards compatibility
599
613
  * this has to be set explicitely to true.
600
- * @param{Boolean} [outputTeX] Optional flag which has to be true if the resulting term will be sent to MathJax or KaTeX.
614
+ * @param{Boolean} [outputTeX] Optional flag which has to be true if the resulting term will be sent to MathJax or KaTeX.
601
615
  * If true, "_" and "^" are NOT replaced by HTML tags sub and sup. Default: false, i.e. the replacement is done.
602
616
  * This flag allows the combination of &lt;value&gt; tag containing calculations with TeX output.
603
617
  *
604
618
  * @private
605
619
  * @see JXG.GeonextParser.geonext2JS
606
620
  */
607
- generateTerm: function (contentStr, expand, avoidGeonext2JS, outputTeX) {
621
+ generateTerm: function (contentStr, expand, avoidGeonext2JS) {
608
622
  var res, term, i, j,
609
623
  plaintext = '""';
610
624
 
611
- outputTeX = outputTeX || false;
612
-
613
625
  // Revert possible jc replacement
614
626
  contentStr = contentStr || '';
615
627
  contentStr = contentStr.replace(/\r/g, '');
@@ -617,16 +629,14 @@ define([
617
629
  contentStr = contentStr.replace(/"/g, '\'');
618
630
  contentStr = contentStr.replace(/'/g, "\\'");
619
631
 
620
- if (!outputTeX) {
621
- // Old GEONExT syntax, not (yet) supported as TeX output.
622
- // Otherwise, the else clause should be used.
623
- // That means, i.e. the <arc> tag and <sqrt> tag are not
624
- // converted into TeX syntax.
625
- contentStr = contentStr.replace(/&amp;arc;/g, '&ang;');
626
- contentStr = contentStr.replace(/<arc\s*\/>/g, '&ang;');
627
- contentStr = contentStr.replace(/&lt;arc\s*\/&gt;/g, '&ang;');
628
- contentStr = contentStr.replace(/&lt;sqrt\s*\/&gt;/g, '&radic;');
629
- }
632
+ // Old GEONExT syntax, not (yet) supported as TeX output.
633
+ // Otherwise, the else clause should be used.
634
+ // That means, i.e. the <arc> tag and <sqrt> tag are not
635
+ // converted into TeX syntax.
636
+ contentStr = contentStr.replace(/&amp;arc;/g, '&ang;');
637
+ contentStr = contentStr.replace(/<arc\s*\/>/g, '&ang;');
638
+ contentStr = contentStr.replace(/&lt;arc\s*\/&gt;/g, '&ang;');
639
+ contentStr = contentStr.replace(/&lt;sqrt\s*\/&gt;/g, '&radic;');
630
640
 
631
641
  contentStr = contentStr.replace(/&lt;value&gt;/g, '<value>');
632
642
  contentStr = contentStr.replace(/&lt;\/value&gt;/g, '</value>');
@@ -636,12 +646,9 @@ define([
636
646
  j = contentStr.indexOf('</value>');
637
647
  if (i >= 0) {
638
648
  while (i >= 0) {
639
- if (!outputTeX) {
640
- plaintext += ' + "' + this.replaceSub(this.replaceSup(contentStr.slice(0, i))) + '"';
641
- // plaintext += ' + "' + this.replaceSub(contentStr.slice(0, i)) + '"';
642
- } else {
643
- plaintext += ' + "' + contentStr.slice(0, i) + '"';
644
- }
649
+ plaintext += ' + "' + this.replaceSub(this.replaceSup(contentStr.slice(0, i))) + '"';
650
+ // plaintext += ' + "' + this.replaceSub(contentStr.slice(0, i)) + '"';
651
+
645
652
  term = contentStr.slice(i + 7, j);
646
653
  term = term.replace(/\s+/g, ''); // Remove all whitespace
647
654
  if (expand === true) {
@@ -674,12 +681,8 @@ define([
674
681
  }
675
682
  }
676
683
 
677
- if (!outputTeX) {
678
- plaintext += ' + "' + this.replaceSub(this.replaceSup(contentStr)) + '"';
679
- plaintext = this.convertGeonextAndSketchometry2CSS(plaintext);
680
- } else {
681
- plaintext += ' + "' + contentStr + '"';
682
- }
684
+ plaintext += ' + "' + this.replaceSub(this.replaceSup(contentStr)) + '"';
685
+ plaintext = this.convertGeonextAndSketchometry2CSS(plaintext);
683
686
 
684
687
  // This should replace e.g. &amp;pi; by &pi;
685
688
  plaintext = plaintext.replace(/&amp;/g, '&');
@@ -688,6 +691,77 @@ define([
688
691
  return plaintext;
689
692
  },
690
693
 
694
+ valueTagToJessieCode: function(contentStr) {
695
+ var res, term, i, j,
696
+ expandShortMath = true,
697
+ textComps = [],
698
+ tick = '"';
699
+
700
+ contentStr = contentStr || '';
701
+ contentStr = contentStr.replace(/\r/g, '');
702
+ contentStr = contentStr.replace(/\n/g, '');
703
+
704
+ contentStr = contentStr.replace(/&lt;value&gt;/g, '<value>');
705
+ contentStr = contentStr.replace(/&lt;\/value&gt;/g, '</value>');
706
+
707
+ // Convert content of value tag (GEONExT/JessieCode) syntax into JavaScript syntax
708
+ i = contentStr.indexOf('<value>');
709
+ j = contentStr.indexOf('</value>');
710
+ if (i >= 0) {
711
+ while (i >= 0) {
712
+ // Add string fragment before <value> tag
713
+ textComps.push(tick + this.escapeTicks(contentStr.slice(0, i)) + tick);
714
+
715
+ term = contentStr.slice(i + 7, j);
716
+ term = term.replace(/\s+/g, ''); // Remove all whitespace
717
+ if (expandShortMath === true) {
718
+ term = this.expandShortMath(term);
719
+ }
720
+ res = term;
721
+ res = res.replace(/\\"/g, "'").replace(/\\'/g, "'");
722
+
723
+ // Hack: apply rounding once only.
724
+ if (res.indexOf('toFixed') < 0) {
725
+ // Output of a value tag
726
+ // Run the JessieCode parser
727
+ if (Type.isNumber((Type.bind(this.board.jc.snippet(res, true, '', false), this))())) {
728
+ // Output is number
729
+ textComps.push('(' + res + ').toFixed(' + (Type.evaluate(this.visProp.digits)) + ')');
730
+ } else {
731
+ // Output is a string
732
+ textComps.push('(' + res + ')');
733
+ }
734
+ } else {
735
+ textComps.push('(' + res + ')');
736
+ }
737
+ contentStr = contentStr.slice(j + 8);
738
+ i = contentStr.indexOf('<value>');
739
+ j = contentStr.indexOf('</value>');
740
+ }
741
+ }
742
+ // Add trailing string fragment
743
+ textComps.push(tick + this.escapeTicks(contentStr) + tick);
744
+
745
+ return textComps.join(' + ').replace(/&amp;/g, '&');
746
+ },
747
+
748
+ poorMansTeX: function(s) {
749
+ s = s.replace(/<arc\s*\/*>/g, '&ang;')
750
+ .replace(/&lt;arc\s*\/*&gt;/g, '&ang;')
751
+ .replace(/<sqrt\s*\/*>/g, '&radic;')
752
+ .replace(/&lt;sqrt\s*\/*&gt;/g, '&radic;');
753
+
754
+ return this.convertGeonextAndSketchometry2CSS(this.replaceSub(this.replaceSup(s)));
755
+ },
756
+
757
+ escapeTicks: function(s) {
758
+ return s.replace(/"/g, '%22').replace(/'/g, '%27');
759
+ },
760
+
761
+ unescapeTicks: function(s) {
762
+ return s.replace(/%22/g, '"').replace(/%27/g, "'");
763
+ },
764
+
691
765
  /**
692
766
  * Converts the GEONExT tags <overline> and <arrow> to
693
767
  * HTML span tags with proper CSS formatting.
package/src/base/ticks.js CHANGED
@@ -659,6 +659,7 @@ define([
659
659
  } else if (!ev_it) {
660
660
  ticksDelta /= (ev_mt + 1);
661
661
  }
662
+ // Now, ticksdelta is the distance between two minor ticks
662
663
  this.ticksDelta = ticksDelta;
663
664
 
664
665
  if (ticksDelta < Mat.eps) {
@@ -754,6 +755,8 @@ define([
754
755
  */
755
756
  processTickPosition: function (coordsZero, tickPosition, ticksDelta, deltas) {
756
757
  var x, y, tickCoords, ti,
758
+ isLabelPosition,
759
+ ticksPerLabel = Type.evaluate(this.visProp.ticksperlabel),
757
760
  labelVal = null;
758
761
 
759
762
  // Calculates tick coordinates
@@ -776,13 +779,19 @@ define([
776
779
  // a multiple of the number of minorticks+1
777
780
  tickCoords.major = Math.round(tickPosition / ticksDelta) % (Type.evaluate(this.visProp.minorticks) + 1) === 0;
778
781
 
782
+ if (!ticksPerLabel) {
783
+ // In case of null, 0 or false, majorTicks are labelled
784
+ ticksPerLabel = Type.evaluate(this.visProp.minorticks) + 1;
785
+ }
786
+ isLabelPosition = Math.round(tickPosition / ticksDelta) % (ticksPerLabel) === 0;
787
+
779
788
  // Compute the start position and the end position of a tick.
780
789
  // If both positions are out of the canvas, ti is empty.
781
790
  ti = this.createTickPath(tickCoords, tickCoords.major);
782
791
  if (ti.length === 3) {
783
792
  this.ticks.push(ti);
784
- if (tickCoords.major && Type.evaluate(this.visProp.drawlabels)) {
785
- // major tick label
793
+ if (isLabelPosition && Type.evaluate(this.visProp.drawlabels)) {
794
+ // Create a label at this position
786
795
  this.labelsData.push(
787
796
  this.generateLabelData(
788
797
  this.generateLabelText(tickCoords, coordsZero, labelVal),
@@ -71,7 +71,7 @@ define([
71
71
  * @constructor
72
72
  * @type JXG.Text
73
73
  *
74
- * @param {number,function_number,function_String_function} x,y,label,handler Parent elements for button elements.
74
+ * @param {number,function_number,function_String,function_function} x,y,label,handler Parent elements for button elements.
75
75
  * <p>
76
76
  * x and y are the coordinates of the lower left corner of the text box.
77
77
  * The position of the text is fixed,
@@ -205,18 +205,22 @@ define([
205
205
  // "\nPossible parents are: [x, y, label, handler]");
206
206
  //}
207
207
 
208
+ // 1. Create empty button
208
209
  par = [parents[0], parents[1], '<button type="button" style="width:100%;"></button>'];
209
-
210
210
  t = board.create('text', par, attr);
211
211
  t.type = Type.OBJECT_TYPE_BUTTON;
212
212
 
213
213
  t.rendNodeButton = t.rendNode.childNodes[0];
214
214
  t.rendNodeButton.id = t.rendNode.id + '_button';
215
- t.rendNodeButton.innerHTML = parents[2];
215
+ // t.rendNodeButton.innerHTML = parents[2];
216
216
 
217
217
  t.rendNodeTag = t.rendNodeButton; // Needed for unified treatment in setAttribute
218
218
  t.rendNodeTag.disabled = !!attr.disabled;
219
219
 
220
+ // 2. Set parents[2] (string|function) as content of the button.
221
+ // abstract.js selects the correct DOM element for the update
222
+ t.setText(parents[2]);
223
+
220
224
  // This sets the font-size of the button text
221
225
  t.visPropOld.fontsize = "0px";
222
226
  board.renderer.updateTextStyle(t, false);
@@ -69,13 +69,13 @@ define([
69
69
  * @constructor
70
70
  * @type JXG.Text
71
71
  *
72
- * @param {number,function_number,function_String_String} x,y,label Parent elements for checkbox elements.
72
+ * @param {number,function_number,function_String,function} x,y,label Parent elements for checkbox elements.
73
73
  * <p>
74
74
  * x and y are the coordinates of the lower left corner of the text box.
75
75
  * The position of the text is fixed,
76
76
  * x and y are numbers. The position is variable if x or y are functions.
77
77
  * <p>
78
- * The label of the input element may be given as string.
78
+ * The label of the input element may be given as string or function.
79
79
  * <p>
80
80
  * The value of the checkbox can be controlled with the attribute <tt>checked</tt>
81
81
  * <p>The HTML node can be accessed with <tt>element.rendNodeCheckbox</tt>
@@ -184,7 +184,7 @@ define([
184
184
  '</span>'
185
185
  ];
186
186
 
187
- //t = JXG.createText(board, par, attr);
187
+ // 1. Create checkbox element with empty label
188
188
  t = board.create('text', par, attr);
189
189
  t.type = Type.OBJECT_TYPE_CHECKBOX;
190
190
 
@@ -194,11 +194,15 @@ define([
194
194
  t.rendNodeTag = t.rendNodeCheckbox; // Needed for unified treatment in setAttribute
195
195
  t.rendNodeTag.disabled = !!attr.disabled;
196
196
 
197
- t.rendNodeLabel.innerHTML = parents[2];
197
+ // t.rendNodeLabel.innerHTML = parents[2];
198
198
  t.rendNodeCheckbox.id = t.rendNode.id + '_checkbox';
199
199
  t.rendNodeLabel.id = t.rendNode.id + '_label';
200
200
  t.rendNodeLabel.setAttribute('for', t.rendNodeCheckbox.id);
201
201
 
202
+ // 2. Set parents[2] (string|function) as label of the checkbox element.
203
+ // abstract.js selects the correct DOM element for the update
204
+ t.setText(parents[2]);
205
+
202
206
  // This sets the font-size of the checkbox itself
203
207
  t.visPropOld.fontsize = "0px";
204
208
  board.renderer.updateTextStyle(t, false);
@@ -2065,17 +2065,21 @@ define([
2065
2065
  throw new Error("JSXGraph: Can't create reflected element with parent types '" +
2066
2066
  (typeof parents[0]) + "' and '" + (typeof parents[1]) + "'." + errStr);
2067
2067
  }
2068
-
2069
2068
  t = Transform.createTransform(board, [l], {type: 'reflect'});
2069
+
2070
2070
  if (Type.isPoint(org)) {
2071
2071
  r = Point.createPoint(board, [org, t], attr);
2072
+
2072
2073
  // Arcs and sectors are treated as curves
2073
2074
  } else if (org.elementClass === Const.OBJECT_CLASS_CURVE){
2074
2075
  r = Curve.createCurve(board, [org, t], attr);
2076
+
2075
2077
  } else if (org.elementClass === Const.OBJECT_CLASS_LINE){
2076
2078
  r = Line.createLine(board, [org, t], attr);
2079
+
2077
2080
  } else if (org.type === Const.OBJECT_TYPE_POLYGON){
2078
2081
  r = Polygon.createPolygon(board, [org, t], attr);
2082
+
2079
2083
  } else if (org.elementClass === Const.OBJECT_CLASS_CIRCLE) {
2080
2084
  if (attr.type.toLowerCase() === 'euclidean') {
2081
2085
  // Create a circle element from a circle and a Euclidean transformation
@@ -2087,10 +2091,12 @@ define([
2087
2091
  // Create a conic element from a circle and a projective transformation
2088
2092
  r = Circle.createCircle(board, [org, t], attr);
2089
2093
  }
2094
+
2090
2095
  } else {
2091
2096
  throw new Error("JSXGraph: Can't create reflected element with parent types '" +
2092
2097
  (typeof parents[0]) + "' and '" + (typeof parents[1]) + "'." + errStr);
2093
2098
  }
2099
+
2094
2100
  if (Type.exists(org._is_new)) {
2095
2101
  r.addChild(org);
2096
2102
  delete org._is_new;
@@ -736,7 +736,7 @@ define([
736
736
  *
737
737
  * @example
738
738
  * // Parameters: A, C, F, B/2, D/2, E/2
739
- * var conic = board.create('conic', [1, 2, -4, 0, 0, 0]s);
739
+ * var conic = board.create('conic', [1, 2, -4, 0, 0, 0]);
740
740
  *
741
741
  * </pre><div id="JXG8576a04a-52d8-4a7e-8d54-e32443910b97" class="jxgbox" style="width: 300px; height: 300px;"></div>
742
742
  * <script type="text/javascript">
@@ -744,7 +744,7 @@ define([
744
744
  * var board = JXG.JSXGraph.initBoard('JXG8576a04a-52d8-4a7e-8d54-e32443910b97',
745
745
  * {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
746
746
  * // Parameters: A, C, F, B/2, D/2, E/2
747
- * var conic = board.create('conic', [1, 2, -4, 0, 0, 0]s);
747
+ * var conic = board.create('conic', [1, 2, -4, 0, 0, 0]);
748
748
  * })();
749
749
  *
750
750
  * </script><pre>
@@ -71,14 +71,14 @@ define([
71
71
  * @constructor
72
72
  * @type JXG.Text
73
73
  *
74
- * @param {number,function_number,function_String_String} x,y,value,label Parent elements for input elements.
74
+ * @param {number,function_number,function_String_String,function} x,y,value,label Parent elements for input elements.
75
75
  * <p>
76
76
  * x and y are the coordinates of the lower left corner of the text box. The position of the text is fixed,
77
77
  * x and y are numbers. The position is variable if x or y are functions.
78
78
  * <p>
79
- * The default value of the input element may be given as string.
79
+ * The default value of the input element must be given as string.
80
80
  * <p>
81
- * The label of the input element may be given as string.
81
+ * The label of the input element may be given as string or function.
82
82
  *
83
83
  * @example
84
84
  * // Create an input element at position [1,4].
@@ -139,19 +139,23 @@ define([
139
139
  '</span>'
140
140
  ];
141
141
 
142
- //t = JXG.createText(board, par, attr);
142
+ // 1. Create input element with empty label
143
143
  t = board.create('text', par, attr);
144
144
  t.type = Type.OBJECT_TYPE_INPUT;
145
145
 
146
146
  t.rendNodeLabel = t.rendNode.childNodes[0].childNodes[0];
147
147
  t.rendNodeInput = t.rendNode.childNodes[0].childNodes[1];
148
- t.rendNodeLabel.innerHTML = parents[3];
148
+ // t.rendNodeLabel.innerHTML = parents[3];
149
149
  t.rendNodeInput.value = parents[2];
150
150
  t.rendNodeTag = t.rendNodeInput; // Needed for unified treatment in setAttribute
151
151
  t.rendNodeTag.disabled = !!attr.disabled;
152
152
  t.rendNodeLabel.id = t.rendNode.id + '_label';
153
153
  t.rendNodeInput.id = t.rendNode.id + '_input';
154
154
 
155
+ // 2. Set parents[3] (string|function) as label of the input element.
156
+ // abstract.js selects the correct DOM element for the update
157
+ t.setText(parents[3]);
158
+
155
159
  t._value = parents[2];
156
160
  t.update = function () {
157
161
  if (this.needsUpdate) {
package/src/jsxgraph.js CHANGED
@@ -302,6 +302,8 @@ define([
302
302
  * @param {Boolean|Object} [attributes.grid] If set to true, shows the grid. Can also be set to an object that is given to the grid as its attribute object.
303
303
  * @param {Boolean} [attributes.registerEvents=true] Register mouse / touch events.
304
304
  * @returns {JXG.Board} Reference to the created board.
305
+ *
306
+ * @see JXG.AbstractRenderer#drawZoomBar
305
307
  */
306
308
  initBoard: function (box, attributes) {
307
309
  var originX, originY, unitX, unitY,
@@ -171,13 +171,9 @@ var JXG = {},
171
171
  return {
172
172
  requirePath: window.location.href,
173
173
 
174
- setRequirePathToScriptFile: function (filename) {
174
+ getPathOfScriptFile: function (filename) {
175
175
  var scripts, reg, i, s, requirePath = '';
176
176
 
177
- if (requirePathLocation === filename) {
178
- return;
179
- }
180
-
181
177
  scripts = document.getElementsByTagName('script');
182
178
  reg = new RegExp(filename + '(\\?.*)?$');
183
179
 
@@ -185,11 +181,20 @@ var JXG = {},
185
181
  s = scripts[i];
186
182
  if (s.src && s.src.match(reg)) {
187
183
  requirePath = s.src.replace(reg, '');
188
- JXG.Load.requirePath = requirePath;
189
- requirePathLocation = filename;
190
184
  break;
191
185
  }
192
186
  }
187
+
188
+ return requirePath;
189
+ },
190
+
191
+ setRequirePathToScriptFile: function (filename) {
192
+ if (requirePathLocation === filename) {
193
+ return;
194
+ }
195
+
196
+ JXG.Load.requirePath = JXG.Load.getPathOfScriptFile(filename);
197
+ requirePathLocation = filename;
193
198
  },
194
199
 
195
200
  setRequirePathToHref: function () {
@@ -305,7 +310,7 @@ var JXG = {},
305
310
  ////////////////////////////////////////////////////////////////////////////////
306
311
 
307
312
  // Has to be a String for Makefile!
308
- JXG.Load.baseFiles = 'jxg,base/constants,utils/type,utils/xml,utils/env,utils/event,utils/expect,utils/color,math/probfuncs,math/math,math/ia,math/extrapolate,math/numerics,math/nlp,math/plot,math/metapost,math/statistics,math/symbolic,math/geometry,math/clip,math/poly,math/complex,renderer/abstract,renderer/no,reader/file,parser/geonext,base/board,options,jsxgraph,base/element,base/coordselement,base/coords,base/point,base/line,base/group,base/circle,element/conic,base/polygon,base/curve,element/arc,element/sector,base/composition,element/composition,base/text,base/image,element/slider,element/measure,base/chart,base/transformation,base/turtle,base/ticks,utils/zip,utils/base64,utils/uuid,utils/encoding,server/server,element/locus,parser/datasource,parser/ca,parser/jessiecode,utils/dump,renderer/svg,renderer/vml,renderer/canvas,renderer/no,element/comb,element/slopetriangle,math/qdt,element/checkbox,element/input,element/button,base/foreignobject,options3d,3d/threed,3d/view3d,3d/point3d,3d/curve3d,3d/surface3d,3d/linspace3d,3d/box3d';
313
+ JXG.Load.baseFiles = 'jxg,base/constants,utils/type,utils/xml,utils/env,utils/event,utils/expect,utils/color,math/probfuncs,math/math,math/ia,math/extrapolate,math/numerics,math/nlp,math/plot,math/metapost,math/statistics,math/symbolic,math/geometry,math/clip,math/poly,math/complex,renderer/abstract,renderer/no,reader/file,parser/geonext,base/board,options,jsxgraph,base/element,base/coordselement,base/coords,base/point,base/line,base/group,base/circle,element/conic,base/polygon,base/curve,element/arc,element/sector,base/composition,element/composition,base/text,base/image,element/slider,element/measure,base/chart,base/transformation,base/turtle,base/ticks,utils/zip,utils/base64,utils/uuid,utils/encoding,server/server,element/locus,parser/datasource,parser/ca,parser/jessiecode,utils/dump,renderer/svg,renderer/vml,renderer/canvas,renderer/no,element/comb,element/slopetriangle,math/qdt,element/checkbox,element/input,element/button,base/foreignobject,options3d,3d/view3d,3d/element3d,3d/point3d,3d/curve3d,3d/surface3d,3d/linspace3d,3d/box3d';
309
314
  JXG.Load.setRequirePathToScriptFile('loadjsxgraph.js');
310
315
  JXG.Load.JSfiles(JXG.Load.baseFiles.split(','), preventCachingFiles);
311
316
  JXG.Load.baseFiles = null;