lexgui 0.1.33 → 0.1.35

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/build/lexgui.js CHANGED
@@ -12,7 +12,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
12
12
  */
13
13
 
14
14
  var LX = global.LX = {
15
- version: "0.1.33",
15
+ version: "0.1.35",
16
16
  ready: false,
17
17
  components: [], // specific pre-build components
18
18
  signals: {} // events and triggers
@@ -25,8 +25,11 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
25
25
  LX.MOUSE_DOUBLE_CLICK = 2;
26
26
  LX.MOUSE_TRIPLE_CLICK = 3;
27
27
 
28
- function clamp (num, min, max) { return Math.min(Math.max(num, min), max) }
29
- function round(num, n) { return +num.toFixed(n); }
28
+ LX.CURVE_MOVEOUT_CLAMP = 0;
29
+ LX.CURVE_MOVEOUT_DELETE = 1;
30
+
31
+ function clamp( num, min, max ) { return Math.min( Math.max( num, min ), max ); }
32
+ function round( num, n ) { return +num.toFixed( n ); }
30
33
 
31
34
  function getSupportedDOMName( string )
32
35
  {
@@ -469,7 +472,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
469
472
  var link = document.createElement( 'link' );
470
473
  link.rel = 'stylesheet';
471
474
  link.type = 'text/css';
472
- link.href = 'https://use.fontawesome.com/releases/v6.5.1/css/all.css';
475
+ link.href = 'https://use.fontawesome.com/releases/v6.6.0/css/all.css';
473
476
  head.appendChild( link );
474
477
 
475
478
  // Global vars
@@ -523,26 +526,29 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
523
526
  * size: (Array) [width, height]
524
527
  */
525
528
 
526
- function popup(text, title, options = {})
529
+ function popup( text, title, options = {} )
527
530
  {
528
- if(!text)
531
+ if( !text )
532
+ {
529
533
  throw("No message to show");
534
+ }
530
535
 
531
- options.size = options.size ?? ["auto", "auto"];
536
+ options.size = options.size ?? [ "auto", "auto" ];
532
537
  options.class = "lexpopup";
533
- const time = options.timeout || 3000;
534
538
 
535
- const dialog = new Dialog(title, p => {
536
- p.addTextArea(null, text, null, { disabled: true, fitHeight: true });
537
- }, options);
538
-
539
- dialog.root.classList.add("fadein");
539
+ const time = options.timeout || 3000;
540
+ const dialog = new Dialog( title, p => {
541
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
542
+ }, options );
543
+
544
+ dialog.root.classList.add( 'fadein' );
540
545
  setTimeout(() => {
541
- dialog.root.classList.remove("fadein");
542
- dialog.root.classList.add("fadeout");
543
- }, time - 1000);
546
+ dialog.root.classList.remove( 'fadein' );
547
+ dialog.root.classList.add( 'fadeout' );
548
+ }, time - 1000 );
549
+
550
+ setTimeout( dialog.close, time );
544
551
 
545
- setTimeout(dialog.close, time);
546
552
  return dialog;
547
553
  }
548
554
 
@@ -561,36 +567,45 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
561
567
  * required: Input has to be filled [true]. Default: false
562
568
  */
563
569
 
564
- function prompt(text, title, callback, options = {})
570
+ function prompt( text, title, callback, options = {} )
565
571
  {
566
572
  options.modal = true;
567
573
 
568
574
  let value = "";
569
575
 
570
- const dialog = new Dialog(title, p => {
571
- p.addTextArea(null, text, null, { disabled: true });
572
- if(options.input !== false)
573
- p.addText(null, options.input || value, (v) => value = v, {placeholder: "..."} );
574
- p.sameLine(2);
575
- p.addButton(null, options.accept || "OK", () => {
576
- if(options.required && value === '') {
576
+ const dialog = new Dialog( title, p => {
577
577
 
578
- text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
579
- dialog.close() ;
580
- prompt(text, title, callback, options);
581
- }else {
578
+ p.addTextArea( null, text, null, { disabled: true, fitHeight: true } );
579
+
580
+ if( options.input ?? true )
581
+ {
582
+ p.addText( null, options.input || value, v => value = v, { placeholder: "..." } );
583
+ }
582
584
 
583
- callback.call(this, value);
584
- dialog.close() ;
585
+ p.sameLine( 2 );
586
+
587
+ p.addButton( null, options.accept || "OK", () => {
588
+ if( options.required && value === '' )
589
+ {
590
+ text += text.includes("You must fill the input text.") ? "": "\nYou must fill the input text.";
591
+ dialog.close();
592
+ prompt( text, title, callback, options );
593
+ }else
594
+ {
595
+ if( callback ) callback.call( this, value );
596
+ dialog.close();
585
597
  }
586
-
587
598
  }, { buttonClass: "accept" });
599
+
588
600
  p.addButton(null, "Cancel", () => {if(options.on_cancel) options.on_cancel(); dialog.close();} );
589
- }, options);
601
+
602
+ }, options );
590
603
 
591
604
  // Focus text prompt
592
- if(options.input !== false)
593
- dialog.root.querySelector('input').focus();
605
+ if( options.input ?? true )
606
+ {
607
+ dialog.root.querySelector( 'input' ).focus();
608
+ }
594
609
 
595
610
  return dialog;
596
611
  }
@@ -881,35 +896,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
881
896
 
882
897
  split( options = {} ) {
883
898
 
884
- if(this.sections.length)
899
+ if( this.sections.length )
885
900
  {
886
901
  // In case Area has been split before, get 2nd section as root
887
- this.offset = this.root.childNodes[0].offsetHeight; // store offset to take into account when resizing
888
- this._root = this.sections[0].root;
889
- this.root = this.sections[1].root;
902
+ this.offset = this.root.childNodes[ 0 ].offsetHeight; // store offset to take into account when resizing
903
+ this._root = this.sections[ 0 ].root;
904
+ this.root = this.sections[ 1 ].root;
890
905
  }
891
906
 
892
907
  var type = options.type || "horizontal";
893
- var sizes = options.sizes || ["50%", "50%"];
908
+ var sizes = options.sizes || [ "50%", "50%" ];
894
909
  var infer_height = false;
895
- var auto = options.sizes === 'auto';
910
+ var auto = (options.sizes === 'auto');
896
911
 
897
- if( !sizes[1] )
912
+ if( !sizes[ 1 ] )
898
913
  {
899
- let size = sizes[0];
914
+ let size = sizes[ 0 ];
900
915
  let margin = options.top ? options.top : 0;
901
- if(size.constructor == Number) {
916
+ if( size.constructor == Number )
917
+ {
902
918
  size += margin;
903
919
  size += "px";
904
920
  }
905
-
906
- sizes[1] = "calc( 100% - " + size + " )";
921
+
922
+ sizes[ 1 ] = "calc( 100% - " + size + " )";
907
923
  infer_height = true;
908
924
  }
909
925
 
910
926
  // Create areas
911
- var area1 = new Area({ no_append: true, className: "split" + (options.menubar || options.sidebar ? "" : " origin") });
912
- var area2 = new Area({ no_append: true, className: "split"});
927
+ var area1 = new Area( { no_append: true, className: "split" + ( options.menubar || options.sidebar ? "" : " origin" ) } );
928
+ var area2 = new Area( { no_append: true, className: "split"} );
913
929
 
914
930
  area1.parentArea = this;
915
931
  area2.parentArea = this;
@@ -920,23 +936,27 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
920
936
  var data = "0px";
921
937
  this.offset = 0;
922
938
 
923
- if(resize)
939
+ if( resize )
924
940
  {
925
941
  this.resize = resize;
926
- this.split_bar = document.createElement("div");
942
+ this.split_bar = document.createElement( "div" );
927
943
  this.split_bar.className = "lexsplitbar " + type;
928
944
 
929
- if(type == "horizontal") {
945
+ if( type == "horizontal" )
946
+ {
930
947
  this.split_bar.style.width = LX.DEFAULT_SPLITBAR_SIZE + "px";
931
948
  }
932
- else {
949
+ else
950
+ {
933
951
  this.split_bar.style.height = LX.DEFAULT_SPLITBAR_SIZE + "px";
934
952
  }
935
- this.split_bar.addEventListener("mousedown", inner_mousedown);
936
- data = LX.DEFAULT_SPLITBAR_SIZE/2 + "px"; // updates
953
+
954
+ this.split_bar.addEventListener( 'mousedown', inner_mousedown );
955
+
956
+ data = ( LX.DEFAULT_SPLITBAR_SIZE / 2 ) + "px"; // updates
937
957
 
938
958
  // Being minimizable means it's also resizeable!
939
- if(minimizable)
959
+ if( minimizable )
940
960
  {
941
961
  this.split_extended = false;
942
962
 
@@ -958,14 +978,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
958
978
  }
959
979
  }
960
980
 
961
- if(type == "horizontal")
981
+ if( type == "horizontal" )
962
982
  {
963
- var width1 = sizes[0],
964
- width2 = sizes[1];
983
+ var width1 = sizes[ 0 ],
984
+ width2 = sizes[ 1 ];
965
985
 
966
- if(width1.constructor == Number)
986
+ if( width1.constructor == Number )
967
987
  width1 += "px";
968
- if(width2.constructor == Number)
988
+ if( width2.constructor == Number )
969
989
  width2 += "px";
970
990
 
971
991
  area1.root.style.width = "calc( " + width1 + " - " + data + " )";
@@ -984,20 +1004,20 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
984
1004
  area1.root.style.height = "auto";
985
1005
 
986
1006
  // Listen resize event on first area
987
- const resizeObserver = new ResizeObserver((entries) => {
1007
+ const resizeObserver = new ResizeObserver( entries => {
988
1008
  for (const entry of entries) {
989
1009
  const bb = entry.contentRect;
990
1010
  area2.root.style.height = "calc(100% - " + ( bb.height + 4) + "px )";
991
1011
  }
992
1012
  });
993
1013
 
994
- resizeObserver.observe(area1.root);
1014
+ resizeObserver.observe( area1.root );
995
1015
  }
996
1016
  else
997
1017
  {
998
- var height1 = sizes[0],
999
- height2 = sizes[1];
1000
-
1018
+ var height1 = sizes[ 0 ],
1019
+ height2 = sizes[ 1 ];
1020
+
1001
1021
  if(height1.constructor == Number)
1002
1022
  height1 += "px";
1003
1023
  if(height2.constructor == Number)
@@ -1011,7 +1031,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1011
1031
 
1012
1032
  this.root.appendChild( area1.root );
1013
1033
 
1014
- if(resize)
1034
+ if( resize )
1015
1035
  {
1016
1036
  this.root.appendChild(this.split_bar);
1017
1037
  }
@@ -1023,55 +1043,67 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
1023
1043
  // Update sizes
1024
1044
  this._update();
1025
1045
 
1026
- if(!resize)
1046
+ if( !resize )
1027
1047
  {
1028
1048
  return this.sections;
1029
1049
  }
1030
1050
 
1031
- // from litegui.js @jagenjo
1032
-
1033
1051
  var that = this;
1034
- var last_pos = [0,0];
1035
- function inner_mousedown(e)
1052
+ var last_pos = [ 0, 0 ];
1053
+
1054
+ function inner_mousedown( e )
1036
1055
  {
1037
1056
  var doc = that.root.ownerDocument;
1038
- doc.addEventListener("mousemove",inner_mousemove);
1039
- doc.addEventListener("mouseup",inner_mouseup);
1057
+ doc.addEventListener( 'mousemove', inner_mousemove );
1058
+ doc.addEventListener( 'mouseup', inner_mouseup );
1040
1059
  last_pos[0] = e.x;
1041
1060
  last_pos[1] = e.y;
1042
1061
  e.stopPropagation();
1043
1062
  e.preventDefault();
1044
- document.body.classList.add("nocursor");
1045
- that.split_bar.classList.add("nocursor");
1063
+ document.body.classList.add( 'nocursor' );
1064
+ that.split_bar.classList.add( 'nocursor' );
1046
1065
  }
1047
1066
 
1048
- function inner_mousemove(e)
1067
+ function inner_mousemove( e )
1049
1068
  {
1050
- if(that.type == "horizontal") {
1051
- that._moveSplit(last_pos[0] - e.x);
1069
+ if(that.type == "horizontal")
1070
+ {
1071
+ that._moveSplit( last_pos[ 0 ] - e.x );
1052
1072
  }
1053
- else {
1054
- that._moveSplit(last_pos[1] - e.y);
1073
+ else
1074
+ {
1075
+ that._moveSplit( last_pos[ 1 ] - e.y );
1055
1076
  }
1056
-
1057
- last_pos[0] = e.x;
1058
- last_pos[1] = e.y;
1077
+
1078
+ last_pos[ 0 ] = e.x;
1079
+ last_pos[ 1 ] = e.y;
1080
+
1081
+ const widgets = that.root.querySelectorAll( ".lexwidget" );
1082
+
1083
+ // Send area resize to every widget in the area
1084
+ for( let widget of widgets )
1085
+ {
1086
+ const jsInstance = widget.jsIinstance;
1087
+
1088
+ if( jsInstance.onresize )
1089
+ {
1090
+ jsInstance.onresize();
1091
+ }
1092
+ }
1093
+
1059
1094
  e.stopPropagation();
1060
1095
  e.preventDefault();
1061
1096
  }
1062
1097
 
1063
- function inner_mouseup(e)
1098
+ function inner_mouseup( e )
1064
1099
  {
1065
1100
  var doc = that.root.ownerDocument;
1066
- doc.removeEventListener("mousemove",inner_mousemove);
1067
- doc.removeEventListener("mouseup",inner_mouseup);
1068
- document.body.classList.remove("nocursor");
1069
- that.split_bar.classList.remove("nocursor");
1101
+ doc.removeEventListener( 'mousemove', inner_mousemove );
1102
+ doc.removeEventListener( 'mouseup', inner_mouseup );
1103
+ document.body.classList.remove( 'nocursor' );
1104
+ that.split_bar.classList.remove( 'nocursor' );
1070
1105
  }
1071
1106
 
1072
- // Is this necessary?..
1073
- // setTimeout( () => this._moveSplit(0), 100);
1074
-
1075
1107
  return this.sections;
1076
1108
  }
1077
1109
 
@@ -3217,7 +3249,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
3217
3249
 
3218
3250
  if( type != Widget.TITLE )
3219
3251
  {
3220
- element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE || ( type == Widget.BUTTON && !name ) ? 10 : 20) + "px)";
3252
+ element.style.width = "calc(100% - " + (this.current_branch || type == Widget.FILE ? 10 : 20) + "px)";
3221
3253
  if( options.width ) {
3222
3254
  element.style.width = element.style.minWidth = options.width;
3223
3255
  }
@@ -4033,37 +4065,39 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4033
4065
 
4034
4066
  addDropdown( name, values, value, callback, options = {} ) {
4035
4067
 
4036
- let widget = this.create_widget(name, Widget.DROPDOWN, options);
4068
+ let widget = this.create_widget( name, Widget.DROPDOWN, options );
4069
+
4037
4070
  widget.onGetValue = () => {
4038
- return element.querySelector("li.selected").getAttribute('value');
4071
+ return element.querySelector( "li.selected" ).getAttribute( 'value' );
4039
4072
  };
4073
+
4040
4074
  widget.onSetValue = ( newValue, skipCallback ) => {
4041
- let btn = element.querySelector(".lexwidgetname .lexicon");
4042
- if(btn) btn.style.display = (newValue != wValue.iValue ? "block" : "none");
4075
+ let btn = element.querySelector( ".lexwidgetname .lexicon" );
4076
+ if( btn ) btn.style.display = ( newValue != wValue.iValue ? "block" : "none" );
4043
4077
  value = newValue;
4044
- list.querySelectorAll('li').forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
4045
- if( !skipCallback ) this._trigger( new IEvent(name, value, null), callback );
4078
+ list.querySelectorAll( 'li' ).forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
4079
+ if( !skipCallback ) this._trigger( new IEvent( name, value, null ), callback );
4046
4080
  };
4047
4081
 
4048
4082
  let element = widget.domEl;
4049
4083
  let that = this;
4050
4084
 
4051
4085
  // Add reset functionality
4052
- if(widget.name && !(options.skipReset ?? false))
4086
+ if(widget.name && !( options.skipReset ?? false ))
4053
4087
  {
4054
- Panel._add_reset_property(element.domName, function() {
4088
+ Panel._add_reset_property( element.domName, function() {
4055
4089
  value = wValue.iValue;
4056
- list.querySelectorAll('li').forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
4090
+ list.querySelectorAll( 'li' ).forEach( e => { if( e.getAttribute('value') == value ) e.click() } );
4057
4091
  this.style.display = "none";
4058
4092
  });
4059
4093
  }
4060
4094
 
4061
- let container = document.createElement('div');
4095
+ let container = document.createElement( 'div' );
4062
4096
  container.className = "lexdropdown";
4063
4097
  container.style.width = options.inputWidth || "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4064
-
4098
+
4065
4099
  // Add widget value
4066
- let wValue = document.createElement('div');
4100
+ let wValue = document.createElement( 'div' );
4067
4101
  wValue.className = "lexdropdown lexoption";
4068
4102
  wValue.name = name;
4069
4103
  wValue.iValue = value;
@@ -4074,14 +4108,15 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4074
4108
 
4075
4109
  this.queue(container);
4076
4110
 
4077
- let selectedOption = this.addButton(null, buttonName, (value, event) => {
4111
+ let selectedOption = this.addButton( null, buttonName, (value, event) => {
4078
4112
  if( list.unfocus_event ) {
4079
4113
  delete list.unfocus_event;
4080
4114
  return;
4081
4115
  }
4082
- element.querySelector(".lexoptions").style.top = (selectedOption.offsetTop + selectedOption.offsetHeight) + 'px';
4083
- element.querySelector(".lexoptions").style.width = (event.currentTarget.clientWidth) + 'px';
4084
- element.querySelector(".lexoptions").toggleAttribute('hidden');
4116
+ const topPosition = selectedOption.getBoundingClientRect().y;
4117
+ list.style.top = (topPosition + selectedOption.offsetHeight) + 'px';
4118
+ list.style.width = (event.currentTarget.clientWidth) + 'px';
4119
+ list.toggleAttribute('hidden');
4085
4120
  list.focus();
4086
4121
  }, { buttonClass: 'array', skipInlineCount: true });
4087
4122
 
@@ -4225,7 +4260,14 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4225
4260
  * @param {Function} callback Callback function on change
4226
4261
  * @param {*} options:
4227
4262
  * skipReset: Don't add the reset value button when value changes
4228
- */
4263
+ * bgColor: Widget background color
4264
+ * pointsColor: Curve points color
4265
+ * lineColor: Curve line color
4266
+ * noOverlap: Points do not overlap, replacing themselves if necessary
4267
+ * allowAddValues: Support adding values on click
4268
+ * smooth: Curve smoothness
4269
+ * moveOutAction: Clamp or delete points moved out of the curve (LX.CURVE_MOVEOUT_CLAMP, LX.CURVE_MOVEOUT_DELETE)
4270
+ */
4229
4271
 
4230
4272
  addCurve( name, values, callback, options = {} ) {
4231
4273
 
@@ -4235,34 +4277,36 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4235
4277
 
4236
4278
  let that = this;
4237
4279
  let widget = this.create_widget(name, Widget.CURVE, options);
4280
+
4238
4281
  widget.onGetValue = () => {
4239
- return JSON.parse(JSON.stringify(curve_instance.element.value));
4282
+ return JSON.parse(JSON.stringify(curveInstance.element.value));
4240
4283
  };
4284
+
4241
4285
  widget.onSetValue = ( newValue, skipCallback ) => {
4242
- let btn = element.querySelector(".lexwidgetname .lexicon");
4243
- if(btn) btn.style.display = (newValue != curve_instance.element.value ? "block" : "none");
4244
- curve_instance.element.value = JSON.parse(JSON.stringify(newValue));
4245
- curve_instance.redraw();
4246
- if( !skipCallback ) that._trigger( new IEvent(name, curve_instance.element.value, null), callback );
4286
+ let btn = element.querySelector( ".lexwidgetname .lexicon" );
4287
+ if( btn ) btn.style.display = ( newValue != curveInstance.element.value ? "block" : "none" );
4288
+ curveInstance.element.value = JSON.parse( JSON.stringify( newValue ) );
4289
+ curveInstance.redraw();
4290
+ if( !skipCallback ) that._trigger( new IEvent( name, curveInstance.element.value, null ), callback );
4247
4291
  };
4248
4292
 
4249
4293
  let element = widget.domEl;
4250
- let defaultValues = JSON.parse(JSON.stringify(values));
4294
+ let defaultValues = JSON.parse( JSON.stringify( values ) );
4251
4295
 
4252
4296
  // Add reset functionality
4253
4297
  if( !(options.skipReset ?? false) )
4254
4298
  {
4255
4299
  Panel._add_reset_property(element.domName, function(e) {
4256
4300
  this.style.display = "none";
4257
- curve_instance.element.value = JSON.parse(JSON.stringify(defaultValues));
4258
- curve_instance.redraw();
4259
- that._trigger( new IEvent(name, curve_instance.element.value, e), callback );
4301
+ curveInstance.element.value = JSON.parse( JSON.stringify( defaultValues ) );
4302
+ curveInstance.redraw();
4303
+ that._trigger( new IEvent( name, curveInstance.element.value, e ), callback );
4260
4304
  });
4261
4305
  }
4262
4306
 
4263
4307
  // Add widget value
4264
4308
 
4265
- var container = document.createElement('div');
4309
+ var container = document.createElement( 'div' );
4266
4310
  container.className = "lexcurve";
4267
4311
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4268
4312
 
@@ -4271,16 +4315,22 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4271
4315
  if(btn) btn.style.display = (v != defaultValues ? "block" : "none");
4272
4316
  that._trigger( new IEvent(name, v, e), callback );
4273
4317
  };
4318
+
4274
4319
  options.name = name;
4275
- let curve_instance = new Curve(this, values, options);
4276
- container.appendChild(curve_instance.element);
4277
- element.appendChild(container);
4320
+
4321
+ let curveInstance = new Curve( this, values, options );
4322
+ container.appendChild( curveInstance.element );
4323
+ element.appendChild( container );
4278
4324
 
4279
4325
  // Resize
4280
- curve_instance.canvas.width = container.offsetWidth;
4281
- curve_instance.redraw();
4282
- widget.onresize = curve_instance.redraw.bind(curve_instance);
4283
- widget.curve_instance = curve_instance;
4326
+ widget.onresize = curveInstance.redraw.bind( curveInstance );
4327
+ widget.curveInstance = curveInstance;
4328
+
4329
+ doAsync(() => {
4330
+ curveInstance.canvas.width = container.offsetWidth;
4331
+ curveInstance.redraw();
4332
+ });
4333
+
4284
4334
  return widget;
4285
4335
  }
4286
4336
 
@@ -4729,19 +4779,19 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4729
4779
  flag.id = "checkbox"+simple_guidGenerator();
4730
4780
  flag.innerHTML = "<a class='fa-solid fa-check' style='display: " + (flag.value ? "block" : "none") + "'></a>";
4731
4781
 
4732
- if(options.disabled) {
4782
+ if( options.disabled ) {
4733
4783
  flag.disabled = true;
4734
4784
  toggle.className += " disabled";
4735
4785
  }
4736
4786
 
4737
- toggle.appendChild(flag);
4787
+ toggle.appendChild( flag );
4738
4788
 
4739
- let value_name = document.createElement('span');
4789
+ let value_name = document.createElement( 'span' );
4740
4790
  value_name.id = "checkboxtext";
4741
4791
  value_name.innerHTML = "On";
4742
4792
 
4743
- container.appendChild(toggle);
4744
- container.appendChild(value_name);
4793
+ container.appendChild( toggle );
4794
+ container.appendChild( value_name );
4745
4795
 
4746
4796
  toggle.addEventListener( "click" , e => {
4747
4797
 
@@ -4749,7 +4799,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4749
4799
  if( flag.disabled )
4750
4800
  return;
4751
4801
 
4752
- const skipCallback = (e.detail.constructor == Number ? null : skipCallback);
4802
+ const skipCallback = ( e.detail.constructor == Number ? null : e.detail );
4753
4803
 
4754
4804
  let check = toggle.querySelector( ".checkbox a" );
4755
4805
 
@@ -4833,7 +4883,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4833
4883
  container.style.width = "calc( 100% - " + LX.DEFAULT_NAME_WIDTH + ")";
4834
4884
 
4835
4885
  let color = document.createElement( 'input' );
4836
- color.style.width = "calc(30% - 6px)";
4886
+ color.style.width = "32px";
4837
4887
  color.type = 'color';
4838
4888
  color.className = "colorinput";
4839
4889
  color.id = "color" + simple_guidGenerator();
@@ -4874,7 +4924,7 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
4874
4924
  change_from_input = true;
4875
4925
  widget.set( v );
4876
4926
  change_from_input = false;
4877
- }, { width: "calc(70% - 4px)" });
4927
+ }, { width: "calc( 100% - 32px )"});
4878
4928
 
4879
4929
  text_widget.domEl.style.marginLeft = "4px";
4880
4930
 
@@ -6404,78 +6454,80 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6404
6454
 
6405
6455
  class Curve {
6406
6456
 
6407
- constructor(panel, value, options = {}) {
6408
-
6409
- let element = document.createElement("div");
6410
- element.className = "curve " + (options.className ? options.className : "");
6457
+ constructor( panel, value, options = {} ) {
6458
+
6459
+ let element = document.createElement( "div" );
6460
+ element.className = "curve " + ( options.className ? options.className : "" );
6411
6461
  element.style.minHeight = "50px";
6412
6462
  element.style.width = options.width || "100%";
6413
-
6414
- element.bgcolor = options.bgcolor || LX.getThemeColor("global-dark-background");
6415
- element.pointscolor = options.pointscolor || LX.getThemeColor("global-selected-light");
6416
- element.linecolor = options.linecolor || "#555";
6417
-
6418
- element.value = value || [];
6419
- element.xrange = options.xrange || [0,1]; //min,max
6420
- element.yrange = options.yrange || [0,1]; //min,max
6421
- element.defaulty = options.defaulty != null ? options.defaulty : 0.0;
6422
- element.no_trespassing = options.no_trespassing || false;
6423
- element.show_samples = options.show_samples || 0;
6424
- element.allow_add_values = options.allow_add_values ?? true;
6425
- element.draggable_x = options.draggable_x ?? true;
6426
- element.draggable_y = options.draggable_y ?? true;
6427
- element.smooth = (options.smooth && typeof(options.smooth) == 'number' ? options.smooth : 0.3) || false;
6428
- element.options = options;
6429
6463
  element.style.minWidth = "50px";
6430
6464
  element.style.minHeight = "20px";
6431
-
6465
+
6466
+ element.bgcolor = options.bgColor || LX.getThemeColor( "global-dark-background" );
6467
+ element.pointscolor = options.pointsColor || LX.getThemeColor( "global-selected-light" );
6468
+ element.linecolor = options.lineColor || "#555";
6469
+ element.value = value || [];
6470
+ element.xrange = options.xrange || [ 0, 1 ]; // min, max
6471
+ element.yrange = options.yrange || [ 0, 1 ]; // min, max
6472
+ element.defaulty = options.defaulty != null ? options.defaulty : 0.0;
6473
+ element.no_overlap = options.noOverlap || false;
6474
+ element.show_samples = options.showSamples || 0;
6475
+ element.allow_add_values = options.allowAddValues ?? true;
6476
+ element.draggable_x = options.draggableX ?? true;
6477
+ element.draggable_y = options.draggableY ?? true;
6478
+ element.smooth = (options.smooth && typeof( options.smooth ) == 'number' ? options.smooth : 0.3) || false;
6479
+ element.move_out = options.moveOutAction ?? LX.CURVE_MOVEOUT_DELETE;
6480
+
6432
6481
  this.element = element;
6433
-
6434
- let canvas = document.createElement("canvas");
6482
+
6483
+ let canvas = document.createElement( "canvas" );
6435
6484
  canvas.width = options.width || 200;
6436
6485
  canvas.height = options.height || 50;
6437
6486
  element.appendChild( canvas );
6438
6487
  this.canvas = canvas;
6439
-
6440
- element.addEventListener("mousedown", onmousedown);
6441
-
6442
- element.getValueAt = function(x) {
6443
-
6444
- if(x < element.xrange[0] || x > element.xrange[1])
6488
+
6489
+ element.addEventListener( "mousedown", onmousedown );
6490
+
6491
+ element.getValueAt = function( x ) {
6492
+
6493
+ if( x < element.xrange[ 0 ] || x > element.xrange[ 1 ] )
6494
+ {
6445
6495
  return element.defaulty;
6446
-
6447
- var last = [ element.xrange[0], element.defaulty ];
6496
+ }
6497
+
6498
+ var last = [ element.xrange[ 0 ], element.defaulty ];
6448
6499
  var f = 0;
6449
- for(var i = 0; i < element.value.length; i += 1)
6500
+ for( var i = 0; i < element.value.length; i += 1 )
6450
6501
  {
6451
- var v = element.value[i];
6452
- if(x == v[0]) return v[1];
6453
- if(x < v[0])
6502
+ var v = element.value[ i ];
6503
+ if( x == v[ 0 ] ) return v[ 1 ];
6504
+ if( x < v[ 0 ] )
6454
6505
  {
6455
- f = (x - last[0]) / (v[0] - last[0]);
6456
- return last[1] * (1-f) + v[1] * f;
6506
+ f = ( x - last[ 0 ] ) / (v[ 0 ] - last[ 0 ]);
6507
+ return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
6457
6508
  }
6509
+
6458
6510
  last = v;
6459
6511
  }
6460
-
6461
- v = [ element.xrange[1], element.defaulty ];
6462
- f = (x - last[0]) / (v[0] - last[0]);
6463
- return last[1] * (1-f) + v[1] * f;
6512
+
6513
+ v = [ element.xrange[ 1 ], element.defaulty ];
6514
+ f = (x - last[ 0 ]) / (v[ 0 ] - last[ 0 ]);
6515
+ return last[ 1 ] * ( 1 - f ) + v[ 1 ] * f;
6464
6516
  }
6465
-
6466
- element.resample = function(samples) {
6467
-
6517
+
6518
+ element.resample = function( samples ) {
6519
+
6468
6520
  var r = [];
6469
- var dx = (element.xrange[1] - element.xrange[0]) / samples;
6521
+ var dx = (element.xrange[1] - element.xrange[ 0 ]) / samples;
6470
6522
  for(var i = element.xrange[0]; i <= element.xrange[1]; i += dx)
6471
6523
  {
6472
6524
  r.push( element.getValueAt(i) );
6473
6525
  }
6474
6526
  return r;
6475
6527
  }
6476
-
6528
+
6477
6529
  element.addValue = function(v) {
6478
-
6530
+
6479
6531
  for(var i = 0; i < element.value; i++) {
6480
6532
  var value = element.value[i];
6481
6533
  if(value[0] < v[0]) continue;
@@ -6483,231 +6535,247 @@ console.warn( 'Script "build/lexgui.js" is depracated and will be removed soon.
6483
6535
  redraw();
6484
6536
  return;
6485
6537
  }
6486
-
6538
+
6487
6539
  element.value.push(v);
6488
6540
  redraw();
6489
6541
  }
6490
-
6542
+
6491
6543
  //value to canvas
6492
6544
  function convert(v) {
6493
6545
  return [ canvas.width * ( v[0] - element.xrange[0])/ (element.xrange[1]),
6494
6546
  canvas.height * (v[1] - element.yrange[0])/ (element.yrange[1])];
6495
- // return [ canvas.width * ( (element.xrange[1] - element.xrange[0]) * v[0] + element.xrange[0]),
6496
- // canvas.height * ((element.yrange[1] - element.yrange[0]) * v[1] + element.yrange[0])];
6497
6547
  }
6498
-
6548
+
6499
6549
  //canvas to value
6500
6550
  function unconvert(v) {
6501
6551
  return [(v[0] * element.xrange[1] / canvas.width + element.xrange[0]),
6502
6552
  (v[1] * element.yrange[1] / canvas.height + element.yrange[0])];
6503
- // return [(v[0] / canvas.width - element.xrange[0]) / (element.xrange[1] - element.xrange[0]),
6504
- // (v[1] / canvas.height - element.yrange[0]) / (element.yrange[1] - element.yrange[0])];
6505
6553
  }
6506
-
6554
+
6507
6555
  var selected = -1;
6508
-
6509
- element.redraw = function(o = {} ) {
6556
+
6557
+ element.redraw = function( o = {} ) {
6510
6558
 
6511
- if(o.value) element.value = o.value;
6512
- if(o.xrange) element.xrange = o.xrange;
6513
- if(o.yrange) element.yrange = o.yrange;
6514
- if(o.smooth) element.smooth = o.smooth;
6559
+ if( o.value ) element.value = o.value;
6560
+ if( o.xrange ) element.xrange = o.xrange;
6561
+ if( o.yrange ) element.yrange = o.yrange;
6562
+ if( o.smooth ) element.smooth = o.smooth;
6515
6563
  var rect = canvas.parentElement.getBoundingClientRect();
6516
- if(canvas.parentElement.parentElement) rect = canvas.parentElement.parentElement.getBoundingClientRect();
6517
- if(rect && canvas.width != rect.width && rect.width && rect.width < 1000)
6564
+ if( canvas.parentElement.parentElement ) rect = canvas.parentElement.parentElement.getBoundingClientRect();
6565
+ if( rect && canvas.width != rect.width && rect.width && rect.width < 1000 )
6566
+ {
6518
6567
  canvas.width = rect.width;
6519
- // if(rect && canvas.height != rect.height && rect.height && rect.height < 1000)
6520
- // canvas.height = rect.height;
6521
-
6522
- var ctx = canvas.getContext("2d");
6523
- ctx.setTransform(1, 0, 0, 1, 0, 0);
6524
- ctx.translate(0,canvas.height);
6525
- ctx.scale(1,-1);
6526
-
6568
+ }
6569
+
6570
+ var ctx = canvas.getContext( "2d" );
6571
+ ctx.setTransform( 1, 0, 0, 1, 0, 0 );
6572
+ ctx.translate( 0, canvas.height );
6573
+ ctx.scale( 1, -1 );
6574
+
6527
6575
  ctx.fillStyle = element.bgcolor;
6528
6576
  ctx.fillRect(0,0,canvas.width,canvas.height);
6529
-
6577
+
6530
6578
  ctx.strokeStyle = element.linecolor;
6531
6579
  ctx.beginPath();
6532
-
6580
+
6533
6581
  //draw line
6534
- var pos = convert([element.xrange[0],element.defaulty]);
6535
- ctx.moveTo( pos[0], pos[1] );
6536
- let values = [pos[0], pos[1]];
6537
-
6582
+ var pos = convert([ element.xrange[ 0 ],element.defaulty ]);
6583
+ ctx.moveTo( pos[ 0 ], pos[ 1 ] );
6584
+ let values = [pos[ 0 ], pos[ 1 ]];
6585
+
6538
6586
  for(var i in element.value) {
6539
6587
  var value = element.value[i];
6540
6588
  pos = convert(value);
6541
- values.push(pos[0]);
6542
- values.push(pos[1]);
6589
+ values.push(pos[ 0 ]);
6590
+ values.push(pos[ 1 ]);
6543
6591
  if(!element.smooth)
6544
- ctx.lineTo( pos[0], pos[1] );
6592
+ ctx.lineTo( pos[ 0 ], pos[ 1 ] );
6545
6593
  }
6546
-
6547
- pos = convert([element.xrange[1],element.defaulty]);
6548
- values.push(pos[0]);
6549
- values.push(pos[1]);
6550
- if(!element.smooth) {
6551
- ctx.lineTo( pos[0], pos[1] );
6594
+
6595
+ pos = convert([ element.xrange[ 1 ], element.defaulty ]);
6596
+ values.push(pos[ 0 ]);
6597
+ values.push(pos[ 1 ]);
6598
+ if( !element.smooth )
6599
+ {
6600
+ ctx.lineTo( pos[ 0 ], pos[ 1 ] );
6552
6601
  ctx.stroke();
6553
- } else {
6554
-
6555
- LX.UTILS.drawSpline(ctx, values, element.smooth);
6556
6602
  }
6557
-
6558
- //draw points
6559
- for(var i = 0; i < element.value.length; i += 1) {
6560
- var value = element.value[i];
6561
- pos = convert(value);
6562
- if(selected == i)
6603
+ else
6604
+ {
6605
+ LX.UTILS.drawSpline( ctx, values, element.smooth );
6606
+ }
6607
+
6608
+ // Draw points
6609
+ for( var i = 0; i < element.value.length; i += 1 ) {
6610
+ var value = element.value[ i ];
6611
+ pos = convert( value );
6612
+ if( selected == i )
6563
6613
  ctx.fillStyle = "white";
6564
6614
  else
6565
6615
  ctx.fillStyle = element.pointscolor;
6566
6616
  ctx.beginPath();
6567
- ctx.arc( pos[0], pos[1], selected == i ? 4 : 3, 0, Math.PI * 2);
6617
+ ctx.arc( pos[ 0 ], pos[ 1 ], selected == i ? 4 : 3, 0, Math.PI * 2);
6568
6618
  ctx.fill();
6569
6619
  }
6570
-
6620
+
6571
6621
  if(element.show_samples) {
6572
6622
  var samples = element.resample(element.show_samples);
6573
6623
  ctx.fillStyle = "#888";
6574
6624
  for(var i = 0; i < samples.length; i += 1)
6575
6625
  {
6576
- var value = [ i * ((element.xrange[1] - element.xrange[0]) / element.show_samples) + element.xrange[0], samples[i] ];
6626
+ var value = [ i * ((element.xrange[ 1 ] - element.xrange[ 0 ]) / element.show_samples) + element.xrange[ 0 ], samples[ i ] ];
6577
6627
  pos = convert(value);
6578
6628
  ctx.beginPath();
6579
- ctx.arc( pos[0], pos[1], 2, 0, Math.PI * 2);
6629
+ ctx.arc( pos[ 0 ], pos[ 1 ], 2, 0, Math.PI * 2);
6580
6630
  ctx.fill();
6581
6631
  }
6582
6632
  }
6583
6633
  }
6584
-
6585
- var last_mouse = [0,0];
6586
-
6587
- function onmousedown(evt) {
6588
- document.addEventListener("mousemove",onmousemove);
6589
- document.addEventListener("mouseup",onmouseup);
6590
-
6634
+
6635
+ var last_mouse = [ 0, 0 ];
6636
+
6637
+ function onmousedown( e ) {
6638
+ document.addEventListener( "mousemove", onmousemove );
6639
+ document.addEventListener( "mouseup", onmouseup );
6640
+
6591
6641
  var rect = canvas.getBoundingClientRect();
6592
- var mousex = evt.clientX - rect.left;
6593
- var mousey = evt.clientY - rect.top;
6594
-
6595
- selected = computeSelected(mousex,canvas.height-mousey);
6596
-
6597
- if(selected == -1 && element.allow_add_values) {
6598
- var v = unconvert([mousex,canvas.height-mousey]);
6599
- element.value.push(v);
6642
+ var mousex = e.clientX - rect.left;
6643
+ var mousey = e.clientY - rect.top;
6644
+
6645
+ selected = computeSelected( mousex, canvas.height - mousey );
6646
+
6647
+ if( e.button == LX.MOUSE_LEFT_CLICK && selected == -1 && element.allow_add_values ) {
6648
+ var v = unconvert([ mousex, canvas.height - mousey ]);
6649
+ element.value.push( v );
6600
6650
  sortValues();
6601
- selected = element.value.indexOf(v);
6651
+ selected = element.value.indexOf( v );
6602
6652
  }
6603
-
6604
- last_mouse = [mousex,mousey];
6653
+
6654
+ last_mouse = [ mousex, mousey ];
6605
6655
  element.redraw();
6606
- evt.preventDefault();
6607
- evt.stopPropagation();
6656
+ e.preventDefault();
6657
+ e.stopPropagation();
6608
6658
  }
6609
-
6610
- function onmousemove(evt) {
6659
+
6660
+ function onmousemove( e ) {
6661
+
6611
6662
  var rect = canvas.getBoundingClientRect();
6612
- var mousex = evt.clientX - rect.left;
6613
- var mousey = evt.clientY - rect.top;
6614
-
6615
- if(mousex < 0) mousex = 0;
6616
- else if(mousex > canvas.width) mousex = canvas.width;
6617
- if(mousey < 0) mousey = 0;
6618
- else if(mousey > canvas.height) mousey = canvas.height;
6619
-
6620
- //dragging to remove
6621
- if( selected != -1 && distance( [evt.clientX - rect.left, evt.clientY - rect.top], [mousex,mousey] ) > canvas.height * 0.5 )
6663
+ var mousex = e.clientX - rect.left;
6664
+ var mousey = e.clientY - rect.top;
6665
+
6666
+ if( mousex < 0 ) mousex = 0;
6667
+ else if( mousex > canvas.width ) mousex = canvas.width;
6668
+ if( mousey < 0 ) mousey = 0;
6669
+ else if( mousey > canvas.height ) mousey = canvas.height;
6670
+
6671
+ // Dragging to remove
6672
+ const currentMouseDiff = [ e.clientX - rect.left, e.clientY - rect.top ];
6673
+ if( selected != -1 && distance( currentMouseDiff, [ mousex, mousey ] ) > canvas.height * 0.5 )
6622
6674
  {
6623
- element.value.splice(selected,1);
6624
- onmouseup(evt);
6675
+ if( element.move_out == LX.CURVE_MOVEOUT_DELETE)
6676
+ {
6677
+ element.value.splice( selected, 1 );
6678
+ }
6679
+ else
6680
+ {
6681
+ const d = [ currentMouseDiff[ 0 ] - mousex, currentMouseDiff[ 1 ] - mousey ];
6682
+ let value = element.value[ selected ];
6683
+ value[ 0 ] = ( d[ 0 ] == 0.0 ) ? value[ 0 ] : ( d[ 0 ] < 0.0 ? element.xrange[ 0 ] : element.xrange[ 1 ] );
6684
+ value[ 1 ] = ( d[ 1 ] == 0.0 ) ? value[ 1 ] : ( d[ 1 ] < 0.0 ? element.yrange[ 1 ] : element.yrange[ 0 ] );
6685
+ }
6686
+
6687
+ onmouseup( e );
6625
6688
  return;
6626
6689
  }
6627
-
6628
- var dx = element.draggable_x ? last_mouse[0] - mousex : 0;
6629
- var dy = element.draggable_y ? last_mouse[1] - mousey : 0;
6630
- var delta = unconvert([-dx,dy]);
6631
- if(selected != -1) {
6632
- var minx = element.xrange[0];
6633
- var maxx = element.xrange[1];
6634
-
6635
- if(element.no_trespassing)
6690
+
6691
+ var dx = element.draggable_x ? last_mouse[ 0 ] - mousex : 0;
6692
+ var dy = element.draggable_y ? last_mouse[ 1 ] - mousey : 0;
6693
+ var delta = unconvert([ -dx, dy ]);
6694
+
6695
+ if( selected != -1 ) {
6696
+ var minx = element.xrange[ 0 ];
6697
+ var maxx = element.xrange[ 1 ];
6698
+
6699
+ if( element.no_overlap )
6636
6700
  {
6637
- if(selected > 0) minx = element.value[selected-1][0];
6638
- if(selected < (element.value.length-1) ) maxx = element.value[selected+1][0];
6701
+ if( selected > 0) minx = element.value[ selected - 1 ][ 0 ];
6702
+ if( selected < ( element.value.length - 1 ) ) maxx = element.value[ selected + 1 ][ 0 ];
6639
6703
  }
6640
-
6704
+
6641
6705
  var v = element.value[selected];
6642
- v[0] += delta[0];
6643
- v[1] += delta[1];
6644
- if(v[0] < minx) v[0] = minx;
6645
- else if(v[0] > maxx) v[0] = maxx;
6646
- if(v[1] < element.yrange[0]) v[1] = element.yrange[0];
6647
- else if(v[1] > element.yrange[1]) v[1] = element.yrange[1];
6706
+ v[ 0 ] += delta[ 0 ];
6707
+ v[ 1 ] += delta[ 1 ];
6708
+ if(v[ 0 ] < minx) v[ 0 ] = minx;
6709
+ else if(v[ 0 ] > maxx) v[ 0 ] = maxx;
6710
+ if(v[ 1 ] < element.yrange[ 0 ]) v[ 1 ] = element.yrange[ 0 ];
6711
+ else if(v[ 1 ] > element.yrange[ 1 ]) v[ 1 ] = element.yrange[ 1 ];
6648
6712
  }
6649
-
6713
+
6650
6714
  sortValues();
6651
6715
  element.redraw();
6652
- last_mouse[0] = mousex;
6653
- last_mouse[1] = mousey;
6654
- onchange(evt);
6655
-
6656
- evt.preventDefault();
6657
- evt.stopPropagation();
6716
+ last_mouse[ 0 ] = mousex;
6717
+ last_mouse[ 1 ] = mousey;
6718
+ onchange( e );
6719
+
6720
+ e.preventDefault();
6721
+ e.stopPropagation();
6658
6722
  }
6659
-
6660
- function onmouseup(evt) {
6723
+
6724
+ function onmouseup( e ) {
6661
6725
  selected = -1;
6662
6726
  element.redraw();
6663
6727
  document.removeEventListener("mousemove", onmousemove);
6664
6728
  document.removeEventListener("mouseup", onmouseup);
6665
- onchange(evt);
6666
- evt.preventDefault();
6667
- evt.stopPropagation();
6729
+ onchange(e);
6730
+ e.preventDefault();
6731
+ e.stopPropagation();
6668
6732
  }
6669
6733
 
6670
- function onchange(e) {
6671
- if(options.callback)
6672
- options.callback.call(element, element.value, e);
6734
+ function onchange( e ) {
6735
+ if( options.callback )
6736
+ options.callback.call( element, element.value, e );
6673
6737
  }
6674
-
6738
+
6675
6739
  function distance(a,b) { return Math.sqrt( Math.pow(b[0]-a[0],2) + Math.pow(b[1]-a[1],2) ); };
6676
-
6677
- function computeSelected(x,y) {
6678
-
6679
- var min_dist = 100000;
6680
- var max_dist = 8; //pixels
6740
+
6741
+ function computeSelected( x, y ) {
6742
+
6743
+ var minDistance = 100000;
6744
+ var maxDistance = 8; //pixels
6681
6745
  var selected = -1;
6682
- for(var i=0; i < element.value.length; i++)
6746
+ for( var i = 0; i < element.value.length; i++ )
6683
6747
  {
6684
- var value = element.value[i];
6685
- var pos = convert(value);
6686
- var dist = distance([x,y],pos);
6687
- if(dist < min_dist && dist < max_dist)
6748
+ var value = element.value[ i ];
6749
+ var pos = convert( value );
6750
+ var dist = distance( [ x,y ], pos );
6751
+ if( dist < minDistance && dist < maxDistance )
6688
6752
  {
6689
- min_dist = dist;
6753
+ minDistance = dist;
6690
6754
  selected = i;
6691
6755
  }
6692
6756
  }
6693
6757
  return selected;
6694
6758
  }
6695
-
6759
+
6696
6760
  function sortValues() {
6697
6761
  var v = null;
6698
- if(selected != -1)
6699
- v = element.value[selected];
6700
- element.value.sort(function(a,b) { return a[0] - b[0]; });
6701
- if(v)
6702
- selected = element.value.indexOf(v);
6762
+ if( selected != -1 )
6763
+ {
6764
+ v = element.value[ selected ];
6765
+ }
6766
+ element.value.sort(function( a,b ) { return a[ 0 ] - b[ 0 ]; });
6767
+ if( v )
6768
+ {
6769
+ selected = element.value.indexOf( v );
6770
+ }
6703
6771
  }
6704
6772
 
6705
6773
  element.redraw();
6706
6774
  return this;
6707
6775
  }
6708
-
6709
- redraw(options = {}) {
6710
- this.element.redraw(options);
6776
+
6777
+ redraw( options = {} ) {
6778
+ this.element.redraw( options );
6711
6779
  }
6712
6780
  }
6713
6781