jsxgraph 1.3.1 → 1.4.2
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.
- package/README.md +2 -2
- package/distrib/README.md +2 -2
- package/distrib/geogebra.min.js +3 -3
- package/distrib/geonext.min.js +3 -3
- package/distrib/index.d.ts +4964 -4627
- package/distrib/intergeo.min.js +3 -3
- package/distrib/jsxgraph.css +10 -15
- package/distrib/jsxgraphcore.js +9 -25
- package/distrib/jsxgraphsrc.js +28437 -25331
- package/distrib/sketch.min.js +3 -3
- package/package.json +11 -22
- package/src/base/board.js +555 -427
- package/src/base/chart.js +1 -1
- package/src/base/circle.js +23 -1
- package/src/base/composition.js +1 -1
- package/src/base/constants.js +33 -11
- package/src/base/coords.js +4 -4
- package/src/base/coordselement.js +47 -20
- package/src/base/curve.js +308 -117
- package/src/base/element.js +80 -51
- package/src/base/foreignobject.js +463 -0
- package/src/base/group.js +2 -2
- package/src/base/image.js +12 -15
- package/src/base/line.js +1 -1
- package/src/base/point.js +20 -41
- package/src/base/polygon.js +75 -18
- package/src/base/text.js +116 -63
- package/src/base/ticks.js +35 -12
- package/src/base/transformation.js +1 -1
- package/src/base/turtle.js +1 -1
- package/src/element/arc.js +1 -1
- package/src/element/button.js +29 -2
- package/src/element/checkbox.js +31 -1
- package/src/element/comb.js +5 -2
- package/src/element/composition.js +27 -6
- package/src/element/conic.js +46 -5
- package/src/element/input.js +32 -1
- package/src/element/locus.js +2 -2
- package/src/element/measure.js +9 -4
- package/src/element/sector.js +46 -12
- package/src/element/slider.js +17 -12
- package/src/element/slopetriangle.js +1 -1
- package/src/jsxgraph.js +28 -9
- package/src/jxg.js +4 -3
- package/src/loadjsxgraph.js +3 -2
- package/src/math/bst.js +1 -1
- package/src/math/clip.js +550 -345
- package/src/math/complex.js +1 -1
- package/src/math/extrapolate.js +1 -1
- package/src/math/geometry.js +109 -128
- package/src/math/ia.js +290 -21
- package/src/math/math.js +30 -1
- package/src/math/metapost.js +1 -1
- package/src/math/nlp.js +25 -5
- package/src/math/numerics.js +183 -4
- package/src/math/plot.js +4 -4
- package/src/math/poly.js +1 -1
- package/src/math/probfuncs.js +2 -1
- package/src/math/qdt.js +68 -62
- package/src/math/statistics.js +58 -7
- package/src/math/symbolic.js +1 -1
- package/src/options.js +393 -115
- package/src/parser/ca.js +1297 -1291
- package/src/parser/datasource.js +1 -1
- package/src/parser/geonext.js +6 -6
- package/src/parser/jessiecode.js +378 -79
- package/src/parser/jessiescript.js +1 -1
- package/src/reader/cinderella.js +1 -1
- package/src/reader/file.js +1 -1
- package/src/reader/geogebra.js +1 -1
- package/src/reader/geonext.js +1 -1
- package/src/reader/graph.js +1 -1
- package/src/reader/intergeo.js +1 -1
- package/src/reader/sketch.js +25 -17
- package/src/renderer/abstract.js +25 -7
- package/src/renderer/canvas.js +20 -15
- package/src/renderer/no.js +11 -4
- package/src/renderer/svg.js +68 -49
- package/src/renderer/vml.js +36 -32
- package/src/server/server.js +1 -1
- package/src/utils/base64.js +2 -2
- package/src/utils/color.js +147 -3
- package/src/utils/dump.js +20 -14
- package/src/utils/env.js +26 -62
- package/src/utils/event.js +1 -1
- package/src/utils/expect.js +1 -1
- package/src/utils/type.js +30 -19
- package/src/utils/xml.js +1 -1
- package/src/utils/zip.js +1 -1
- package/CHANGELOG.md +0 -1305
package/src/utils/color.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
* Stoyan Stefanov <sstoo@gmail.com> (see http://www.phpied.com/rgb-color-parser-in-javascript/)
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
|
-
define(['jxg', 'utils/type', 'math/math'],
|
|
48
|
+
define(['jxg', 'utils/type', 'math/math'],
|
|
49
|
+
function (JXG, Type, Mat) {
|
|
49
50
|
|
|
50
51
|
"use strict";
|
|
51
52
|
|
|
@@ -198,9 +199,10 @@ define(['jxg', 'utils/type', 'math/math'], function (JXG, Type, Mat) {
|
|
|
198
199
|
yellow: 'ffff00',
|
|
199
200
|
yellowgreen: '9acd32'
|
|
200
201
|
},
|
|
202
|
+
|
|
201
203
|
// array of color definition objects
|
|
202
204
|
colorDefs = [{
|
|
203
|
-
re: /^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([\d
|
|
205
|
+
re: /^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([\d.]{1,3})\s*\)\s*$/,
|
|
204
206
|
example: ['rgba(123, 234, 45, 0.5)', 'rgba(255,234,245,1.0)'],
|
|
205
207
|
process: function (bits) {
|
|
206
208
|
return [
|
|
@@ -872,5 +874,147 @@ define(['jxg', 'utils/type', 'math/math'], function (JXG, Type, Mat) {
|
|
|
872
874
|
return lightColor;
|
|
873
875
|
};
|
|
874
876
|
|
|
877
|
+
/**
|
|
878
|
+
* Use the color scheme of JSXGraph up to version 1.3.2.
|
|
879
|
+
* This method has to be called before JXG.JSXGraph.initBoard();
|
|
880
|
+
*
|
|
881
|
+
* @see JXG.palette
|
|
882
|
+
* @see JXG.paletteWong
|
|
883
|
+
*
|
|
884
|
+
* @example
|
|
885
|
+
*
|
|
886
|
+
* JXG.setClassicColors();
|
|
887
|
+
* var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5, 5, 5,-5]});
|
|
888
|
+
*
|
|
889
|
+
*/
|
|
890
|
+
JXG.setClassicColors = function() {
|
|
891
|
+
JXG.Options.elements.strokeColor = 'blue';
|
|
892
|
+
JXG.Options.elements.fillColor = 'red';
|
|
893
|
+
JXG.Options.hatch.strokeColor = 'blue';
|
|
894
|
+
JXG.Options.angle.fillColor = '#ff7f00';
|
|
895
|
+
JXG.Options.angle.highlightFillColor = '#ff7f00';
|
|
896
|
+
JXG.Options.angle.strokeColor = '#ff7f00';
|
|
897
|
+
JXG.Options.angle.label.strokeColor = 'blue';
|
|
898
|
+
JXG.Options.arc.strokeColor = 'blue';
|
|
899
|
+
JXG.Options.circle.center.fillColor = 'red';
|
|
900
|
+
JXG.Options.circle.center.strokeColor = 'blue';
|
|
901
|
+
JXG.Options.circumcircle.strokeColor = 'blue';
|
|
902
|
+
JXG.Options.circumcircle.center.fillColor = 'red';
|
|
903
|
+
JXG.Options.circumcircle.center.strokeColor = 'blue';
|
|
904
|
+
JXG.Options.circumcirclearc.strokeColor = 'blue';
|
|
905
|
+
JXG.Options.circumcirclesector.strokeColor = 'blue';
|
|
906
|
+
JXG.Options.circumcirclesector.fillColor = 'green';
|
|
907
|
+
JXG.Options.circumcirclesector.highlightFillColor = 'green';
|
|
908
|
+
JXG.Options.conic.strokeColor = 'blue';
|
|
909
|
+
JXG.Options.curve.strokeColor = 'blue';
|
|
910
|
+
JXG.Options.incircle.strokeColor = 'blue';
|
|
911
|
+
JXG.Options.incircle.center.fillColor = 'red';
|
|
912
|
+
JXG.Options.incircle.center.strokeColor = 'blue';
|
|
913
|
+
JXG.Options.inequality.fillColor = 'red';
|
|
914
|
+
JXG.Options.integral.fillColor = 'red';
|
|
915
|
+
JXG.Options.integral.curveLeft.color = 'red';
|
|
916
|
+
JXG.Options.integral.curveRight.color = 'red';
|
|
917
|
+
JXG.Options.line.strokeColor = 'blue';
|
|
918
|
+
JXG.Options.point.fillColor = 'red';
|
|
919
|
+
JXG.Options.point.strokeColor = 'red';
|
|
920
|
+
JXG.Options.polygon.fillColor = 'green';
|
|
921
|
+
JXG.Options.polygon.highlightFillColor = 'green';
|
|
922
|
+
JXG.Options.polygon.vertices.strokeColor = 'red';
|
|
923
|
+
JXG.Options.polygon.vertices.fillColor = 'red';
|
|
924
|
+
JXG.Options.regularpolygon.fillColor = 'green';
|
|
925
|
+
JXG.Options.regularpolygon.highlightFillColor = 'green';
|
|
926
|
+
JXG.Options.regularpolygon.vertices.strokeColor = 'red';
|
|
927
|
+
JXG.Options.regularpolygon.vertices.fillColor = 'red';
|
|
928
|
+
JXG.Options.riemannsum.fillColor = 'yellow';
|
|
929
|
+
JXG.Options.sector.fillColor = 'green';
|
|
930
|
+
JXG.Options.sector.highlightFillColor = 'green';
|
|
931
|
+
JXG.Options.semicircle.center.fillColor = 'red';
|
|
932
|
+
JXG.Options.semicircle.center.strokeColor = 'blue';
|
|
933
|
+
JXG.Options.slopetriangle.fillColor = 'red';
|
|
934
|
+
JXG.Options.slopetriangle.highlightFillColor = 'red';
|
|
935
|
+
JXG.Options.turtle.arrow.strokeColor = 'blue';
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
JXG.extend(JXG, /** @lends JXG */ {
|
|
939
|
+
/**
|
|
940
|
+
* Bang Wong color palette,
|
|
941
|
+
* optimized for various type
|
|
942
|
+
* of color blindness.
|
|
943
|
+
* It contains values for
|
|
944
|
+
* <ul>
|
|
945
|
+
* <li> 'black'
|
|
946
|
+
* <li> 'orange'
|
|
947
|
+
* <li> 'skyblue'
|
|
948
|
+
* <li> 'bluishgreen'
|
|
949
|
+
* <li> 'yellow'
|
|
950
|
+
* <li> 'darkblue'
|
|
951
|
+
* <li> 'vermillion'
|
|
952
|
+
* <li> 'reddishpurple'
|
|
953
|
+
* </ul>
|
|
954
|
+
*
|
|
955
|
+
* As substitutes for standard colors, it contains the following aliases:
|
|
956
|
+
*
|
|
957
|
+
* <ul>
|
|
958
|
+
* <li> black (= #000000)
|
|
959
|
+
* <li> blue (= darkblue)
|
|
960
|
+
* <li> green (= bluishgreen)
|
|
961
|
+
* <li> purple (= reddishpurple)
|
|
962
|
+
* <li> red (= vermillion)
|
|
963
|
+
* <li> white (= #ffffff)
|
|
964
|
+
* </ul>
|
|
965
|
+
*
|
|
966
|
+
* See <a href="https://www.nature.com/articles/nmeth.1618">Bang Wong: "Points of view: Color blindness"</a>
|
|
967
|
+
* and
|
|
968
|
+
* <a href="https://davidmathlogic.com/colorblind/">https://davidmathlogic.com/colorblind/</a>.
|
|
969
|
+
*
|
|
970
|
+
* @name JXG.paletteWong
|
|
971
|
+
* @type Object
|
|
972
|
+
* @see JXG.palette
|
|
973
|
+
* @example
|
|
974
|
+
* var p = board.create('line', [[-1, 1], [2, -3]], {strokeColor: JXG.paletteWong.yellow});
|
|
975
|
+
*/
|
|
976
|
+
paletteWong: {
|
|
977
|
+
black: '#000000',
|
|
978
|
+
orange: '#E69F00',
|
|
979
|
+
skyblue: '#56B4E9',
|
|
980
|
+
bluishgreen: '#009E73',
|
|
981
|
+
yellow: '#F0E442',
|
|
982
|
+
darkblue: '#0072B2',
|
|
983
|
+
vermillion: '#D55E00',
|
|
984
|
+
reddishpurple: '#CC79A7',
|
|
985
|
+
|
|
986
|
+
blue: '#0072B2',
|
|
987
|
+
red: '#D55E00', // vermillion
|
|
988
|
+
green: '#009E73', // bluishgreen
|
|
989
|
+
purple: '#CC79A7', // reddishpurple
|
|
990
|
+
white: '#ffffff'
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* Default color palette.
|
|
996
|
+
* Contains at least color values for
|
|
997
|
+
* <ul>
|
|
998
|
+
* <li> black
|
|
999
|
+
* <li> blue
|
|
1000
|
+
* <li> green
|
|
1001
|
+
* <li> purple
|
|
1002
|
+
* <li> red
|
|
1003
|
+
* <li> white
|
|
1004
|
+
* <li> yellow
|
|
1005
|
+
* </ul>
|
|
1006
|
+
*
|
|
1007
|
+
* @name JXG.palette
|
|
1008
|
+
* @type Object
|
|
1009
|
+
* @default JXG.paletteWong
|
|
1010
|
+
* @see JXG.paletteWong
|
|
1011
|
+
*
|
|
1012
|
+
* @example
|
|
1013
|
+
*
|
|
1014
|
+
* var p = board.create('line', [[-1, 1], [2, -3]], {strokeColor: JXG.palette.yellow});
|
|
1015
|
+
*
|
|
1016
|
+
*/
|
|
1017
|
+
JXG.palette = JXG.paletteWong;
|
|
1018
|
+
|
|
875
1019
|
return JXG;
|
|
876
1020
|
});
|
package/src/utils/dump.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -209,15 +209,6 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
209
209
|
|
|
210
210
|
this.addMarkers(board, 'dumped', false);
|
|
211
211
|
|
|
212
|
-
// This has been moved to toJavaScript and toJessie
|
|
213
|
-
/*
|
|
214
|
-
methods.push({
|
|
215
|
-
obj: '$board',
|
|
216
|
-
method: 'setBoundingBox',
|
|
217
|
-
params: [board.getBoundingBox(), true]
|
|
218
|
-
});
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
212
|
for (e = 0; e < len; e++) {
|
|
222
213
|
obj = board.objectsList[e];
|
|
223
214
|
element = {};
|
|
@@ -313,7 +304,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
313
304
|
}
|
|
314
305
|
return 'null';
|
|
315
306
|
case 'string':
|
|
316
|
-
return '\'' + obj.replace(/(["'])/g, '\\$1') + '\'';
|
|
307
|
+
return '\'' + obj.replace(/\\/g,'\\\\').replace(/(["'])/g, '\\$1') + '\'';
|
|
317
308
|
case 'number':
|
|
318
309
|
case 'boolean':
|
|
319
310
|
return obj.toString();
|
|
@@ -328,7 +319,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
328
319
|
* @returns {String} JessieCode
|
|
329
320
|
*/
|
|
330
321
|
toJessie: function (board) {
|
|
331
|
-
var i, elements,
|
|
322
|
+
var i, elements, id,
|
|
332
323
|
dump = this.dump(board),
|
|
333
324
|
script = [];
|
|
334
325
|
|
|
@@ -340,8 +331,15 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
340
331
|
if (elements[i].attributes.name.length > 0) {
|
|
341
332
|
script.push('// ' + elements[i].attributes.name);
|
|
342
333
|
}
|
|
343
|
-
|
|
344
334
|
script.push('s' + i + ' = ' + elements[i].type + '(' + elements[i].parents.join(', ') + ') ' + this.toJCAN(elements[i].attributes).replace(/\n/, '\\n') + ';');
|
|
335
|
+
|
|
336
|
+
if (elements[i].type === 'axis') {
|
|
337
|
+
// Handle the case that remove[All]Ticks had been called.
|
|
338
|
+
id = elements[i].attributes.id;
|
|
339
|
+
if (board.objects[id].defaultTicks === null) {
|
|
340
|
+
script.push('s' + i + '.removeAllTicks();');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
345
343
|
script.push('');
|
|
346
344
|
}
|
|
347
345
|
|
|
@@ -364,7 +362,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
364
362
|
* @returns {String} JavaScript
|
|
365
363
|
*/
|
|
366
364
|
toJavaScript: function (board) {
|
|
367
|
-
var i, elements,
|
|
365
|
+
var i, elements, id,
|
|
368
366
|
dump = this.dump(board),
|
|
369
367
|
script = [];
|
|
370
368
|
|
|
@@ -374,6 +372,14 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
374
372
|
|
|
375
373
|
for (i = 0; i < elements.length; i++) {
|
|
376
374
|
script.push('board.create("' + elements[i].type + '", [' + elements[i].parents.join(', ') + '], ' + Type.toJSON(elements[i].attributes) + ');');
|
|
375
|
+
|
|
376
|
+
if (elements[i].type === 'axis') {
|
|
377
|
+
// Handle the case that remove[All]Ticks had been called.
|
|
378
|
+
id = elements[i].attributes.id;
|
|
379
|
+
if (board.objects[id].defaultTicks === null) {
|
|
380
|
+
script.push('board.objects["' + id + '"].removeTicks(board.objects["' + id + '"].defaultTicks);');
|
|
381
|
+
}
|
|
382
|
+
}
|
|
377
383
|
}
|
|
378
384
|
|
|
379
385
|
for (i = 0; i < dump.methods.length; i++) {
|
package/src/utils/env.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -51,8 +51,9 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
51
51
|
JXG.extendConstants(JXG, /** @lends JXG */{
|
|
52
52
|
/**
|
|
53
53
|
* Determines the property that stores the relevant information in the event object.
|
|
54
|
-
* @type
|
|
54
|
+
* @type String
|
|
55
55
|
* @default 'touches'
|
|
56
|
+
* @private
|
|
56
57
|
*/
|
|
57
58
|
touchProperty: 'touches',
|
|
58
59
|
});
|
|
@@ -73,7 +74,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
73
74
|
* @returns {Boolean}
|
|
74
75
|
*/
|
|
75
76
|
isPointerEvent: function (evt) {
|
|
76
|
-
return JXG.exists(evt
|
|
77
|
+
return JXG.exists(evt.pointerId);
|
|
77
78
|
},
|
|
78
79
|
|
|
79
80
|
/**
|
|
@@ -131,12 +132,16 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
131
132
|
* @default false
|
|
132
133
|
*/
|
|
133
134
|
supportsES6: function () {
|
|
135
|
+
var testMap;
|
|
136
|
+
/* jshint ignore:start */
|
|
134
137
|
try {
|
|
138
|
+
// This would kill the old uglifyjs: testMap = (a = 0) => a;
|
|
135
139
|
new Function('(a = 0) => a');
|
|
136
140
|
return true;
|
|
137
141
|
} catch (err) {
|
|
138
142
|
return false;
|
|
139
143
|
}
|
|
144
|
+
/* jshint ignore:end */
|
|
140
145
|
},
|
|
141
146
|
|
|
142
147
|
/**
|
|
@@ -248,7 +253,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
248
253
|
* @returns {Boolean}
|
|
249
254
|
*/
|
|
250
255
|
isWebkitApple: function () {
|
|
251
|
-
return this.isApple() && (navigator.userAgent.search(/Mobile\/[0-9A-Za-z
|
|
256
|
+
return this.isApple() && (navigator.userAgent.search(/Mobile\/[0-9A-Za-z.]*Safari/) > -1);
|
|
252
257
|
},
|
|
253
258
|
|
|
254
259
|
/**
|
|
@@ -797,8 +802,8 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
797
802
|
* @see JXG.Board#fullscreenListener
|
|
798
803
|
* @private
|
|
799
804
|
*/
|
|
800
|
-
_getScaleFactors: function(node) {
|
|
801
|
-
var width
|
|
805
|
+
_getScaleFactors: function (node) {
|
|
806
|
+
var width = node.getBoundingClientRect().width,
|
|
802
807
|
height = node.getBoundingClientRect().height,
|
|
803
808
|
|
|
804
809
|
// Determine the maximum scale factor.
|
|
@@ -809,7 +814,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
809
814
|
vshift = (window.screen.height - height) * 0.5,
|
|
810
815
|
|
|
811
816
|
// Scaling factor: if not supplied, it's taken as large as possible
|
|
812
|
-
scale =
|
|
817
|
+
scale = Math.min(r_w, r_h);
|
|
813
818
|
|
|
814
819
|
// Adapt vshift and scale for landscape on tablets
|
|
815
820
|
if (window.matchMedia && window.matchMedia('(orientation:landscape)').matches &&
|
|
@@ -822,7 +827,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
822
827
|
}
|
|
823
828
|
scale *= 0.85;
|
|
824
829
|
|
|
825
|
-
return {scale: scale, vshift: vshift};
|
|
830
|
+
return { scale: scale, vshift: vshift, width: width };
|
|
826
831
|
},
|
|
827
832
|
|
|
828
833
|
/**
|
|
@@ -830,21 +835,21 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
830
835
|
* inside of a parent DOM
|
|
831
836
|
* element which is set to fullscreen.
|
|
832
837
|
* This is realized with a CSS transformation.
|
|
833
|
-
*
|
|
838
|
+
* *
|
|
834
839
|
* @param {String} wrap_id id of the parent DOM element which is in fullscreen mode
|
|
835
|
-
* @param {String} inner_id id of the DOM element which is scaled and shifted
|
|
840
|
+
* @param {String} inner_id id of the DOM element which is scaled and shifted
|
|
836
841
|
* @param {Number} scale Scaling factor
|
|
837
842
|
* @param {Number} vshift Vertical shift (in pixel)
|
|
838
843
|
*
|
|
839
844
|
* @private
|
|
840
|
-
* @see JXG#toFullscreen
|
|
845
|
+
* @see JXG.Board#toFullscreen
|
|
841
846
|
* @see JXG.Board#fullscreenListener
|
|
842
|
-
*
|
|
847
|
+
*
|
|
843
848
|
*/
|
|
844
849
|
scaleJSXGraphDiv: function (wrap_id, inner_id, scale, vshift) {
|
|
845
850
|
var len = document.styleSheets.length, style,
|
|
846
851
|
|
|
847
|
-
pseudo_keys = [':fullscreen', ':-webkit-full-screen', ':-moz-full-screen',':-ms-fullscreen'],
|
|
852
|
+
pseudo_keys = [':fullscreen', ':-webkit-full-screen', ':-moz-full-screen', ':-ms-fullscreen'],
|
|
848
853
|
len_pseudo = pseudo_keys.length, i,
|
|
849
854
|
|
|
850
855
|
// CSS rules to center the inner div horizontally and vertically.
|
|
@@ -852,10 +857,10 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
852
857
|
|
|
853
858
|
// A previously installed CSS rule to center the JSXGraph div has to
|
|
854
859
|
// be searched and removed again.
|
|
855
|
-
regex = new RegExp('
|
|
860
|
+
regex = new RegExp('.*#' + wrap_id + ':.*full.*screen.*#' + inner_id + '.*auto;.*transform:.*matrix');
|
|
856
861
|
|
|
857
862
|
if (len === 0) {
|
|
858
|
-
// In case there is not a single CSS rule defined.
|
|
863
|
+
// In case there is not a single CSS rule defined at all.
|
|
859
864
|
style = document.createElement('style');
|
|
860
865
|
// WebKit hack :(
|
|
861
866
|
style.appendChild(document.createTextNode(''));
|
|
@@ -875,57 +880,16 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
875
880
|
// Install a CSS rule to center the JSXGraph div at the first position of the list.
|
|
876
881
|
for (i = 0; i < len_pseudo; i++) {
|
|
877
882
|
try {
|
|
878
|
-
document.styleSheets[len - 1].insertRule(wrap_id + pseudo_keys[i] + ' ' + inner_id + rule_inner, 0);
|
|
883
|
+
document.styleSheets[len - 1].insertRule('#' + wrap_id + pseudo_keys[i] + ' #' + inner_id + rule_inner, 0);
|
|
879
884
|
break;
|
|
880
885
|
} catch (err) {
|
|
881
|
-
console.log('JXG.scaleJSXGraphDiv: Could not add CSS rule "' + pseudo_keys[i] + '".');
|
|
882
|
-
console.log('One possible reason could be that the id of the JSXGraph container does not start with a letter.');
|
|
886
|
+
// console.log('JXG.scaleJSXGraphDiv: Could not add CSS rule "' + pseudo_keys[i] + '".');
|
|
887
|
+
// console.log('One possible reason could be that the id of the JSXGraph container does not start with a letter.');
|
|
883
888
|
}
|
|
884
889
|
}
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
* Set the DOM element with id='wrap_id' containing the JSXGraph div
|
|
889
|
-
* element in fullscreen mode.
|
|
890
|
-
* The JSXGraph element is scaled as large as possible while
|
|
891
|
-
* retaining its proportions.
|
|
892
|
-
*
|
|
893
|
-
* @param {String} wrap_id id of DOM element containing the JSXGraph
|
|
894
|
-
* div element.
|
|
895
|
-
*
|
|
896
|
-
* @example
|
|
897
|
-
*
|
|
898
|
-
* <div id="outer" class="JXG_wrap_private">
|
|
899
|
-
* <div id='jxgbox' class='jxgbox' style='width:300px; height:300px;'></div>
|
|
900
|
-
* </div>
|
|
901
|
-
* <button onClick="JXG.toFullscreen('outer')">Fullscreen</button>
|
|
902
|
-
* <script>
|
|
903
|
-
* var board = JXG.JSXGraph.initBoard('jxgbox', {axis:true, boundingbox:[-8, 8, 8,-8]});
|
|
904
|
-
* var p = board.create('point', [0, 1]);
|
|
905
|
-
* </script>
|
|
906
|
-
*
|
|
907
|
-
* </pre><div id="JXGf9b973ea4_outer" class="JXG_wrap_private"><div id="JXGd9b973ea4-fd43-11e8-ab14-901b0e1b8723" class="jxgbox" style="width: 300px; height: 300px;"></div></div>
|
|
908
|
-
* <button onClick="JXG.toFullscreen('JXGf9b973ea4_outer')">Fullscreen</button>
|
|
909
|
-
* <script type="text/javascript">
|
|
910
|
-
* (function() {
|
|
911
|
-
* var board = JXG.JSXGraph.initBoard('JXGd9b973ea4-fd43-11e8-ab14-901b0e1b8723',
|
|
912
|
-
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
913
|
-
* var p = board.create('point', [0, 1]);
|
|
914
|
-
* })();
|
|
915
|
-
* </script><pre>
|
|
916
|
-
*
|
|
917
|
-
*/
|
|
918
|
-
toFullscreen: function (wrap_id) {
|
|
919
|
-
var elem = document.getElementById(wrap_id);
|
|
920
|
-
|
|
921
|
-
// Trigger the fullscreen mode
|
|
922
|
-
elem.requestFullscreen = elem.requestFullscreen ||
|
|
923
|
-
elem.webkitRequestFullscreen ||
|
|
924
|
-
elem.mozRequestFullScreen ||
|
|
925
|
-
elem.msRequestFullscreen;
|
|
926
|
-
|
|
927
|
-
if (elem.requestFullscreen) {
|
|
928
|
-
elem.requestFullscreen();
|
|
890
|
+
if (i === len_pseudo) {
|
|
891
|
+
console.log('JXG.scaleJSXGraphDiv: Could not add any CSS rule.');
|
|
892
|
+
console.log('One possible reason could be that the id of the JSXGraph container does not start with a letter.');
|
|
929
893
|
}
|
|
930
894
|
}
|
|
931
895
|
});
|
package/src/utils/event.js
CHANGED
package/src/utils/expect.js
CHANGED
package/src/utils/type.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -196,18 +196,29 @@ define([
|
|
|
196
196
|
* @param {Boolean} [checkEmptyString=false] If set to true, it is also checked whether v is not equal to ''.
|
|
197
197
|
* @returns {Boolean} True, if v is neither undefined nor null.
|
|
198
198
|
*/
|
|
199
|
-
exists:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
exists: function (v, checkEmptyString) {
|
|
200
|
+
/* eslint-disable eqeqeq */
|
|
201
|
+
var result = !(v == undefined || v === null);
|
|
202
|
+
/* eslint-enable eqeqeq */
|
|
203
|
+
checkEmptyString = checkEmptyString || false;
|
|
204
|
+
|
|
205
|
+
if (checkEmptyString) {
|
|
206
|
+
return result && v !== '';
|
|
207
|
+
}
|
|
208
|
+
return result;
|
|
209
|
+
},
|
|
210
|
+
// exists: (function (undef) {
|
|
211
|
+
// return function (v, checkEmptyString) {
|
|
212
|
+
// var result = !(v === undef || v === null);
|
|
213
|
+
|
|
214
|
+
// checkEmptyString = checkEmptyString || false;
|
|
215
|
+
|
|
216
|
+
// if (checkEmptyString) {
|
|
217
|
+
// return result && v !== '';
|
|
218
|
+
// }
|
|
219
|
+
// return result;
|
|
220
|
+
// };
|
|
221
|
+
// }()),
|
|
211
222
|
|
|
212
223
|
/**
|
|
213
224
|
* Checks if v is an empty object or empty.
|
|
@@ -703,12 +714,12 @@ define([
|
|
|
703
714
|
* is returned by JavaScript's toFixed()
|
|
704
715
|
*
|
|
705
716
|
* @memberOf JXG
|
|
706
|
-
* @param {Number} num
|
|
707
|
-
* @param {Number}
|
|
708
|
-
* @return {String}
|
|
717
|
+
* @param {Number} num Number tp be rounded
|
|
718
|
+
* @param {Number} digits Decimal digits
|
|
719
|
+
* @return {String} Rounded number is returned as string
|
|
709
720
|
*/
|
|
710
|
-
toFixed: function (num,
|
|
711
|
-
return this._round10(num, -
|
|
721
|
+
toFixed: function (num, digits) {
|
|
722
|
+
return this._round10(num, -digits).toFixed(digits);
|
|
712
723
|
},
|
|
713
724
|
|
|
714
725
|
/**
|
|
@@ -1155,7 +1166,7 @@ define([
|
|
|
1155
1166
|
* @returns {String}
|
|
1156
1167
|
*/
|
|
1157
1168
|
unescapeHTML: function (str) {
|
|
1158
|
-
//
|
|
1169
|
+
// This regex is NOT insecure. We are replacing everything found with ''
|
|
1159
1170
|
/*jslint regexp:true*/
|
|
1160
1171
|
return str.replace(/<\/?[^>]+>/gi, '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
1161
1172
|
},
|
package/src/utils/xml.js
CHANGED
package/src/utils/zip.js
CHANGED