jsxgraph 1.4.1 → 1.4.4

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.
@@ -0,0 +1,265 @@
1
+ /*global JXG:true, define: true*/
2
+
3
+ define([
4
+ 'jxg', 'options'
5
+ ], function (JXG, Options) {
6
+
7
+ "use strict";
8
+
9
+ JXG.extend(Options, {
10
+
11
+ infobox: {
12
+ strokeColor: 'black'
13
+ },
14
+
15
+ axes3d: {
16
+ /**#@+
17
+ * @visprop
18
+ */
19
+
20
+ /**
21
+ * Position of the main axes in a View3D element. Possible values are
22
+ * 'center' and 'border'.
23
+ *
24
+ * @type String
25
+ * @name View3D#axesPosition
26
+ * @default 'center'
27
+ */
28
+ axesPosition: 'center', // Possible values: 'center', otherwise: border
29
+
30
+ // Main axes
31
+
32
+ /**
33
+ * Attributes of the 3D x-axis.
34
+ *
35
+ * @type Line3D
36
+ * @name View3D#xAxis
37
+ */
38
+ xAxis: { visible: true, point2: {name: 'x'}},
39
+
40
+ /**
41
+ * Attributes of the 3D y-axis.
42
+ *
43
+ * @type Line3D
44
+ * @name View3D#yAxis
45
+ */
46
+ yAxis: { visible: true, point2: {name: 'y'}},
47
+
48
+ /**
49
+ * Attributes of the 3D z-axis.
50
+ *
51
+ * @type Line3D
52
+ * @name View3D#zAxis
53
+ */
54
+ zAxis: { visible: true, point2: {name: 'z'}},
55
+
56
+ // Planes
57
+ /**
58
+ * Attributes of the 3D plane orthogonal to the x-axis at the "rear" of the cube.
59
+ * @type Plane3D
60
+ * @name View3D#xPlaneRear
61
+ */
62
+ xPlaneRear: { visible: true, layer: 0, mesh3d: { layer: 1 } },
63
+ /**
64
+ * Attributes of the 3D plane orthogonal to the y-axis at the "rear" of the cube.
65
+ * @type Plane3D
66
+ * @name View3D#yPlaneRear
67
+ */
68
+ yPlaneRear: { visible: true, layer: 0, mesh3d: { layer: 1 } },
69
+ /**
70
+ * Attributes of the 3D plane orthogonal to the z-axis at the "rear" of the cube.
71
+ * @type Plane3D
72
+ * @name View3D#zPlaneRear
73
+ */
74
+ zPlaneRear: { visible: true, layer: 0, mesh3d: { layer: 1 } },
75
+
76
+ /**
77
+ * Attributes of the 3D plane orthogonal to the x-axis at the "front" of the cube.
78
+ * @type Plane3D
79
+ * @name View3D#xPlaneFront
80
+ */
81
+ xPlaneFront: { visible: false, layer: 0, mesh3d: { layer: 1 } },
82
+ /**
83
+ * Attributes of the 3D plane orthogonal to the y-axis at the "front" of the cube.
84
+ * @type Plane3D
85
+ * @name View3D#yPlaneFront
86
+ */
87
+ yPlaneFront: { visible: false, layer: 0, mesh3d: { layer: 1 } },
88
+ /**
89
+ * Attributes of the 3D plane orthogonal to the z-axis at the "front" of the cube.
90
+ * @type Plane3D
91
+ * @name View3D#zPlaneFront
92
+ */
93
+ zPlaneFront: { visible: false, layer: 0, mesh3d: { layer: 1 } },
94
+
95
+ // Axes on the planes
96
+ /**
97
+ * Attributes of the 3D y-axis on the 3D plane orthogonal to the x-axis at the "rear" of the cube.
98
+ * @type Plane3D
99
+ * @name View3D#xPlaneRearYAxis
100
+ */
101
+ xPlaneRearYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
102
+ /**
103
+ * Attributes of the 3D z-axis on the 3D plane orthogonal to the x-axis at the "rear" of the cube.
104
+ * @type Plane3D
105
+ * @name View3D#xPlaneRearZAxis
106
+ */
107
+ xPlaneRearZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
108
+ /**
109
+ * Attributes of the 3D y-axis on the 3D plane orthogonal to the x-axis at the "front" of the cube.
110
+ * @type Plane3D
111
+ * @name View3D#xPlaneFrontYAxis
112
+ */
113
+ xPlaneFrontYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
114
+ /**
115
+ * Attributes of the 3D z-axis on the 3D plane orthogonal to the x-axis at the "front" of the cube.
116
+ * @type Plane3D
117
+ * @name View3D#xPlaneFrontZAxis
118
+ */
119
+ xPlaneFrontZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
120
+
121
+ /**
122
+ * Attributes of the 3D x-axis on the 3D plane orthogonal to the y-axis at the "rear" of the cube.
123
+ * @type Plane3D
124
+ * @name View3D#yPlaneRearXAxis
125
+ */
126
+ yPlaneRearXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
127
+ /**
128
+ * Attributes of the 3D z-axis on the 3D plane orthogonal to the y-axis at the "rear" of the cube.
129
+ * @type Plane3D
130
+ * @name View3D#yPlaneRearZAxis
131
+ */
132
+ yPlaneRearZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
133
+ /**
134
+ * Attributes of the 3D x-axis on the 3D plane orthogonal to the y-axis at the "front" of the cube.
135
+ * @type Plane3D
136
+ * @name View3D#yPlaneFrontXAxis
137
+ */
138
+ yPlaneFrontXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
139
+ /**
140
+ * Attributes of the 3D z-axis on the 3D plane orthogonal to the y-axis at the "front" of the cube.
141
+ * @type Plane3D
142
+ * @name View3D#yPlaneFrontZAxis
143
+ */
144
+ yPlaneFrontZAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
145
+
146
+ /**
147
+ * Attributes of the 3D x-axis on the 3D plane orthogonal to the z-axis at the "rear" of the cube.
148
+ * @type Plane3D
149
+ * @name View3D#zPlaneRearXAxis
150
+ */
151
+ zPlaneRearXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
152
+ /**
153
+ * Attributes of the 3D y-axis on the 3D plane orthogonal to the z-axis at the "rear" of the cube.
154
+ * @type Plane3D
155
+ * @name View3D#zPlaneRearYAxis
156
+ */
157
+ zPlaneRearYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
158
+ /**
159
+ * Attributes of the 3D x-axis on the 3D plane orthogonal to the z-axis at the "front" of the cube.
160
+ * @type Plane3D
161
+ * @name View3D#zPlaneFrontXAxis
162
+ */
163
+ zPlaneFrontXAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1},
164
+ /**
165
+ * Attributes of the 3D y-axis on the 3D plane orthogonal to the z-axis at the "front" of the cube.
166
+ * @type Plane3D
167
+ * @name View3D#zPlaneFrontYAxis
168
+ */
169
+ zPlaneFrontYAxis: {visible: 'inherit', strokeColor: '#888888', strokeWidth: 1}
170
+
171
+ /**#@-*/
172
+ },
173
+
174
+ axis3d: {
175
+ highlight: false,
176
+ strokecolor: 'black',
177
+ strokeWidth: 1,
178
+ tabindex: null,
179
+
180
+ point1: { visible: false, name: '' },
181
+ point2: { visible: false, name: '', label: { visible: true } }
182
+ },
183
+
184
+ mesh3d: {
185
+ strokeWidth: 1,
186
+ strokeColor: '#9a9a9a',
187
+ strokeOpacity: 0.6,
188
+ highlight: false,
189
+ fillColor: '#9a9a9a',
190
+ fillOpacity: 0.1,
191
+ tabindex: null,
192
+
193
+ visible: 'inherit'
194
+ },
195
+
196
+ line3d: {
197
+ strokeWidth: 1,
198
+ strokeColor: 'black',
199
+ fixed: true,
200
+ tabindex: null,
201
+
202
+ gradient: 'linear',
203
+ gradientSecondColor: '#ffffff',
204
+
205
+ point1: {visible: false, name: ''},
206
+ point2: {visible: false, name: ''}
207
+ },
208
+
209
+ plane3d: {
210
+ strokeWidth: 0,
211
+ strokeColor: 'black',
212
+ strokeOpacity: 1,
213
+ highlight: false,
214
+ tabindex: null,
215
+
216
+ gradient: 'linear',
217
+ gradientSecondColor: '#ffffff',
218
+ gradientAngle: Math.PI,
219
+ fillColor: '#a7a7a7',
220
+ fillOpacity: 0.6
221
+ },
222
+
223
+ point3d: {
224
+ strokeWidth: 0,
225
+ gradient: 'radial',
226
+ gradientSecondColor: '#555555',
227
+ fillColor: 'yellow',
228
+ highlightStrokeColor: '#555555'
229
+ },
230
+
231
+ surface3d: {
232
+ /**#@+
233
+ * @visprop
234
+ */
235
+
236
+ highlight: false,
237
+ tabindex: -1,
238
+ strokeWidth: 1,
239
+
240
+ /**
241
+ * Number of intervals the mesh is divided into in direction of parameter u.
242
+ * @type Number
243
+ * @name Surface3D#stepsU
244
+ */
245
+ stepsU: 30,
246
+
247
+ /**
248
+ * Number of intervals the mesh is divided into in direction of parameter v.
249
+ * @type Number
250
+ * @name Surface3D#stepsV
251
+ */
252
+ stepsV: 30
253
+
254
+ /**#@-*/
255
+ },
256
+
257
+ view3d: {
258
+ needsRegularUpdate: true
259
+ }
260
+
261
+ });
262
+
263
+ return JXG.Options;
264
+ });
265
+
@@ -172,6 +172,12 @@ define([
172
172
  */
173
173
  this.builtIn = this.defineBuiltIn();
174
174
 
175
+ /**
176
+ * List of all possible operands in JessieCode (except of JSXGraph objects).
177
+ * @type Object
178
+ */
179
+ this.operands = this.getPossibleOperands();
180
+
175
181
  /**
176
182
  * The board which currently is used to create and look up elements.
177
183
  * @type JXG.Board
@@ -2464,6 +2470,103 @@ define([
2464
2470
  return builtIn;
2465
2471
  },
2466
2472
 
2473
+ /**
2474
+ * Returns information about the possible functions and constants.
2475
+ * @returns {Object}
2476
+ */
2477
+ getPossibleOperands: function () {
2478
+ var FORBIDDEN = ['E'],
2479
+ jessiecode = this.defineBuiltIn(),
2480
+ math = Math,
2481
+ jc, ma, merge,
2482
+ i, j, p, len, e,
2483
+ funcs, funcsJC, consts, operands,
2484
+ sort, pack;
2485
+
2486
+ sort = function (a, b) {
2487
+ return a.toLowerCase().localeCompare(b.toLowerCase());
2488
+ };
2489
+
2490
+ pack = function (name, origin) {
2491
+ var that = null;
2492
+
2493
+ if (origin === 'jc') that = jessiecode[name];
2494
+ else if (origin === 'Math') that = math[name];
2495
+ else return;
2496
+
2497
+ if (FORBIDDEN.includes(name)) {
2498
+ return;
2499
+ } else if (JXG.isFunction(that)) {
2500
+ return {
2501
+ name: name,
2502
+ type: 'function',
2503
+ numParams: that.length,
2504
+ origin: origin,
2505
+ };
2506
+ } else if (JXG.isNumber(that)) {
2507
+ return {
2508
+ name: name,
2509
+ type: 'constant',
2510
+ value: that,
2511
+ origin: origin,
2512
+ };
2513
+ } else if (that !== undefined) {
2514
+ console.error('undefined type', that);
2515
+ }
2516
+ };
2517
+
2518
+ jc = Object.getOwnPropertyNames(jessiecode).sort(sort);
2519
+ ma = Object.getOwnPropertyNames(math).sort(sort);
2520
+ merge = [];
2521
+ i = 0;
2522
+ j = 0;
2523
+
2524
+ while (i < jc.length || j < ma.length) {
2525
+ if (jc[i] === ma[j]) {
2526
+ p = pack(ma[j], 'Math');
2527
+ if (JXG.exists(p)) merge.push(p);
2528
+ i++;
2529
+ j++;
2530
+ } else if (!JXG.exists(ma[j]) || jc[i].toLowerCase().localeCompare(ma[j].toLowerCase()) < 0) {
2531
+ p = pack(jc[i], 'jc');
2532
+ if (JXG.exists(p)) merge.push(p);
2533
+ i++;
2534
+ } else {
2535
+ p = pack(ma[j], 'Math');
2536
+ if (JXG.exists(p)) merge.push(p);
2537
+ j++;
2538
+ }
2539
+ }
2540
+
2541
+ funcs = [];
2542
+ funcsJC = [];
2543
+ consts = [];
2544
+ operands = {};
2545
+ len = merge.length;
2546
+ for (i = 0; i < len; i++) {
2547
+ e = merge[i];
2548
+ switch (e.type) {
2549
+ case 'function':
2550
+ funcs.push(e.name);
2551
+ if (e.origin === 'jc')
2552
+ funcsJC.push(e.name);
2553
+ break;
2554
+ case 'constant':
2555
+ consts.push(e.name);
2556
+ break;
2557
+ }
2558
+ operands[e.name] = e;
2559
+ }
2560
+
2561
+ return {
2562
+ all: operands,
2563
+ list: merge,
2564
+ functions: funcs,
2565
+ functions_jessiecode: funcsJC,
2566
+ constants: consts,
2567
+ };
2568
+ },
2569
+
2467
2570
  /**
2468
2571
  * Output a debugging message. Uses debug console, if available. Otherwise an HTML element with the
2469
2572
  * id "debug" and an innerHTML property is used.
@@ -886,7 +886,7 @@ Copyright 2008-2022
886
886
  str1[i] = pn(step.args.p1[i]);
887
887
  }
888
888
 
889
- set_str = 'point(' + str1.join(', ') + ') <<id: \'' + pid1 + '\', name: \'\', visible: false, ';
889
+ set_str = 'point(' + str1.join(', ') + ') <<id: \'' + pid1 + '\', name: \'\', visible: false, isinfinit: true, ';
890
890
  set_str += 'snaptogrid: false, snaptopoints: false, priv: true>>; ';
891
891
  reset_str = 'remove(' + pid1 + '); ';
892
892
  } else {
@@ -901,7 +901,7 @@ Copyright 2008-2022
901
901
  str1[i] = pn(step.args.p2[i]);
902
902
  }
903
903
 
904
- set_str += 'point(' + str1.join(', ') + ') <<id: \'' + pid2 + '\', name: \'\', visible: false, ';
904
+ set_str += 'point(' + str1.join(', ') + ') <<id: \'' + pid2 + '\', name: \'\', visible: false, isinfinit: true, ';
905
905
  set_str += 'snaptogrid: false, snaptopoints: false, priv: true>>; ';
906
906
  reset_str = 'remove(' + pid2 + '); ' + reset_str;
907
907
  } else {
@@ -1376,10 +1376,10 @@ Copyright 2008-2022
1376
1376
 
1377
1377
  set_str = assign + step.args.plot_type + '(' + step.args.func;
1378
1378
 
1379
- if (isNaN(step.args.a) || step.args.a === null || step.args.a === undefined)
1380
- step.args.a = '-infinity';
1381
- if (isNaN(step.args.b) || step.args.b === null || step.args.b === undefined)
1382
- step.args.b = 'infinity';
1379
+ if (isNaN(step.args.a) || step.args.a === null || step.args.a === undefined|| step.args.a ==='-infinity')
1380
+ step.args.a = '';
1381
+ if (isNaN(step.args.b) || step.args.b === null || step.args.b === undefined|| step.args.b ==='infinity')
1382
+ step.args.b = '';
1383
1383
 
1384
1384
  if (step.args.a != step.args.b)
1385
1385
  set_str += ', ' + step.args.a + ', ' + step.args.b;
@@ -1584,8 +1584,11 @@ define([
1584
1584
 
1585
1585
  setTabindex: function(element) {
1586
1586
  var val;
1587
- if (Type.exists(element.rendNode)) {
1587
+ if (element.board.attr.keyboard.enabled && Type.exists(element.rendNode)) {
1588
1588
  val = Type.evaluate(element.visProp.tabindex);
1589
+ if (!element.visPropCalc.visible || Type.evaluate(element.visProp.fixed)) {
1590
+ val = null;
1591
+ }
1589
1592
  if (val !== element.visPropOld.tabindex) {
1590
1593
  element.rendNode.setAttribute('tabindex', val);
1591
1594
  element.visPropOld.tabindex = val;
@@ -1694,10 +1694,11 @@ define([
1694
1694
  * setTimeout(function() { console.log('done'); }, 400);
1695
1695
  */
1696
1696
  dumpToCanvas: function (canvasId, w, h, ignoreTexts) {
1697
- var svg, tmpImg, cv, ctx;
1697
+ var svg, tmpImg, cv, ctx,
1698
+ doc = this.container.ownerDocument;
1698
1699
 
1699
1700
  // Prepare the canvas element
1700
- cv = document.getElementById(canvasId);
1701
+ cv = doc.getElementById(canvasId);
1701
1702
 
1702
1703
  // Clear the canvas
1703
1704
  /* eslint-disable no-self-assign */
@@ -1833,7 +1834,8 @@ define([
1833
1834
  } else {
1834
1835
  // Debug: use canvas element 'jxgbox_canvas' from jsxdev/dump.html
1835
1836
  id = 'jxgbox_canvas';
1836
- canvas = document.getElementById(id);
1837
+ // canvas = document.getElementById(id);
1838
+ canvas = doc.getElementById(id);
1837
1839
  }
1838
1840
 
1839
1841
  if (newImg) {
@@ -1853,7 +1855,8 @@ define([
1853
1855
  }
1854
1856
 
1855
1857
  // Hide navigation bar in board
1856
- zbar = document.getElementById(this.container.id + '_navigationbar');
1858
+ // zbar = document.getElementById(this.container.id + '_navigationbar');
1859
+ zbar = doc.getElementById(this.container.id + '_navigationbar');
1857
1860
  if (Type.exists(zbar)) {
1858
1861
  zbarDisplay = zbar.style.display;
1859
1862
  zbar.style.display = 'none';
@@ -988,8 +988,7 @@ define(['jxg', 'utils/type', 'math/math'],
988
988
  green: '#009E73', // bluishgreen
989
989
  purple: '#CC79A7', // reddishpurple
990
990
  white: '#ffffff'
991
- },
992
-
991
+ }
993
992
  });
994
993
 
995
994
  /**
package/src/utils/type.js CHANGED
@@ -977,7 +977,7 @@ define([
977
977
  }
978
978
 
979
979
  // options from attributes
980
- o = attributes;
980
+ o = (typeof attributes === 'object') ? attributes : {};
981
981
  isAvail = true;
982
982
  for (i = 3; i < len; i++) {
983
983
  if (this.exists(o[arguments[i]])) {
@@ -1283,7 +1283,7 @@ define([
1283
1283
  return html_sanitize(str, function () { return undefined; }, function (id) { return id; });
1284
1284
  }
1285
1285
 
1286
- if (str) {
1286
+ if (str && typeof str === 'string') {
1287
1287
  str = str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
1288
1288
  }
1289
1289