targetj 1.0.54 → 1.0.55

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
4
4
  "keywords": [
5
5
  "targetj"
6
6
  ],
package/src/App.js CHANGED
@@ -13,7 +13,7 @@ import { TargetManager } from "./TargetManager.js";
13
13
 
14
14
  var tapp;
15
15
 
16
- function AppFn(tmodel) {
16
+ function AppFn(firstChild) {
17
17
 
18
18
  function my() {}
19
19
 
@@ -44,33 +44,32 @@ function AppFn(tmodel) {
44
44
  my.targetManager = new TargetManager();
45
45
  my.manager = new TModelManager();
46
46
 
47
- my.uiFactory = function() {
48
-
49
- var tmodel = new TModel('targetj', {
50
- domCreatedBySelector: true,
51
- domHolder: {
52
- value: function() {
53
- return this.getDomHolder();
54
- },
55
- enabledOn: function() {
56
- return this.getDomHolder();
57
- }
58
- },
59
- canHaveDom: false
60
- });
47
+ my.tjRootFactory = function() {
48
+
49
+ var tjRoot = new TModel('targetj');
61
50
 
62
- tmodel.addChild = function(child, index) {
63
- child.addTargets({
64
- domCreatedBySelector: true,
65
- domHolder: {
51
+ tjRoot.addChild = function(child, index) {
52
+ if (!TUtil.isDefined(child.targets['domHolder'])) {
53
+ child.addTarget('domHolder', {
66
54
  value: function() {
67
- return this.getDomHolder();
68
- },
69
- enabledOn: function() {
70
- return this.getDomHolder();
55
+ var $dom;
56
+ if (!$Dom.query('#tj-root')) {
57
+ $dom = new $Dom();
58
+ $dom.create('div');
59
+ $dom.setSelector('#tj-root');
60
+ $dom.setId('#tj-root');
61
+ $dom.attr("tabindex", "0");
62
+ new $Dom('body').insertFirst$Dom($dom);
63
+ } else {
64
+ $dom = new $Dom('#tj-root');
65
+ }
66
+ return $dom;
71
67
  }
72
- },
73
- addEventHandler: {
68
+ });
69
+ }
70
+
71
+ if (!TUtil.isDefined(child.targets['addEventHandler'])) {
72
+ child.addTarget('addEventHandler', {
74
73
  value: function() {
75
74
  my.events.removeHandlers(this.$dom);
76
75
  my.events.addHandlers(this.$dom);
@@ -81,27 +80,29 @@ function AppFn(tmodel) {
81
80
  enabledOn: function() {
82
81
  return this.hasDom();
83
82
  }
84
- }
85
- });
83
+ });
84
+ }
86
85
 
87
- TModel.prototype.addChild.call(tmodel, child, index);
86
+ TModel.prototype.addChild.call(tjRoot, child, index);
88
87
  };
89
-
90
-
91
- if (my.ui) {
92
- my.ui.getChildren().forEach(function(t, index) {
93
- delete App.oids[t.type];
94
- tmodel.addChild(new TModel(t.type, t.targets));
88
+
89
+ if (my.tjRoot) {
90
+ my.tjRoot.getChildren().forEach(function(t, num) {
91
+ var child = new TModel(t.type, t.targets);
92
+ child.oidNum = num;
93
+ child.oid = num > 0 ? t.type + num : t.type;
94
+ tjRoot.addChild(child);
95
95
  });
96
96
  }
97
97
 
98
- return tmodel;
98
+ return tjRoot;
99
99
  };
100
100
 
101
101
 
102
- my.ui = my.uiFactory();
103
- if (tmodel) {
104
- my.ui.addChild(tmodel);
102
+ my.tjRoot = my.tjRootFactory();
103
+
104
+ if (firstChild) {
105
+ my.tjRoot.addChild(firstChild);
105
106
  }
106
107
 
107
108
  window.history.pushState({ link: document.URL }, "", document.URL);
@@ -113,7 +114,7 @@ function AppFn(tmodel) {
113
114
  my.runningFlag = false;
114
115
 
115
116
  my.events.clear();
116
- my.ui.getChildren().forEach(function(child) {
117
+ my.tjRoot.getChildren().forEach(function(child) {
117
118
  child.deleteTargetValue('addEventHandler');
118
119
  });
119
120
 
@@ -130,7 +131,7 @@ function AppFn(tmodel) {
130
131
  my.stop = function() {
131
132
  my.runningFlag = false;
132
133
 
133
- my.ui.getChildren().forEach(function(child) {
134
+ my.tjRoot.getChildren().forEach(function(child) {
134
135
  if (child.hasDom()) {
135
136
  my.events.removeHandlers(child.$dom);
136
137
  }
@@ -186,8 +187,8 @@ function isRunning() {
186
187
  return tapp ? tapp.runningFlag : false;
187
188
  };
188
189
 
189
- function ui() {
190
- return tapp ? tapp.ui : null;
190
+ function tjRoot() {
191
+ return tapp ? tapp.tjRoot : null;
191
192
  }
192
193
 
193
194
  function getEvents() {
@@ -226,4 +227,4 @@ App.getOid = function(type) {
226
227
  return { oid: num > 0 ? type + num : type, num: num };
227
228
  };
228
229
 
229
- export { tapp, App, isRunning, ui, getEvents, getPager, getLoader, getManager, $Dom, getScreenWidth, getScreenHeight };
230
+ export { tapp, App, tjRoot, isRunning, getEvents, getPager, getLoader, getManager, $Dom, getScreenWidth, getScreenHeight };
@@ -101,7 +101,7 @@ EventListener.prototype.handleEvent = function (event) {
101
101
 
102
102
  this.eventTagName = (event.target.tagName || "").toUpperCase();
103
103
  this.eventName = this.eventMap[event.type];
104
-
104
+
105
105
  switch (this.eventName) {
106
106
 
107
107
  case 'mousedown':
@@ -22,8 +22,8 @@ LocationManager.prototype.calculateAll = function() {
22
22
  };
23
23
 
24
24
  LocationManager.prototype.calculate = function() {
25
- this.addToLocationList(tapp.ui);
26
- this.calculateContainer(tapp.ui);
25
+ this.addToLocationList(tapp.tjRoot);
26
+ this.calculateContainer(tapp.tjRoot);
27
27
  };
28
28
 
29
29
  LocationManager.prototype.getChildren = function(container) {
@@ -15,13 +15,13 @@ PageManager.prototype.openPage = function(link) {
15
15
  var self = this;
16
16
 
17
17
  if (!this.pageCache[link]) {
18
- tapp.ui.getChildren().forEach(function(child) { child.$dom.innerHTML(""); });
19
- tapp.ui = tapp.uiFactory();
18
+ tapp.tjRoot.getChildren().forEach(function(child) { child.$dom.innerHTML(""); });
19
+ tapp.tjRoot = tapp.tjRootFactory();
20
20
  self.lastLink = link;
21
21
  setTimeout(tapp.start);
22
22
  } else {
23
- tapp.ui = this.pageCache[link].ui;
24
- tapp.ui.getChildren().forEach(function(child, index) {
23
+ tapp.tjRoot = this.pageCache[link].tjRoot;
24
+ tapp.tjRoot.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.ui.getChildren().map(function(child) { return child.$dom.innerHTML(); }),
53
+ htmls: tapp.tjRoot.getChildren().map(function(child) { return child.$dom.innerHTML(); }),
54
54
  visibleList: tapp.manager.lists.visible.slice(0),
55
- ui: tapp.ui
55
+ tjRoot: tapp.tjRoot
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.ui.getChildren().map(function(child) { return child.$dom.innerHTML(); }),
72
+ htmls: tapp.tjRoot.getChildren().map(function(child) { return child.$dom.innerHTML(); }),
73
73
  visibleList: tapp.manager.lists.visible.slice(0),
74
- ui: tapp.ui
74
+ tjRoot: tapp.tjRoot
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.ui);
115
+ tmodel = search(tapp.tjRoot);
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.ui);
149
+ tmodel = search(tapp.tjRoot);
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.ui);
182
+ tmodel = search(tapp.tjRoot);
183
183
  if (tmodel) {
184
184
  SearchUtil.foundOids[oid] = tmodel;
185
185
  }
package/src/TModel.js CHANGED
@@ -50,8 +50,6 @@ function TModel(type, targets) {
50
50
  allChildren: [],
51
51
  isInFlow: true,
52
52
  canHaveDom: true,
53
- domSelector: '#tpage',
54
- domCreatedBySelector: false,
55
53
  canHandleEvents: false,
56
54
  widthFromDom: false,
57
55
  heightFromDom: false,
@@ -110,25 +108,7 @@ TModel.prototype.getDomParent = function() {
110
108
  };
111
109
 
112
110
  TModel.prototype.getDomHolder = function() {
113
- var $dom;
114
-
115
- if (this.getValue('domCreatedBySelector')) {
116
-
117
- if (!$Dom.query(this.getValue('domSelector'))) {
118
- $dom = new $Dom();
119
- $dom.create('div');
120
- $dom.setSelector(this.getValue('domSelector'));
121
- $dom.setId(this.getValue('domSelector'));
122
- $dom.attr("tabindex", "0");
123
- new $Dom('body').insertFirst$Dom($dom);
124
- } else {
125
- $dom = new $Dom(this.getValue('domSelector'));
126
- }
127
- } else {
128
- $dom = this.actualValues.domHolder ? this.actualValues.domHolder : this.getDomParent() ? this.getDomParent().$dom : SearchUtil.findParentWithTarget(this, 'domHolder') ? SearchUtil.findParentWithTarget(this, 'domHolder').$dom : null;
129
- }
130
-
131
- return $dom;
111
+ return this.actualValues.domHolder ? this.actualValues.domHolder : this.getDomParent() ? this.getDomParent().$dom : SearchUtil.findParentWithTarget(this, 'domHolder') ? SearchUtil.findParentWithTarget(this, 'domHolder').$dom : null;
132
112
  };
133
113
 
134
114
  TModel.prototype.resetActiveTargetMap = function() {
@@ -322,7 +322,7 @@ TModelManager.prototype.run = function(oid, delay) {
322
322
 
323
323
  tapp.targetManager.doneTargets.length = 0;
324
324
 
325
- tapp.locationManager.calculateTargets(tapp.ui);
325
+ tapp.locationManager.calculateTargets(tapp.tjRoot);
326
326
 
327
327
  tapp.locationManager.calculateAll();
328
328
 
package/webpack.config.js CHANGED
@@ -7,7 +7,7 @@ module.exports = {
7
7
  name: 'TargetJ',
8
8
  type: 'window'
9
9
  },
10
- path: path.resolve(__dirname, './dist'),
10
+ path: path.resolve(__dirname, '../targetj/jslib'),
11
11
  filename: 'targetj.js'
12
12
  }
13
13
  };