cavalion-vcl 1.1.85 → 1.1.86

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/.md CHANGED
@@ -27,7 +27,9 @@
27
27
 
28
28
  # [prototypes](src/:/) `2022/04/17`
29
29
 
30
- > * [App](src/prototypes/:.js) - <= _#window is instantiated here (weirdly not in .desktop)_
30
+ >
31
+ * [cavalion-blocks](src/prototypes/:.js)
32
+ * [App](src/prototypes/:.js) - <= _#window is instantiated here (weirdly not in .desktop)_
31
33
  * [.console](src/prototypes/App:.js) << _hotkeys_ _probably deprecated_
32
34
  * [.desktop](src/prototypes/App:.js) << _#client [ui/forms/Portal<>]()_ _used at all?_
33
35
  * [.framework7](src/prototypes/App:.js) -[.scaffold](src/prototypes/App:.js)
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### `2025/04/03` - 1.1.86
2
+
3
+ * 20250403 fixes bug in sorting by column (List) improves selecting console nodes with keyboard
4
+ * 20250403 updates ^Escape handling to toggle console visibility updates glassy styles toasts out a message whenever the system clipboard is read or written
5
+ * 20250403 introduces Action.prototype.go() (alias for execute()) finetunes Component.prototype.getVar introduces Control.findByName(node) where node is a string (eg. ":focus")
6
+ * 20241119 develops support for searching through history updates Panel.prototype.setZoom to support setting transform-origin as well updates auto ListColumn header algoritm
7
+ * 20241119 updates Component.prototype.setVars to control whether to mixInR or mixIn fixes a bug in Control.prototype.updateChildren() updates glassy styles
8
+ * 20241111 updates glassy background to be more light sets ace.config for dynamic loading of themes and modes
9
+ * 20241108 adds prepend
10
+
1
11
  ### `2024/11/08` - 1.1.85
2
12
 
3
13
  * Service build in favor of cavalion-code
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-vcl",
3
- "version": "1.1.85",
3
+ "version": "1.1.86",
4
4
  "description": "Visual Component Library for vcl-comps",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Action.js CHANGED
@@ -62,6 +62,10 @@ define(function (require) {
62
62
  }
63
63
  }
64
64
  },
65
+ go: function() {
66
+ Action.prototype.go = Action.prototype.execute;
67
+ return this.go.apply(this, arguments);
68
+ },
65
69
  execute: function (evt, sender) {
66
70
  return this.onexecute(evt, sender);
67
71
  },
@@ -312,8 +316,7 @@ define(function (require) {
312
316
  /**
313
317
  * Sets the -hotkey-property.
314
318
  */
315
- value = value.replace(/Cmd\+/g, "Meta+").replace(/\+Cmd/, "+Meta");
316
-
319
+
317
320
  if (this._hotkey !== value) {
318
321
  this._hotkey = value;
319
322
 
@@ -324,11 +327,18 @@ define(function (require) {
324
327
  }
325
328
 
326
329
  var me = this;
327
- var arr = this._hotkey.split("|");
330
+ var arr;
331
+
332
+ if(typeof this._hotkey === "string") {
333
+ arr = this._hotkey.split("|");
334
+ } else if(this._hotkey instanceof Array) {
335
+ arr = this._hotkey;
336
+ }
328
337
 
329
338
  this._hotkeyListeners = [];
330
339
 
331
340
  arr.forEach(function(hotkey, type) {
341
+ hotkey = hotkey.replace(/Cmd\+/g, "Meta+").replace(/\+Cmd/, "+Meta");
332
342
  hotkey = String.trim(hotkey).split(":");
333
343
  type = hotkey.length === 1 ? "keydown" : hotkey.shift();
334
344
  hotkey = hotkey.shift();
@@ -478,6 +488,7 @@ define(function (require) {
478
488
  type: Type.BOOLEAN,
479
489
  set: Function
480
490
  },
491
+ "hotkeys": { set(value) { this.setHotkey(value); } }, // alias
481
492
  "hotkey": {
482
493
  type: Type.STRING,
483
494
  get: Function,
package/src/Component.js CHANGED
@@ -512,7 +512,7 @@ define(function (require) {
512
512
  if(arguments.length === 2) {
513
513
  return this.setVar("" + key, value);
514
514
  }
515
- if(arguments.length === 3) {
515
+ if(arguments.length >= 3) {
516
516
  return this.getVar.apply(this, arguments);
517
517
  }
518
518
  if(key instanceof Array) {
@@ -535,13 +535,12 @@ define(function (require) {
535
535
  }
536
536
  return this._vars;
537
537
  },
538
- setVars: function (value) {
538
+ setVars: function (value, mixInRecursive) {
539
539
  if(typeof value === "string") {
540
540
  value = js.str2obj(value);
541
541
  }
542
- if (this.isLoading()) {
543
- this._vars = mixInR(this._vars || {},
544
- value);
542
+ if (mixInRecursive || this.isLoading()) {
543
+ this._vars = mixInR(this._vars || {}, value);
545
544
  } else {
546
545
  this._vars = value;
547
546
  }
@@ -557,16 +556,18 @@ define(function (require) {
557
556
  hasVar: function (key) {
558
557
  return (this._vars && this._vars.hasOwnProperty(key)) || false;
559
558
  },
560
- getVar: function (namePath, fallback_to_owner, defaultValue) {
561
- if (this._vars !== null && arguments.length === 3) {
559
+ getVar: function (namePath, fallback_to_owner, defaultValue, callingComponent) {
560
+ if (this._vars !== null && arguments.length >= 3) {
562
561
  this._vars = this._vars || {};
563
562
  }
564
563
 
564
+ if(arguments.length < 4) callingComponent = this;
565
+
565
566
  var r = this._vars !== null ? js.get(namePath, this._vars) : undefined;
566
567
  if (r === undefined) {
567
568
  if(fallback_to_owner === true && this._owner !== null) {
568
- r = this._owner.getVar(namePath, true, defaultValue);
569
- } else if(arguments.length === 3) {
569
+ r = this._owner.getVar(namePath, true, defaultValue, callingComponent);
570
+ } else if(arguments.length >= 3) {
570
571
  if((r = defaultValue) !== undefined) {
571
572
  if(typeof defaultValue === "function") {
572
573
  r = defaultValue([this].concat(js.copy_args(arguments)));
package/src/Control.js CHANGED
@@ -1244,6 +1244,8 @@ define(function(require) {
1244
1244
  control.update();
1245
1245
  } else if(control._node !== null) {
1246
1246
  control._update();
1247
+ } else {
1248
+ control.getNode();
1247
1249
  }
1248
1250
  control.updateChildren(recursive, directly);
1249
1251
  }, this);
@@ -1949,6 +1951,11 @@ this._updateCalls = this._updateCalls || 0; this._updateCalls++;
1949
1951
  }, Object.create(root, { hashCode: { value: () => ";-)" } })),
1950
1952
 
1951
1953
  findByNode: function(node) {
1954
+ // as selector when string (usage findByNode(":focus"))
1955
+ if(typeof node === "string") {
1956
+ node = document.qs(node);
1957
+ }
1958
+
1952
1959
  while(node !== null && node[EventDispatcher.elementKey] === undefined) {
1953
1960
  node = node.parentNode || null; // IE
1954
1961
  }
@@ -7,57 +7,42 @@ const Control = require("vcl/Control");
7
7
 
8
8
  require("console/node/vcl/Component").initialize();
9
9
  override(require("vcl/Component").prototype, "print", function(inherited) {
10
- return function() {
11
- var console = this.down("vcl/ui/Console#console");
12
- if(console && !console.vars("skip-print")) {
13
- return console.print.apply(console, arguments);
14
- }
15
- return inherited.apply(this, arguments);
16
- };
17
- });
10
+ return function() {
11
+ var console = this.down("vcl/ui/Console#console");
12
+ if(console && !console.vars("skip-print")) {
13
+ return console.print.apply(console, arguments);
14
+ }
15
+ return inherited.apply(this, arguments);
16
+ };
17
+ });
18
18
 
19
19
  [(""), [
20
20
  ["vcl/Action", ("toggle-console"), {
21
- hotkey: `
22
- keyup:Ctrl+Escape|keydown:Ctrl+Escape|
23
- keyup:Ctrl+Shift+D|keydown:Ctrl+Shift+D|
24
- keyup:Alt+Shift+Z|keydown:Alt+Shift+Z|
25
- keyup:MetaCtrl+192`,
21
+ hotkey: "keyup:Ctrl+Escape|keydown_:Ctrl+Escape|keyup:Ctrl+Shift+D|keyup:MetaCtrl+192",
26
22
  onLoad() {
27
23
  // TODO #CVLN-20200822-2
28
- this.readStorage("visible", (visible) => eval(visible) && this.execute({}));
24
+ this.readStorage("visible", (visible) => JSON.parse(visible) && this.execute({}));
29
25
  },
30
26
  onExecute(evt) {
31
- var scope = this.scope();
32
- var focused;
33
-
34
- if (evt.type === "keydown") {
35
- focused = require("vcl/Control").focused;
36
- if (focused !== scope.console.getScope().console) {
37
- this.setVar("focused", focused);
38
- }
39
- } else {
40
- if (!scope.console.isVisible()) {
41
- scope.console.show();
42
- scope['align-enabled'].setState(true);
43
- } else {
44
- if(Control.focused === scope.console.getScope().console) {
45
- scope['align-enabled'].setState(false);
46
- scope.console.hide();
47
- focused = this.removeVar("focused");
48
- if (focused && focused !== scope.console) {
49
- this.setTimeout("focus", function() {
50
- // console.log("setFocus", focused);
51
- focused.setFocus();
52
- }, 250);
53
- }
54
- } else {
55
- scope.console.setFocus();
56
- }
57
- }
58
- }
27
+ var scope = this.scope(), console = scope.console.qs("#console");
28
+ var focused = Control.findByNode(document.qs(":focus"));
29
+ var visible = scope.console.getVisible();
59
30
 
60
- this.writeStorage("visible", scope.console.isVisible());
31
+ if(focused !== console) {
32
+ this.vars("focused", focused);
33
+ }
34
+
35
+ if(visible && focused !== console) {
36
+ console.setFocus();
37
+ } else if(!scope.console.toggle("visible")) {
38
+ if((focused = this.vars("focused"))) {
39
+ focused.setFocus();
40
+ }
41
+ }
42
+
43
+ visible = scope.console.isVisible();
44
+ scope['align-enabled'].setState(visible);
45
+ this.writeStorage("visible", visible);
61
46
 
62
47
  return this.inherited(arguments);
63
48
  }
@@ -125,6 +110,17 @@ keyup:MetaCtrl+192`,
125
110
  }
126
111
  }
127
112
  }],
113
+ ["vcl/Action", ("open-alphaview"), {
114
+ hotkey: "MetaCtrl+F3",
115
+ on() {
116
+ let c = Control.findByNode(document.qs(":focus"));
117
+ if(c && (c = c instanceof (req("vcl/ui/Console")) ? c : c.udr("vcl/ui/Console"))) {
118
+ H("devtools/Alphaview.csv", { console: c });
119
+ } else {
120
+ H("devtools/Alphaview.csv");
121
+ }
122
+ }
123
+ }],
128
124
 
129
125
  [["ui/forms/util/Console"], "console", {
130
126
  align: "bottom",
@@ -4,16 +4,17 @@ var CssRules = require("vcl/CssRules");
4
4
 
5
5
  var css = {
6
6
  '#close-x': {
7
- '': "transition: opacity 1s; opacity: 0.1; position:absolute;top:0;right:0;color:silver;padding:4px 8px;font-size:14pt;z-index:999999999999;",
8
- '&:hover': "color:black;cursor:pointer;opacity: 1;"
7
+ '': "transition: opacity 1s; opacity: 0.1; position:absolute;top:0;right:0;color:silver;padding:4px 8px;font-size:14pt;z-index:999999999999; border: 1px solid transparent; border-radius:3px;",
8
+ '&:hover': "color:black;font-weight:bold;cursor:pointer;opacity: 1;backdrop-filter: blur(10px); background-color: rgba(255,255,255,0.5); border: 1px solid silver;",
9
+ '&:active': "background-color: rgba(56,127,217,0.025);"
9
10
  },
10
11
  ".with-shadow": "box-shadow:rgba(0, 0, 0, 0.4) 0px 1px 2px 0px;",
11
12
  ".with-text-shadow": "text-shadow: rgb(255 255 255) 0px 0px 12px, #00000094 0px 0px 5px;",
12
13
  ".transparent": "background-color:transparent;",
13
14
  ".glassy-overlay": {
14
15
  "": "pointer-events: none; color:rgba(5,5,5,0.95);",
15
- ".glassy": "background-color: rgba(155, 155, 155, 0.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);",
16
- ".loading": "background: rgba(155, 155, 155, 0.35) url(/shared/vcl/images/loading.gif) 50% 50% no-repeat;",
16
+ ".glassy": "background-color: rgba(215, 215, 215, 0.35); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);",
17
+ ".loading": "background: url(/shared/vcl/images/loading.gif) 50% 50% no-repeat;",
17
18
  ".rounded": "padding: 4px; border-radius: 5px;",
18
19
  ".animate-width-height": "transition: width 250ms ease-in, height 250ms ease-in;",
19
20
  ">.glassy:not(.no-margin)": "margin: 32px;",
@@ -47,7 +48,7 @@ var css = {
47
48
  '&:hover': {
48
49
  'box-shadow': "0 0 10px 5px rgba(0,0,0,.2)",
49
50
  'cursor': "move",
50
- '.client': "border-color: rgba(56,127,217,0.025); background-color:rgba(155, 155, 155, 0.2);"
51
+ '.client': "border-color: rgba(56,127,217,0.025); background-color:rgba(215, 215, 215, 0.2);"
51
52
  },
52
53
  // '&.square': {
53
54
  // 'min-width': 175 + "px",
@@ -73,6 +74,8 @@ var css = {
73
74
  // "&.left": {
74
75
  // '': "left: 5%; transform-origin: top left;",
75
76
  // },
77
+
78
+ '#menubar': "border-bottom: none;",
76
79
 
77
80
  '&.parent-topleft': "transform-origin: 0% 0%;",
78
81
  '&.parent-topcenter': "transform-origin: 50% 0%;",
@@ -92,7 +95,7 @@ var css = {
92
95
  '.{List}': "border-radius:5px;",
93
96
  '.{ListHeader}': {
94
97
  '': "background-color:transparent;transition:background-color 1s ease 0s;",
95
- '&.scrolled': "background-color:rgba(255,255,255,0.75);",
98
+ '&.scrolled': "background-color:rgba(255,255,255,0.75);backdrop-filter:blur(10px);",
96
99
  '>div': "background-image:none;border:none;font-weight:bold;"
97
100
  },
98
101
  '.{Input}': {
@@ -124,11 +127,12 @@ var css = {
124
127
  'border': "7px solid rgba(0,0,0,0)",
125
128
  // 'overflow': "hidden",
126
129
  'height': "100%",
127
- 'transition': "border-color 0.45s ease 0s, background-color 0.45s ease 0s",
130
+ 'transition': "border-color 0.45s ease 0s, background-color 0.45s ease 0s, border-width: 0.45s ease 0s",
128
131
  '&:hover': {
132
+ 'border-width': "10px"
129
133
  }
130
134
  },
131
- '.seperator.seperator.seperator': "border-top: 1px solid rgba(155, 155, 155, 0.55);",
135
+ '.seperator.seperator.seperator': "border-top: 1px solid rgba(215, 215, 215, 0.55);",
132
136
 
133
137
  '&.phone': {
134
138
  '': "width: 389px; border-radius:20px; box-shadow: 0 0 20px 10px rgba(0,0,0,.2);",
@@ -142,7 +146,7 @@ var css = {
142
146
  '.glassy': {
143
147
  '#bar': "background-color: rgba(240, 240, 240, 0.35);",
144
148
  '.{Tabs}': "background-color: rgba(240, 240, 240, 0.35);",
145
- '.{ListRow}:not(.selected).odd': "background-color: rgba(240, 240, 240, 0.7777);"
149
+ '.{ListRow}:not(.selected).odd': "background-color: rgba(240, 240, 240, 0.55);"
146
150
  }
147
151
  };
148
152
 
@@ -1,6 +1,7 @@
1
1
  "use vcl/ui/Popup, vcl/ui/List";
2
2
 
3
3
  ["vcl/Application", { }, [
4
+
4
5
  ["vcl/ui/Panel", ("window"), {
5
6
  align: "client", classes: "animated",
6
7
  onLoad() {
@@ -11,5 +12,11 @@
11
12
  },
12
13
  req("vcl/ui/Popup").prototype._parent = this;
13
14
  }
15
+ }],
16
+ ["vcl/Action", ("reload-app"), {
17
+ hotkey: "Shift+MetaCtrl+R|Cmd+Alt+R",
18
+ on(evt) { evt.preventDefault(); document.location.reload(); }
14
19
  }]
20
+
21
+
15
22
  ]];
@@ -1,4 +1,33 @@
1
+ "use util/Clipboard";
2
+
3
+ const Clipboard = req("util/Clipboard");
4
+
1
5
  ["", {
6
+ onLoad() {
7
+
8
+ // Override toast method to be more convenient (TODO refactor to vcl/Application)
9
+ this.toast = (c = "Content not provided", ms = 1500, opts = {}) => {
10
+ if(typeof c === "object") {
11
+ return this.constructor.prototype.toast.apply(this, [c]);
12
+ }
13
+ return this.constructor.prototype.toast.apply(this, [
14
+ js.mi({content: c, ms: ms, classes: "fade glassy"}, opts)
15
+ ]);
16
+ };
17
+
18
+ Clipboard.onPaste.addListener(e => {
19
+ this.print("onPaste", e);
20
+ this.toast(js.sf("Pasted %d bytes...", e.length ))});
21
+ Clipboard.onCopy.addListener(e => {
22
+ this.print("onCopy", e);
23
+ if(typeof e === "string" && e.length > 150) {
24
+ this.toast(js.sf("Copied %d bytes", e.length ));
25
+ } else {
26
+ this.toast(js.sf("Copied <b>%H<b>", e));
27
+ }});
28
+
29
+ return this.inherited(arguments);
30
+ },
2
31
  onToast: function(options) {
3
32
 
4
33
  /*-
@@ -67,5 +67,11 @@ var FormContainer = require("vcl/ui/FormContainer");
67
67
  ["vcl/ui/FormContainer", "client", {
68
68
  formUri: "./ui/forms/Portal<>"
69
69
  }]
70
- ]]
70
+ ]],
71
+
72
+ // [("vcl/Action"), "reload-app", {
73
+ // hotkey: "Shift+MetaCtrl+R|Cmd+Alt+R",
74
+ // on(evt) { evt.preventDefault(); document.location.reload(); }
75
+ // }]
76
+
71
77
  ]];
@@ -18,15 +18,15 @@ const css = {
18
18
  };
19
19
 
20
20
  [["./App.console.toast.glassy<>"], {
21
- vars: { canunload: true }
21
+ vars: { canunload: false }
22
22
  }, [
23
23
 
24
- [("vcl/Action"), "reload-app", {
25
- hotkey: "Shift+MetaCtrl+R|Cmd+Alt+R",
26
- on() {
27
- document.location.reload();
28
- }
29
- }],
24
+ // [("vcl/Action"), "reload-app", {
25
+ // hotkey: "Shift+MetaCtrl+R|Cmd+Alt+R",
26
+ // on() {
27
+ // document.location.reload();
28
+ // }
29
+ // }],
30
30
 
31
31
  [("#window"), { css: css }]
32
32
  ]];
@@ -76,9 +76,9 @@ var Handlers = {
76
76
  return alert("app-js not set");
77
77
  }
78
78
 
79
- if(confirm("Make?")) {
80
- Handlers.make_app.apply(this, [evt]);
81
- }
79
+ // if(confirm("Make?")) {
80
+ // Handlers.make_app.apply(this, [evt]);
81
+ // }
82
82
 
83
83
  var text = this.ud("#extra-components").getValue();
84
84
  RM.get(uri).then(res => {
@@ -19,6 +19,7 @@ const HOTKEY_ALWAYS_ENABLED = {
19
19
  return false;
20
20
  }
21
21
  };
22
+
22
23
  const getAce = () => {
23
24
  return Control.focused instanceof Ace ?
24
25
  Control.focused :
package/src/ui/Ace.js CHANGED
@@ -53,7 +53,9 @@ function(require, Ace, ace, Panel, Type, Text) {
53
53
  const markDeletionInGutter = (editor, lineNumber) => {
54
54
  editor.session.addGutterDecoration(lineNumber, "line-deleted");
55
55
  };
56
-
56
+
57
+ ace.config.set("basePath", window.require.toUrl("ace").split("?")[0]);
58
+
57
59
  return (Ace = Ace(require, {
58
60
  inherits: Panel,
59
61
  prototype: {
@@ -71,7 +73,7 @@ function(require, Ace, ace, Panel, Type, Text) {
71
73
  _content: "<div></div>",
72
74
 
73
75
  _cursorPos: null,
74
-
76
+
75
77
  onnodecreated: function() {
76
78
  /**
77
79
  * @overrides ../Control.prototype.onnodecreated
@@ -82,8 +84,31 @@ function(require, Ace, ace, Panel, Type, Text) {
82
84
  this._editor.$blockScrolling = Infinity;
83
85
  this._editor.setOption("useSoftTabs", false);
84
86
  this._editor.on("change", (e) => this.dispatch("change", e));
85
-
87
+
86
88
  initCommands(this._editor);
89
+
90
+ if(this.hasOwnProperty("_value")) {
91
+ this._editor.setValue(this._value);
92
+ delete this._value;
93
+ }
94
+
95
+ if(this.hasOwnProperty("_mode")) {
96
+ this.setMode(this._mode);
97
+ }
98
+
99
+ // this.setTimeout(() => {
100
+
101
+ // const app = this.app();
102
+ // if(app && app.qsa("#ace").length > 5) {
103
+ // if(this.isVisible() === false) {
104
+ // this.print(this, "autoremove - isVisible: " + this.isVisible());
105
+ // this._value = this.getValue();
106
+ // this.destroyNode();
107
+ // delete this._editor;
108
+ // }
109
+ // }
110
+
111
+ // }, 200);
87
112
 
88
113
  return this.inherited(arguments);
89
114
  },
@@ -113,27 +138,42 @@ function(require, Ace, ace, Panel, Type, Text) {
113
138
  *
114
139
  * @returns
115
140
  */
141
+
142
+ // this.print(this, "getEditor: " + this._editor);
143
+
116
144
  this.nodeNeeded();
117
145
  return this._editor;
118
146
  },
119
147
  getValue: function() {
148
+ if(this.hasOwnProperty("_value")) return this._value;
149
+
120
150
  this.nodeNeeded();
121
151
  return this._editor.session.getValue();
122
152
  },
123
153
  setValue: function(value) {
124
- this.nodeNeeded();
125
154
  if(value instanceof Array && value.every(s => typeof s === "string")) {
126
155
  value = value.join("\n");
127
156
  }
128
- return this._editor.setValue(typeof value === "string" ? value : JSON.stringify(value));
157
+
158
+ value = typeof value === "string" ? value : JSON.stringify(value);
159
+
160
+ if(!this._node) {
161
+ return (this._value = value);
162
+ }
163
+
164
+ // this.nodeNeeded();
165
+ return this._editor.setValue(value);
129
166
  },
130
167
  getLines: function(seperator) {
131
168
  return this.getValue().split(seperator || "\n");
132
169
  },
133
170
  setMode: function (mode) {
134
- this.getEditor().session.setMode("ace/mode/" + mode);
171
+ if(!this._editor) {
172
+ return this._mode = mode;
173
+ }
174
+ this._editor.session.setMode("ace/mode/" + mode);
135
175
  },
136
-
176
+
137
177
  append: function(content) {
138
178
  const editor = this.getEditor();
139
179
  const session = editor.getSession(); // Get the current session
@@ -141,6 +181,12 @@ function(require, Ace, ace, Panel, Type, Text) {
141
181
 
142
182
  session.insert({ row: lastRow, column: 0 }, '\n' + content); // Insert content at the bottom
143
183
  },
184
+ prepend: function(content) {
185
+ const editor = this.getEditor();
186
+ const session = editor.getSession(); // Get the current session
187
+
188
+ session.insert({ row: 0, column: 0 }, '\n' + content); // Insert content at the bottom
189
+ },
144
190
 
145
191
  getSelection: function() {
146
192
  const editor = this.getEditor();
package/src/ui/Console.js CHANGED
@@ -1,6 +1,7 @@
1
1
  define(function(require) {
2
2
 
3
3
  var Class = require("js/Class");
4
+ var Browser = require("util/Browser");
4
5
  var Deferred = require("js/Deferred");
5
6
  var js = require("js");
6
7
  var Printer = require("console/Printer");
@@ -17,6 +18,17 @@ define(function(require) {
17
18
  };
18
19
 
19
20
  var MAX_HISTORY_LENGTH = 1024 * 50;
21
+
22
+ const initialize_Q = (root, value) => {
23
+ const v = value || root._nodes.input.value;
24
+ root._Q = root._history.filter((s, i, a) => (!i || a[i - 1] !== s) && (!v || s.startsWith(v)));
25
+ root._Q = root._Q.concat(root._history.filter(s => s.includes(v))).reverse().filter(Array.fn.unique).reverse();
26
+
27
+ if(root._Q.length === 0) {
28
+ root._Q = [v];//
29
+ }
30
+ root._Q.index = root._Q.length;
31
+ };
20
32
 
21
33
  var Console = {
22
34
  inherits: Panel,
@@ -155,30 +167,41 @@ define(function(require) {
155
167
 
156
168
  this._nodes.console = this.getChildNode(0);
157
169
  this._nodes.input = this.getChildNode(1, 0);
158
-
170
+
159
171
  this._printer = new Printer(this._nodes.console);
160
172
  },
161
- /*
162
173
  onmousedown: function(evt) {
163
- if(evt.target === this._node) {
164
- this.addClass("highlight-click");
165
- }
174
+ // if(evt.target === this._node) {
175
+ // this.addClass("highlight-click");
176
+ // }
166
177
  },
167
- onmouseup: function() {
168
- if(this.hasClass("highlight-click")) {
169
- this.removeClass("highlight-click");
170
- }
178
+ onmouseup: function(evt) {
179
+ // if(this.hasClass("highlight-click")) {
180
+ // this.removeClass("highlight-click");
181
+ // }
171
182
  },
172
- */
183
+
173
184
  onclick: function(evt) {
174
185
  /** @overrides ../../Control.prototype.onclick */
175
- this.setTimeout("focus", function() {
176
- //if(evt.target === this._node) {
177
- this.storeScroll();
178
- this._nodes.input.focus();
179
- this.restoreScroll();
180
- //}
181
- }.bind(this), 200);
186
+
187
+ if(this._ignoreClick) return console.log("blocked-click");
188
+
189
+ this.setTimeout("focus", () => requestAnimationFrame(() => {
190
+ this.storeScroll();
191
+
192
+ if(Browser.chrome) {
193
+ this._ignoreClick = true;
194
+ this._nodes.input.focus();
195
+ this._node.click(); // Force Chrome to acknowledge a user event
196
+ delete this._ignoreClick;
197
+ }
198
+ this._nodes.input.focus();
199
+
200
+ Browser.chrome && this.restoreScroll();
201
+ Browser.safari && this.nextTick(() => this.restoreScroll());
202
+
203
+ // Browser.chrome && this.nextTick(() => this._nodes.input.focus());
204
+ }), 100);
182
205
 
183
206
  var node = evt.target;
184
207
  if(evt.metactrlKey && HE.hasClass(node, "key")) {
@@ -220,9 +243,9 @@ define(function(require) {
220
243
  onkeypress: function(evt) {
221
244
  /** @overrides ../../Control.prototype.onkeydown */
222
245
  var r = this.inherited(arguments);
223
- if(r !== false) {
246
+ if(r !== false) { this.nextTick(() => { // let key be handled
247
+ const text = this._nodes.input.value;
224
248
  if(evt.keyCode === 13) {
225
- var text = this._nodes.input.value;
226
249
  if(text !== "") {
227
250
  var value;
228
251
 
@@ -236,14 +259,23 @@ define(function(require) {
236
259
  }
237
260
  this.print(text, value);
238
261
  }
262
+ } else if(text.startsWith("// ") && text.endsWith(" //")) {
263
+ if(!this._Q || this._Q.text !== text) {
264
+ initialize_Q(this, text.substring(0, text.length - 4));
265
+
266
+ this._Q.index--;
267
+ this._nodes.input.value = this._Q[this._Q.index];
268
+ this._Q.text = text;
269
+ }
270
+
239
271
  }
240
- }
272
+ });}
241
273
  //this.print("press", evt.keyCode);
242
274
  return r;
243
275
  },
244
276
  onkeydown: function(evt) {
245
277
  /** @overrides ../../Control.prototype.onkeyup */
246
- var r = this.inherited(arguments), clearQ = !!this._Q;
278
+ var r = this.inherited(arguments), clearQ = !!this._Q, nodes;
247
279
 
248
280
  if(evt.ctrlKey === true) {
249
281
  if(evt.altKey === true && evt.keyCode === 13) {
@@ -257,12 +289,12 @@ define(function(require) {
257
289
  if(evt.shiftKey === true) {
258
290
  console.log(sel);
259
291
  }
260
- this.print(sel);
261
- } else if(evt.keyCode === 76) {
292
+ this.print(js.sf("c$%d", Math.random() * 10), sel);
293
+ } else if(evt.keyCode === 76) { // control+L
262
294
  if(evt.shiftKey === true) {
263
295
 
264
296
  } else {
265
- var nodes = this._nodes.console.qsa(".selected.node").map(_ => {
297
+ nodes = this._nodes.console.qsa(".selected.node").map(_ => {
266
298
  _.parentNode.removeChild(_);
267
299
  return _;
268
300
  });
@@ -270,21 +302,40 @@ define(function(require) {
270
302
  evt.preventDefault();
271
303
  nodes.map(_ => this._nodes.console.appendChild(_));
272
304
  }
273
- } else if(evt.keyCode === 75) {
305
+ } else if(evt.keyCode === 75) { // control+K
274
306
  this._nodes.console.qsa(".selected.node").map(_ => HE.removeClass(_, "selected"));
307
+ } else if(evt.keyCode === 73) { // control+I {
308
+ nodes = this._nodes.console.qsa(".selected.node");
309
+ if(nodes.length >= 1) {
310
+ if(nodes[0].previousSibling) {
311
+ nodes[0].previousSibling.classList.add("selected");
312
+ nodes[0].previousSibling.scrollIntoView({ behavior: "auto", block: "center", inline: "nearest" });
313
+ if(evt.shiftKey !== true) {
314
+ nodes[0].classList.remove("selected");
315
+ }
316
+ }
317
+ } else {
318
+ nodes = this._nodes.console.qsa(":scope > .node").reverse()
319
+ nodes[0].classList.add("selected");
320
+ nodes[0].scrollIntoView({ behavior: "auto", block: "center", inline: "nearest" });
321
+ }
322
+ } else if(evt.keyCode === 74) { // control+J {
323
+ nodes = this._nodes.console.qsa(".selected.node").reverse();
324
+ if(nodes.length >= 1) {
325
+ if(nodes[0].nextSibling) {
326
+ nodes[0].nextSibling.classList.add("selected");
327
+ nodes[0].scrollIntoView({ behavior: "auto", block: "center", inline: "nearest" });
328
+ if(evt.shiftKey !== true) {
329
+ nodes[0].classList.remove("selected");
330
+ }
331
+ }
332
+ }
275
333
  }
276
334
  } else if(evt.keyCode === 38 || evt.keyCode === 40) {
277
335
  clearQ = false;
278
- if(!this._Q) {
279
- const v = this._nodes.input.value;
280
-
281
- this._Q = this._history.filter((s, i, a) => (!i || a[i - 1] !== s) && (!v || s.startsWith(v)));
282
- this._Q = this._Q.concat(this._history.filter(s => s.includes(v))).reverse().filter(Array.fn.unique).reverse();
283
336
 
284
- if(this._Q.length === 0) {
285
- this._Q = [v];
286
- }
287
- this._Q.index = this._Q.length;
337
+ if(!this._Q) {
338
+ initialize_Q(this);
288
339
  }
289
340
 
290
341
  if(evt.keyCode === 38) {
@@ -435,13 +486,13 @@ define(function(require) {
435
486
  },
436
487
  getValues: function(selected) {
437
488
  return this.getNode("console")
438
- .qsa(".node" + selected ? ".selected" : "")
489
+ .qsa((selected ? "" : ":scope > ") + " .node" + (selected ? ".selected" : ""))
439
490
  .map(n => n._line)
440
491
  .filter(Boolean).map(l => l._value);
441
492
  },
442
493
  getKeys: function(selected) {
443
494
  return this.getNode("console")
444
- .qsa(".node" + selected ? ".selected" : "")
495
+ .qsa((selected ? "" : ":scope > ") + " .node" + (selected ? ".selected" : ""))
445
496
  .map(n => n._line)
446
497
  .filter(Boolean).map(l => l._key);
447
498
  }
package/src/ui/List.js CHANGED
@@ -37,9 +37,9 @@ define(function(require) {
37
37
  constructor: function() {
38
38
  this._columns = [];
39
39
 
40
- this._header = new ListHeader();
41
- this._footer = new ListFooter();
42
- this._body = new ListBody();
40
+ this._header = new ListHeader(this);
41
+ this._footer = new ListFooter(this);
42
+ this._body = new ListBody(this);
43
43
 
44
44
  this._header.setParent(this);
45
45
  this._body.setParent(this);
@@ -715,10 +715,10 @@ workaroundColumnAlignment(this);
715
715
  if(column === null) {
716
716
  column = this.addColumn();
717
717
  column.setAttribute(attrs[i]);
718
- var s = attrs[i].split(":").pop().split(".");
718
+ var s = attrs[i]/*.split(":").pop()*/.split(".");
719
719
  if(s.length > 1) {
720
720
  if(shuffle) {
721
- s = [s.pop()].concat(s).join(".");
721
+ s = [s.pop()].concat(s.join(".")).join(" ");
722
722
  } else {
723
723
  s = s.join(".");
724
724
  }
@@ -914,15 +914,19 @@ workaroundColumnAlignment(this);
914
914
  var row1 = this._source._array.indexOf(i1);
915
915
  var row2 = this._source._array.indexOf(i2);
916
916
 
917
- if(sv) {
918
- i1 = this._source.getAttributeValue(column._attribute, row1, true);
919
- i2 = this._source.getAttributeValue(column._attribute, row2, true);
917
+ // if(sv) {
918
+ // i1 = this._source.getAttributeValue(column._attribute, row1, true);
919
+ // i2 = this._source.getAttributeValue(column._attribute, row2, true);
920
920
 
921
- return dir * sv(i1, i2);
922
- }
921
+ // return dir * sv(i1, i2);
922
+ // }
923
923
 
924
924
  i1 = this.valueByColumnAndRow(column, row1);
925
925
  i2 = this.valueByColumnAndRow(column, row2);
926
+
927
+ if(numeric === undefined) {
928
+ numeric = (!isNaN(parseFloat(i1)) || !isNaN(parseFloat(i2)));
929
+ }
926
930
 
927
931
  if(i1 === i2) return 0;
928
932
 
package/src/ui/Panel.js CHANGED
@@ -47,15 +47,9 @@ define(function (require) {
47
47
  inherits: Container,
48
48
  prototype: {
49
49
  "@css": {
50
- "position": "absolute",
51
- "overflow": "auto",
52
- "cursor": "default",
53
- "&:focus": {
54
- outline: "none"
55
- },
56
- "&.animated": {
57
- "transition": "transform 0.45s"
58
- }
50
+ '': "position: absolute; overflow: auto; cursor: default;",
51
+ '&:focus': "outline: none;",
52
+ '&.animated': "transition: transform 0.45s;"// transform-origin: 0 0;"
59
53
  },
60
54
 
61
55
  /** @overrides ../Control */
@@ -372,7 +366,8 @@ define(function (require) {
372
366
  style['transform-origin'] = this._zoomOrigin;
373
367
  } else {
374
368
  style.transform = "";
375
- style['transform-origin'] = "";
369
+ setTimeout(() => style['transform-origin'] = "", 450);
370
+ // something is not right here, 0 0 is already the default, right?
376
371
  }
377
372
  },
378
373
 
@@ -865,7 +860,11 @@ define(function (require) {
865
860
  return this.update(function() { this.setZoom(f, o); }.bind(this));
866
861
  }
867
862
  this._zoom = f;
868
- this._zoomOrigin = o;
863
+ if(o === undefined) {
864
+ delete this._zoomOrigin;
865
+ } else {
866
+ this._zoomOrigin = o;
867
+ }
869
868
  this.nodeNeeded();
870
869
  this.renderZoom();
871
870
  this.setTimeout("align", 450);