targetj 1.0.59 → 1.0.61
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/License +22 -0
- package/README.md +159 -13
- package/package.json +1 -1
- package/src/App.js +15 -15
- package/src/Dim.js +2 -2
- package/src/EventListener.js +43 -39
- package/src/LocationManager.js +3 -3
- package/src/PageManager.js +8 -8
- package/src/SearchUtil.js +3 -3
- package/src/TModelManager.js +1 -1
- package/src/TargetManager.js +1 -1
package/License
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ahmad Wasfi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
CHANGED
|
@@ -1,21 +1,69 @@
|
|
|
1
|
-
# TargetJ
|
|
1
|
+
# TargetJ: JavaScript UI framework
|
|
2
2
|
|
|
3
|
-
Welcome to TargetJ, a powerful JavaScript framework designed to
|
|
3
|
+
Welcome to TargetJ, a powerful JavaScript UI framework designed to simplify development and animation. (https://targetj.io)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
TargetJ distinguishes itself by introducing a novel concept known as 'targets', which forms its core. Targets are used as the main building blocks of components instead of direct variables and methods. Each component in TargetJ is a set of targets. Targets are employed across all aspects of the program. They are used in animation, controlling program flow, loading data from external APIs, handling user events, and more.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **No HTML nesting**: HTML nesting is seldom required in TargetJ. If it is required, nesting is done at runtime. Elements can be dynamically detached and incorporated into other elements, facilitating the easy reuse of components regardless of their location or attachment. For instance, the same login button can be attached to the toolbar or placed in the middle of the page.
|
|
9
|
-
- **Next-level animation**: TargetJ was built from scratch to be able to orchestrate intricate animations involving numerous objects with complex sequences. Users can program objects to move at varying speeds, pause at certain intervals, and repeat sequences based on various conditions. It allows the creation of captivating animations resulting in rich and engaging user experiences.
|
|
10
|
-
- **Handle 100,000s of items**: TargetJ efficiently manages large collections of objects on a single page. This is done by its data structure and optimization algorithm. It divides a long list into a tree structure, monitoring only the keeps track of the branches that are visible to the user at any given time. In our examples page, infinite scrolling and infinite zooming demonstrate how it handles dynamically expanding lists of objects.
|
|
11
|
-
- **Control the flow of execution with time**: TargetJ simplifies the execution of various program segments at specific times, making it easy to sequence or parallelize numerous actions. This functionality supports the development of applications that are efficient and responsive, capable of managing complex operations. It enhances user experiences and optimizes resource utilization.
|
|
12
|
-
- **Handle events effortlessly**: In TargetJ, events are triggered synchronously and are designed so that any component can detect when an event occurs. Event handling can be simply implemented as conditions in the enabling functions of \'targets.\' This ensures that managing events is both simple and effective.
|
|
13
|
-
- **Easy to learn**: TargetJ simplifies development by employing the concept of \'targets\' across all aspects of the program. These targets are used in animations,ncontrolling program flow, integrating APIs, and more. This unified approach means that one core concept is applied throughout the program, making TargetJ easy to learn.
|
|
7
|
+
## Brief overview of how it operates
|
|
14
8
|
|
|
9
|
+
Each target in TargetJ essentially has two variables: target and actual. When the target value does not equal the actual value, TargetJ will update the actual value iteratively until it matches the target value. This iteration is determined by two additional variables: steps and step interval. Steps dictate the number of iterations, and the step interval specifies the duration in milliseconds that the system waits before executing the next iteration.
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
To animate a variable, create a target after its name. The variable can be of any type: boolean, number, string, object, or array.
|
|
12
|
+
|
|
13
|
+
## Target life cycle and methods
|
|
14
|
+
|
|
15
|
+
By default, a target in TargetJ has a simple life cycle: it executes only once. However, targets come with a number of methods that control execution and extend their behavior.
|
|
16
|
+
|
|
17
|
+
1. **onEnabled**
|
|
18
|
+
Determines whether the target is eligible for execution. Targets remain inactive until enabled. This method ensures that targets are executed only under suitable conditions and are commonly used to establish dependencies between targets, ensuring they execute at precisely the right moment.
|
|
19
|
+
|
|
20
|
+
2. **loop**
|
|
21
|
+
Controls the repetition of target execution. If loop() returns true, the target will stay active and continue to execute indefinitely. It will become inactive and stop executing when it returns false.
|
|
22
|
+
|
|
23
|
+
3. **onValueChange**
|
|
24
|
+
Monitors changes in the value returned by the main value() for the target. It is triggered whenever there is a change in the value returned by value(). This could be used, for example, to wait for asynchronous responses.
|
|
25
|
+
|
|
26
|
+
4. **onStepsEnd**
|
|
27
|
+
Executes actions after all increments are completed. This method is invoked only after the final step is executed, assuming the target has a defined steps value. It's useful for cleanup or finalization tasks after a sequence of steps.
|
|
17
28
|
|
|
18
29
|
|
|
30
|
+
## Special target names used by TargetJ
|
|
31
|
+
|
|
32
|
+
The following are special target names to impact the UI or control properties of TargetJ objects (called TModel):
|
|
33
|
+
|
|
34
|
+
1. x, y, width, height: Set the location and dimensions of the object.
|
|
35
|
+
2. opacity, scale, rotate: Set the opacity, scale, and rotation of the object.
|
|
36
|
+
3. zIndex: Sets the z-order of the object.
|
|
37
|
+
4. html: Sets the content of the object. By default, it will be interpreted as text.
|
|
38
|
+
5. style: An object that sets the style of the object.
|
|
39
|
+
6. css: A string that sets the CSS of the object.
|
|
40
|
+
7. scrollLeft and scrollTop: Used for scrolling the object.
|
|
41
|
+
8. leftMargin, rightMargin, topMargin, bottomMargin: Set the margins between objects.
|
|
42
|
+
9. children: Sets the TModel children of the object.
|
|
43
|
+
10. domHolder and domParent: Set to control the HTML element containment and how HTML is nested.
|
|
44
|
+
11. isVisible: An optional boolean flag to explicitly control the visibility of the object instead of leaving it to TargetJ to calculate.
|
|
45
|
+
12. canHaveDom: A boolean flag that sets if the object can have a DOM element in the page.
|
|
46
|
+
13. canHandleEvents: Sets what events the object can handle
|
|
47
|
+
14. widthFromDom and heightFromDom: Boolean flags that control if the width and height should be calculated from the DOM element.
|
|
48
|
+
15. textOnly: A boolean flag that sets the type of content to be text or HTML.
|
|
49
|
+
16. canBeBracketed: A boolean flag that controls if the object will be optimized and included in the TargetJ task process only when visible.
|
|
50
|
+
17. isInFlow: A boolean flag that determines if the object will be used to calculate the content height and width of its parent.
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
As a result of using targets, we can develop web sites or apps with the following features:
|
|
55
|
+
|
|
56
|
+
- **No HTML required**: HTML tags are seldom necessary except for images.
|
|
57
|
+
- **No HTML nesting**: HTML nesting is seldom required in TargetJ. If it is required, nesting is done at runtime. Elements can be dynamically detached and incorporated into other elements, facilitating the easy reuse of components regardless of their location or attachment. It also opens the door for a new user experiences.
|
|
58
|
+
- **Next-level animation**: Users can program objects to move at varying speeds, pause at certain intervals, and repeat sequences based on various conditions. It allows the creation of complicated animations.
|
|
59
|
+
- **Control the flow of execution with time**: TargetJ simplifies the execution of various program segments at specific times, making it easy to sequence or parallelize numerous actions.
|
|
60
|
+
- **Handle events effortlessly**: In TargetJ, events are triggered synchronously and are designed so that any component can detect when an event occurs. Event handling can be simply implemented as conditions in the enabling functions of \'targets.\' This ensures that managing events is both simple and effective.
|
|
61
|
+
- **Easy to learn**: TargetJ simplifies development by employing the single concept of \'targets\' making it easy to learn.
|
|
62
|
+
- **Handle 100,000s of items**: TargetJ efficiently manages large collections of objects on a single page. This is done by its data structure and optimization algorithm. It divides a long list into a tree structure, monitoring only the branches that are visible to the user at any given time.
|
|
63
|
+
- **AI friendly**: With a unified concept of targets for all development, the ability to add and remove targets at runtime, and the capability to inspect various statuses of running objects, TargetJ is a strong candidate for AI-powered UI development.
|
|
64
|
+
|
|
65
|
+
## Getting Started
|
|
66
|
+
|
|
19
67
|
### Installation
|
|
20
68
|
|
|
21
69
|
To install TargetJ, run the following command in your terminal:
|
|
@@ -24,7 +72,9 @@ To install TargetJ, run the following command in your terminal:
|
|
|
24
72
|
npm install targetj
|
|
25
73
|
```
|
|
26
74
|
|
|
27
|
-
|
|
75
|
+
## Examples
|
|
76
|
+
|
|
77
|
+
### Hello World example
|
|
28
78
|
|
|
29
79
|
```bash
|
|
30
80
|
import { App, TModel } from 'targetj';
|
|
@@ -32,8 +82,104 @@ import { App, TModel } from 'targetj';
|
|
|
32
82
|
App(new TModel({ html: 'Hello World'}));
|
|
33
83
|
```
|
|
34
84
|
|
|
85
|
+
### Simple animation example
|
|
86
|
+
```bash
|
|
87
|
+
import { App, TModel } from 'targetj';
|
|
88
|
+
|
|
89
|
+
App(new TModel({
|
|
90
|
+
style: { backgroundColor: '#f00' },
|
|
91
|
+
width: {
|
|
92
|
+
value: 250,
|
|
93
|
+
steps: 30,
|
|
94
|
+
stepInterval: 50
|
|
95
|
+
},
|
|
96
|
+
height: {
|
|
97
|
+
value: 250,
|
|
98
|
+
steps: 30,
|
|
99
|
+
stepInterval: 50
|
|
100
|
+
},
|
|
101
|
+
opacity: {
|
|
102
|
+
value: 0.15,
|
|
103
|
+
steps: 30,
|
|
104
|
+
stepInterval: 50
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
It can also be written in a more compact form using arrays:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
import { App, TModel } from 'targetj';
|
|
113
|
+
|
|
114
|
+
App(new TModel({
|
|
115
|
+
style: { backgroundColor: '#f00' },
|
|
116
|
+
width: [ 250, 30, 50],
|
|
117
|
+
height: [ 250, 30, 50],
|
|
118
|
+
opacity: [ 0.15, 30, 50]
|
|
119
|
+
}));
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### More complicated example
|
|
123
|
+
|
|
124
|
+
You can find a running example, which also demonstrates how the code operates, at https://targetj.io/docs/declarative.html
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
import { App, TModel, getScreenWidth, getScreenHeight } from "targetj";
|
|
128
|
+
|
|
129
|
+
App(
|
|
130
|
+
new TModel({
|
|
131
|
+
add() {
|
|
132
|
+
for (var i = 0; i < 10; i++) {
|
|
133
|
+
this.addChild(
|
|
134
|
+
new TModel("square", {
|
|
135
|
+
width: 50,
|
|
136
|
+
height: 50,
|
|
137
|
+
style: { backgroundColor: "#f00" },
|
|
138
|
+
rotate: {
|
|
139
|
+
cycles: 1000,
|
|
140
|
+
steps: 15,
|
|
141
|
+
stepInterval: 50,
|
|
142
|
+
value(key, cycle) {
|
|
143
|
+
return [360, 0][cycle % 2];
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
animate: {
|
|
151
|
+
loop: true,
|
|
152
|
+
stepInterval: 1600,
|
|
153
|
+
value() {
|
|
154
|
+
this.getChildren().forEach((child) => {
|
|
155
|
+
child.setTargetValue("x", -child.getWidth());
|
|
156
|
+
child.setTargetValue("x", getScreenWidth() + child.getWidth(), 30, 50);
|
|
157
|
+
child.setTargetValue("y", Math.random() * getScreenHeight(), 30, 50);
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
enabledOn() {
|
|
161
|
+
return this.isTargetComplete("add");
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
width() {
|
|
165
|
+
return getScreenWidth();
|
|
166
|
+
},
|
|
167
|
+
height() {
|
|
168
|
+
return getScreenHeight();
|
|
169
|
+
},
|
|
170
|
+
})
|
|
171
|
+
);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## How to debug in TargetJ
|
|
175
|
+
1. TargetJ.tapp.stop(): Stops the application.
|
|
176
|
+
2. TargetJ.tapp.start(): Restarts the application
|
|
177
|
+
3. TargetJ.tapp.throttle: Slows down the application. This represents the pause in milliseconds before starting another TargetJ task cycle. It is zero by default.
|
|
178
|
+
4. TargetJ.tapp.debugLevel: Logs information about the TargetJ task cycle and its efficiency. It is zero by default. Set it to 1 to log basic information and 2 to log more detailed information.
|
|
179
|
+
5. Use `t()` to find an object from the browser console using its `oid`: Inspect its targetValues to display the status of its targets.
|
|
180
|
+
|
|
35
181
|
## Documentation
|
|
36
|
-
|
|
182
|
+
Explore the full potential of TargetJ and dive into our interactive documentation at www.targetj.io.
|
|
37
183
|
|
|
38
184
|
## License
|
|
39
185
|
Distributed under the MIT License. See LICENSE for more information.
|
package/package.json
CHANGED
package/src/App.js
CHANGED
|
@@ -44,11 +44,11 @@ function AppFn(firstChild) {
|
|
|
44
44
|
my.targetManager = new TargetManager();
|
|
45
45
|
my.manager = new TModelManager();
|
|
46
46
|
|
|
47
|
-
my.
|
|
47
|
+
my.trootFactory = function() {
|
|
48
48
|
|
|
49
|
-
var
|
|
49
|
+
var troot = new TModel('targetj');
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
troot.addChild = function(child, index) {
|
|
52
52
|
if (!TUtil.isDefined(child.targets['domHolder'])) {
|
|
53
53
|
child.addTarget('domHolder', {
|
|
54
54
|
value: function() {
|
|
@@ -83,26 +83,26 @@ function AppFn(firstChild) {
|
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
TModel.prototype.addChild.call(
|
|
86
|
+
TModel.prototype.addChild.call(troot, child, index);
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
if (my.
|
|
90
|
-
my.
|
|
89
|
+
if (my.troot) {
|
|
90
|
+
my.troot.getChildren().forEach(function(t, num) {
|
|
91
91
|
var child = new TModel(t.type, t.targets);
|
|
92
92
|
child.oidNum = num;
|
|
93
93
|
child.oid = num > 0 ? t.type + num : t.type;
|
|
94
|
-
|
|
94
|
+
troot.addChild(child);
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
return
|
|
98
|
+
return troot;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
|
|
102
|
-
my.
|
|
102
|
+
my.troot = my.trootFactory();
|
|
103
103
|
|
|
104
104
|
if (firstChild) {
|
|
105
|
-
my.
|
|
105
|
+
my.troot.addChild(firstChild);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
window.history.pushState({ link: document.URL }, "", document.URL);
|
|
@@ -114,7 +114,7 @@ function AppFn(firstChild) {
|
|
|
114
114
|
my.runningFlag = false;
|
|
115
115
|
|
|
116
116
|
my.events.clear();
|
|
117
|
-
my.
|
|
117
|
+
my.troot.getChildren().forEach(function(child) {
|
|
118
118
|
child.deleteTargetValue('addEventHandler');
|
|
119
119
|
});
|
|
120
120
|
|
|
@@ -131,7 +131,7 @@ function AppFn(firstChild) {
|
|
|
131
131
|
my.stop = function() {
|
|
132
132
|
my.runningFlag = false;
|
|
133
133
|
|
|
134
|
-
my.
|
|
134
|
+
my.troot.getChildren().forEach(function(child) {
|
|
135
135
|
if (child.hasDom()) {
|
|
136
136
|
my.events.removeHandlers(child.$dom);
|
|
137
137
|
}
|
|
@@ -188,8 +188,8 @@ function isRunning() {
|
|
|
188
188
|
return tapp ? tapp.runningFlag : false;
|
|
189
189
|
};
|
|
190
190
|
|
|
191
|
-
function
|
|
192
|
-
return tapp ? tapp.
|
|
191
|
+
function troot() {
|
|
192
|
+
return tapp ? tapp.troot : null;
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
function getEvents() {
|
|
@@ -228,4 +228,4 @@ App.getOid = function(type) {
|
|
|
228
228
|
return { oid: num > 0 ? type + num : type, num: num };
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
export { tapp, App,
|
|
231
|
+
export { tapp, App, troot, isRunning, getEvents, getPager, getLoader, getManager, $Dom, getScreenWidth, getScreenHeight };
|
package/src/Dim.js
CHANGED
|
@@ -9,9 +9,9 @@ function Dim() {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
my.measureScreen = function() {
|
|
12
|
-
my.screen.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
12
|
+
my.screen.width = Math.min(window.outerWidth, window.innerWidth) || document.documentElement.clientWidth || document.body.clientWidth;
|
|
13
13
|
my.screen.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
return my;
|
|
16
16
|
};
|
|
17
17
|
|
package/src/EventListener.js
CHANGED
|
@@ -40,9 +40,7 @@ function EventListener() {
|
|
|
40
40
|
orientationchange: 'resize'
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
this.
|
|
44
|
-
this.eventName = "";
|
|
45
|
-
this.eventTagName = "";
|
|
43
|
+
this.lastEvents = [];
|
|
46
44
|
|
|
47
45
|
this.cursor = { x: 0, y: 0};
|
|
48
46
|
this.start0 = undefined;
|
|
@@ -77,48 +75,50 @@ EventListener.prototype.addHandlers = function ($dom) {
|
|
|
77
75
|
|
|
78
76
|
EventListener.prototype.captureEvents = function() {
|
|
79
77
|
|
|
80
|
-
if (
|
|
78
|
+
if (this.lastEvents.length === 0) {
|
|
81
79
|
this.currentEvent = "";
|
|
82
|
-
this.currentKey = "";
|
|
80
|
+
this.currentKey = "";
|
|
83
81
|
return;
|
|
84
82
|
}
|
|
83
|
+
var lastEvent = this.lastEvents.pop();
|
|
84
|
+
|
|
85
|
+
if (lastEvent.eventName === 'resize') {
|
|
86
|
+
tapp.dim.measureScreen();
|
|
87
|
+
} else {
|
|
88
|
+
this.findEventHandlers(lastEvent.tmodel);
|
|
89
|
+
this.currentEvent = lastEvent.eventName;
|
|
90
|
+
this.currentKey = this.currentTouch.key;
|
|
91
|
+
this.currentTouch.key = "";
|
|
92
|
+
}
|
|
85
93
|
|
|
86
|
-
this.findEventHandlers(this.lastEvent);
|
|
87
|
-
this.currentEvent = this.eventName;
|
|
88
|
-
this.currentKey = this.currentTouch.key;
|
|
89
|
-
this.eventName = "";
|
|
90
|
-
this.lastEvent = undefined;
|
|
91
|
-
this.currentTouch.key = "";
|
|
92
94
|
};
|
|
93
95
|
|
|
94
96
|
EventListener.prototype.handleEvent = function (event) {
|
|
95
|
-
|
|
96
|
-
if (this.eventName && this.eventName !== this.currentEvent) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
this.lastEvent = event;
|
|
101
|
-
|
|
102
|
-
this.eventTagName = (event.target.tagName || "").toUpperCase();
|
|
103
|
-
this.eventName = this.eventMap[event.type];
|
|
104
97
|
|
|
105
|
-
|
|
98
|
+
var eventName = this.eventMap[event.type];
|
|
99
|
+
var tmodel = this.getTModelFromEvent(event);
|
|
100
|
+
|
|
101
|
+
switch (eventName) {
|
|
106
102
|
|
|
107
103
|
case 'mousedown':
|
|
108
104
|
case 'touchstart':
|
|
105
|
+
this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
|
|
106
|
+
|
|
109
107
|
this.clear();
|
|
110
108
|
this.touchCount = this.countTouches(event);
|
|
111
|
-
if (this.preventDefault(
|
|
109
|
+
if (this.preventDefault(tmodel, eventName)) event.preventDefault();
|
|
112
110
|
this.start(event);
|
|
113
111
|
event.stopPropagation();
|
|
114
112
|
break;
|
|
115
113
|
|
|
116
114
|
case 'mousemove':
|
|
117
115
|
case 'touchmove':
|
|
116
|
+
this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
|
|
117
|
+
|
|
118
118
|
var touch = this.getTouch(event);
|
|
119
119
|
this.cursor.x = touch.x;
|
|
120
120
|
this.cursor.y = touch.y;
|
|
121
|
-
if (this.preventDefault(
|
|
121
|
+
if (this.preventDefault(tmodel, eventName)) event.preventDefault();
|
|
122
122
|
if (this.touchCount > 0) {
|
|
123
123
|
this.move(event);
|
|
124
124
|
event.stopPropagation();
|
|
@@ -127,32 +127,40 @@ EventListener.prototype.handleEvent = function (event) {
|
|
|
127
127
|
|
|
128
128
|
case 'mouseup':
|
|
129
129
|
case 'touchend':
|
|
130
|
-
|
|
130
|
+
this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
|
|
131
|
+
|
|
132
|
+
if (this.preventDefault(tmodel, eventName)) event.preventDefault();
|
|
131
133
|
this.end(event);
|
|
132
134
|
event.stopPropagation();
|
|
133
135
|
break;
|
|
134
136
|
|
|
135
137
|
case 'wheel':
|
|
136
|
-
|
|
138
|
+
this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
|
|
139
|
+
|
|
140
|
+
if (this.preventDefault(tmodel, eventName)) event.preventDefault();
|
|
137
141
|
this.wheel(event);
|
|
138
142
|
break;
|
|
139
143
|
|
|
140
144
|
case 'key':
|
|
145
|
+
this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
|
|
146
|
+
|
|
141
147
|
this.keyUpHandler(event);
|
|
142
148
|
break;
|
|
143
|
-
|
|
149
|
+
|
|
144
150
|
case 'resize':
|
|
145
|
-
|
|
151
|
+
if (this.lastEvents.length === 0 || this.lastEvents[this.lastEvents.length - 1].eventName !== 'resize') {
|
|
152
|
+
this.lastEvents.push({ eventName: eventName, tmodel: tmodel });
|
|
153
|
+
}
|
|
146
154
|
break;
|
|
147
|
-
|
|
155
|
+
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
tapp.manager.scheduleRun(0,
|
|
158
|
+
tapp.manager.scheduleRun(0, eventName + '-' + (event.target.tagName || "").toUpperCase());
|
|
159
|
+
tapp.manager.scheduleRun(20, eventName + '-' + (event.target.tagName || "").toUpperCase());
|
|
160
|
+
|
|
151
161
|
};
|
|
152
162
|
|
|
153
|
-
EventListener.prototype.findEventHandlers = function(
|
|
154
|
-
|
|
155
|
-
var tmodel = this.getTModelFromEvent(event);
|
|
163
|
+
EventListener.prototype.findEventHandlers = function(tmodel) {
|
|
156
164
|
|
|
157
165
|
var touchHandler = tmodel ? SearchUtil.findFirstTouchHandler(tmodel) : null;
|
|
158
166
|
var scrollLeftHandler = tmodel ? SearchUtil.findFirstScrollLeftHandler(tmodel) : null;
|
|
@@ -165,8 +173,7 @@ EventListener.prototype.findEventHandlers = function(event) {
|
|
|
165
173
|
this.currentHandlers.pinch = pinchHandler;
|
|
166
174
|
};
|
|
167
175
|
|
|
168
|
-
EventListener.prototype.preventDefault = function(
|
|
169
|
-
var tmodel = this.getTModelFromEvent(event);
|
|
176
|
+
EventListener.prototype.preventDefault = function(tmodel, eventName) {
|
|
170
177
|
|
|
171
178
|
if (tmodel && (tmodel.keepEventDefault() === true || (Array.isArray(tmodel.keepEventDefault()) && tmodel.keepEventDefault().includes(eventName)))) {
|
|
172
179
|
return false;
|
|
@@ -233,9 +240,6 @@ EventListener.prototype.resetEvents = function () {
|
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
tapp.manager.scheduleRun(runDelay, "scroll decay");
|
|
236
|
-
} else if (this.eventName || this.lastEvent) {
|
|
237
|
-
this.eventName = "";
|
|
238
|
-
tapp.manager.scheduleRun(1, "reseting current event");
|
|
239
243
|
}
|
|
240
244
|
|
|
241
245
|
};
|
|
@@ -413,8 +417,8 @@ EventListener.prototype.end = function (event) {
|
|
|
413
417
|
}
|
|
414
418
|
}
|
|
415
419
|
|
|
416
|
-
if (!momentum && this.touchCount === 1 && startToEndTime
|
|
417
|
-
this.eventName
|
|
420
|
+
if (!momentum && this.touchCount === 1 && startToEndTime <= 300) {
|
|
421
|
+
this.lastEvents.push({ eventName: 'click', tmodel: this.getTModelFromEvent(event) });
|
|
418
422
|
this.clear();
|
|
419
423
|
this.currentTouch.timeStamp = 0;
|
|
420
424
|
}
|
package/src/LocationManager.js
CHANGED
|
@@ -8,7 +8,7 @@ function LocationManager() {
|
|
|
8
8
|
this.hasLocationList = [];
|
|
9
9
|
this.hasLocationMap = {};
|
|
10
10
|
|
|
11
|
-
this.bracketThreshold =
|
|
11
|
+
this.bracketThreshold = 6;
|
|
12
12
|
this.locationCount = [];
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -22,8 +22,8 @@ LocationManager.prototype.calculateAll = function() {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
LocationManager.prototype.calculate = function() {
|
|
25
|
-
this.addToLocationList(tapp.
|
|
26
|
-
this.calculateContainer(tapp.
|
|
25
|
+
this.addToLocationList(tapp.troot);
|
|
26
|
+
this.calculateContainer(tapp.troot);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
LocationManager.prototype.getChildren = function(container) {
|
package/src/PageManager.js
CHANGED
|
@@ -15,13 +15,13 @@ PageManager.prototype.openPage = function(link) {
|
|
|
15
15
|
var self = this;
|
|
16
16
|
|
|
17
17
|
if (!this.pageCache[link]) {
|
|
18
|
-
tapp.
|
|
19
|
-
tapp.
|
|
18
|
+
tapp.troot.getChildren().forEach(function(child) { child.$dom.innerHTML(""); });
|
|
19
|
+
tapp.troot = tapp.trootFactory();
|
|
20
20
|
self.lastLink = link;
|
|
21
21
|
setTimeout(tapp.start);
|
|
22
22
|
} else {
|
|
23
|
-
tapp.
|
|
24
|
-
tapp.
|
|
23
|
+
tapp.troot = this.pageCache[link].troot;
|
|
24
|
+
tapp.troot.getChildren().forEach(function(child, index) {
|
|
25
25
|
child.$dom.innerHTML(self.pageCache[link].htmls[index]);
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -50,9 +50,9 @@ PageManager.prototype.openLink = function(link) {
|
|
|
50
50
|
if (this.lastLink) {
|
|
51
51
|
this.pageCache[this.lastLink] = {
|
|
52
52
|
link: this.lastLink,
|
|
53
|
-
htmls: tapp.
|
|
53
|
+
htmls: tapp.troot.getChildren().map(function(child) { return child.$dom.innerHTML(); }),
|
|
54
54
|
visibleList: tapp.manager.lists.visible.slice(0),
|
|
55
|
-
|
|
55
|
+
troot: tapp.troot
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -69,9 +69,9 @@ PageManager.prototype.updateBrowserUrl = function(link) {
|
|
|
69
69
|
if (!currentState.browserUrl) {
|
|
70
70
|
this.pageCache[document.URL] = {
|
|
71
71
|
link: document.URL,
|
|
72
|
-
htmls: tapp.
|
|
72
|
+
htmls: tapp.troot.getChildren().map(function(child) { return child.$dom.innerHTML(); }),
|
|
73
73
|
visibleList: tapp.manager.lists.visible.slice(0),
|
|
74
|
-
|
|
74
|
+
troot: tapp.troot
|
|
75
75
|
};
|
|
76
76
|
history.pushState({ browserUrl: link }, "", link);
|
|
77
77
|
} else {
|
package/src/SearchUtil.js
CHANGED
|
@@ -112,7 +112,7 @@ SearchUtil.findByType = function (type) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
if (!TUtil.isDefined(SearchUtil.foundTypeMap[type])) {
|
|
115
|
-
tmodel = search(tapp.
|
|
115
|
+
tmodel = search(tapp.troot);
|
|
116
116
|
if (tmodel) {
|
|
117
117
|
SearchUtil.foundTypeMap[type] = tmodel;
|
|
118
118
|
}
|
|
@@ -146,7 +146,7 @@ SearchUtil.findByTarget = function (target) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
if (!TUtil.isDefined(SearchUtil.foundTargetMap[target])) {
|
|
149
|
-
tmodel = search(tapp.
|
|
149
|
+
tmodel = search(tapp.troot);
|
|
150
150
|
if (tmodel) {
|
|
151
151
|
SearchUtil.foundTargetMap[target] = tmodel;
|
|
152
152
|
}
|
|
@@ -179,7 +179,7 @@ SearchUtil.find = function (oid) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
if (!TUtil.isDefined(SearchUtil.foundOids[oid])) {
|
|
182
|
-
tmodel = search(tapp.
|
|
182
|
+
tmodel = search(tapp.troot);
|
|
183
183
|
if (tmodel) {
|
|
184
184
|
SearchUtil.foundOids[oid] = tmodel;
|
|
185
185
|
}
|
package/src/TModelManager.js
CHANGED
|
@@ -332,7 +332,7 @@ TModelManager.prototype.run = function(oid, delay) {
|
|
|
332
332
|
|
|
333
333
|
tapp.targetManager.doneTargets.length = 0;
|
|
334
334
|
|
|
335
|
-
tapp.locationManager.calculateTargets(tapp.
|
|
335
|
+
tapp.locationManager.calculateTargets(tapp.troot);
|
|
336
336
|
|
|
337
337
|
tapp.locationManager.calculateAll();
|
|
338
338
|
|
package/src/TargetManager.js
CHANGED
|
@@ -60,7 +60,7 @@ TargetManager.prototype.setTargetValue = function(tmodel, key) {
|
|
|
60
60
|
|
|
61
61
|
if (tmodel.isTargetEnabled(key)) {
|
|
62
62
|
if (tmodel.getScheduleTimeStamp(key) && tmodel.isTargetActive(key) && tmodel.getTargetStepInterval(key) > 0
|
|
63
|
-
&& tmodel.getScheduleTimeStamp(key) + tmodel.getTargetStepInterval(key) <=
|
|
63
|
+
&& tmodel.getScheduleTimeStamp(key) + tmodel.getTargetStepInterval(key) <= browser.now()) {
|
|
64
64
|
tmodel.resetScheduleTimeStamp(key);
|
|
65
65
|
}
|
|
66
66
|
|