pict 1.0.73 → 1.0.75

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": "pict",
3
- "version": "1.0.73",
3
+ "version": "1.0.75",
4
4
  "description": "Pict browser library.",
5
5
  "main": "source/Pict.js",
6
6
  "scripts": {
@@ -46,7 +46,7 @@ class PictApplication extends libFableServiceBase
46
46
  if (this.options.AutoRenderMainViewportView)
47
47
  {
48
48
  this.log.info(`Pict Application ${this.options.Name}[${this.UUID}]::[${this.Hash}] beginning auto render of [${this.options.MainViewportView}::${this.options.MainViewportRenderable}].`);
49
- return this.renderAsync(this.options.MainViewportView, this.options.MainViewportRenderable, this.options.MainViewportDestinationAddress, this.options.MainViewportDefaultDataAddress, fStageComplete);
49
+ this.renderAsync(this.options.MainViewportView, this.options.MainViewportRenderable, this.options.MainViewportDestinationAddress, this.options.MainViewportDefaultDataAddress, ()=>{});
50
50
  }
51
51
  }
52
52
 
@@ -4,133 +4,158 @@ class PictContentAssignment extends libFableServiceBase
4
4
  {
5
5
  constructor(pFable, pOptions, pServiceHash)
6
6
  {
7
- super(pFable, pOptions, pServiceHash);
8
-
9
- this.serviceType = 'PictContentAssignment';
10
-
11
- // Check to see if we are running in a browser
12
- this.inBrowser = false;
13
- this.hasDocument = false;
14
- if (typeof(window) == 'object')
15
- {
16
- this.inBrowser = true;
17
- // Now check that the browser has a document object
18
- if ((typeof(window.document) != 'undefined') && (typeof(window.document.querySelectorAll) == 'function'))
19
- {
20
- this.hasDocument = true;
21
- }
22
- }
23
-
24
- // If we're in a browser, check to see if jQuery is available.
25
- this.hasJquery = false;
26
- this.jQuery = false;
27
- if (this.inBrowser && typeof(window.jQuery) !== 'undefined')
28
- {
29
- this.hasJquery = true;
30
- }
31
-
32
- // API Consumers can also craft their own assign function
33
- this.customAssignFunction = false;
34
-
35
- // API Consumers can also craft their own append function
36
- this.customAppendFunction = false;
37
-
38
- // API Consumers can also craft their own read function
39
- this.customReadFunction = false;
7
+ super(pFable, pOptions, pServiceHash);
8
+
9
+ this.serviceType = 'PictContentAssignment';
10
+
11
+ // Check to see if we are running in a browser
12
+ this.inBrowser = false;
13
+ this.hasDocument = false;
14
+ if (typeof (window) == 'object')
15
+ {
16
+ this.inBrowser = true;
17
+ // Now check that the browser has a document object
18
+ if ((typeof (window.document) != 'undefined') && (typeof (window.document.querySelectorAll) == 'function'))
19
+ {
20
+ this.hasDocument = true;
21
+ }
22
+ }
23
+
24
+ // If we're in a browser, check to see if jQuery is available.
25
+ this.hasJquery = false;
26
+ this.jQuery = false;
27
+ if (this.inBrowser && typeof (window.jQuery) !== 'undefined')
28
+ {
29
+ this.hasJquery = true;
30
+ }
31
+
32
+ // API Consumers can also craft their own assign function
33
+ this.customAssignFunction = false;
34
+
35
+ // API Consumers can also craft their own append function
36
+ this.customAppendFunction = false;
37
+
38
+ // API Consumers can also craft their own read function
39
+ this.customReadFunction = false;
40
+
41
+ // API Consumers can even craft their own get element function.
42
+ this.customGetElementFunction = false;
40
43
  }
41
44
 
42
- assignContent(pAddress, pContent)
43
- {
44
- if (this.customAssignFunction)
45
- {
46
- return this.customAssignFunction(pAddress, pContent);
47
- }
48
- else if (this.hasJquery)
49
- {
50
- // Get the element
51
- let tmpTargetElement = window.jQuery(pAddress);
52
-
53
- // Should we ensure we matched 1 and exactly 1 element?
54
- //if (tmpTargetElement && tmpTargetElement.length == 1)
55
- //{
56
- // Set the content
57
- tmpTargetElement.html(pContent);
58
- //}
59
- }
60
- else if (this.inBrowser && this.hasDocument)
61
- {
62
- let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
63
-
64
- for (let i = 0; i < tmpTargetElementSet.length; i++)
65
- {
66
- tmpTargetElementSet[i].innerHTML = pContent;
67
- }
68
- }
69
- else
70
- {
71
- // Just log it out for now
72
- this.log.trace(`PICT Content ASSIGN to [${pAddress}]:`, pContent);
73
- }
74
- }
75
-
76
- appendContent(pAddress, pContent)
77
- {
78
- if (this.customAppendFunction)
79
- {
80
- return this.customAppendFunction(pAddress, pContent);
81
- }
82
- else if (this.hasJquery)
83
- {
84
- let tmpTargetElement = window.jQuery(pAddress);
85
- tmpTargetElement.append(pContent);
86
- }
87
- else if (this.inBrowser && this.hasDocument)
88
- {
89
- let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
90
- for (let i = 0; i < tmpTargetElementSet.length; i++)
91
- {
92
- tmpTargetElementSet[i].insertAdjacentHTML("beforeend", pContent);
93
- }
94
- }
95
- else
96
- {
97
- // Just log it out for now -- nothing browser in our mix.
98
- this.log.trace(`PICT Content APPEND to [${pAddress}]:`, pContent);
99
- }
100
- }
101
-
102
- readContent(pAddress, pContentType)
103
- {
104
- let tmpContentType = (typeof(pContentType) == 'string') ? pContentType : 'value';
105
-
106
- if (this.customReadFunction)
107
- {
108
- return this.customReadFunction(pAddress, pContentType);
109
- }
110
- else if (this.hasJquery)
111
- {
112
- let tmpTargetElement = window.jQuery(pAddress);
113
- return tmpTargetElement.html();
114
- }
115
- else if (this.inBrowser && this.hasDocument)
116
- {
117
- let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
118
- if (tmpTargetElementSet.length < 1)
119
- {
120
- return '';
121
- }
122
- else if (tmpTargetElementSet.length == 1)
123
- {
124
- return tmpTargetElementSet[0].innerHTML;
125
- }
126
- }
127
- else
128
- {
129
- // Just log it out for now -- nothing browser in our mix.
130
- this.log.trace(`PICT Content READ from [${pAddress}] type [${tmpContentType}]...`);
131
- return '';
132
- }
133
- }
45
+ getElement(pAddress)
46
+ {
47
+ if (this.customGetElementFunction)
48
+ {
49
+ return this.customGetElementFunction(pAddress);
50
+ }
51
+ else if (this.hasJquery)
52
+ {
53
+ return window.jQuery(pAddress);
54
+ }
55
+ else if (this.inBrowser && this.hasDocument)
56
+ {
57
+ return window.document.querySelectorAll(pAddress);
58
+ }
59
+ else
60
+ {
61
+ // Just log it out for now
62
+ this.log.trace(`PICT Content GET ELEMENT for [${pAddress}]`);
63
+ return false;
64
+ }
65
+ }
66
+
67
+ assignContent(pAddress, pContent)
68
+ {
69
+ if (this.customAssignFunction)
70
+ {
71
+ return this.customAssignFunction(pAddress, pContent);
72
+ }
73
+ else if (this.hasJquery)
74
+ {
75
+ // Get the element
76
+ let tmpTargetElement = window.jQuery(pAddress);
77
+
78
+ // Should we ensure we matched 1 and exactly 1 element?
79
+ //if (tmpTargetElement && tmpTargetElement.length == 1)
80
+ //{
81
+ // Set the content
82
+ tmpTargetElement.html(pContent);
83
+ //}
84
+ }
85
+ else if (this.inBrowser && this.hasDocument)
86
+ {
87
+ let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
88
+
89
+ for (let i = 0; i < tmpTargetElementSet.length; i++)
90
+ {
91
+ tmpTargetElementSet[i].innerHTML = pContent;
92
+ }
93
+ }
94
+ else
95
+ {
96
+ // Just log it out for now
97
+ this.log.trace(`PICT Content ASSIGN to [${pAddress}]:`, pContent);
98
+ }
99
+ }
100
+
101
+ appendContent(pAddress, pContent)
102
+ {
103
+ if (this.customAppendFunction)
104
+ {
105
+ return this.customAppendFunction(pAddress, pContent);
106
+ }
107
+ else if (this.hasJquery)
108
+ {
109
+ let tmpTargetElement = window.jQuery(pAddress);
110
+ tmpTargetElement.append(pContent);
111
+ }
112
+ else if (this.inBrowser && this.hasDocument)
113
+ {
114
+ let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
115
+ for (let i = 0; i < tmpTargetElementSet.length; i++)
116
+ {
117
+ tmpTargetElementSet[i].insertAdjacentHTML("beforeend", pContent);
118
+ }
119
+ }
120
+ else
121
+ {
122
+ // Just log it out for now -- nothing browser in our mix.
123
+ this.log.trace(`PICT Content APPEND to [${pAddress}]:`, pContent);
124
+ }
125
+ }
126
+
127
+ readContent(pAddress, pContentType)
128
+ {
129
+ let tmpContentType = (typeof (pContentType) == 'string') ? pContentType : 'value';
130
+
131
+ if (this.customReadFunction)
132
+ {
133
+ return this.customReadFunction(pAddress, pContentType);
134
+ }
135
+ else if (this.hasJquery)
136
+ {
137
+ let tmpTargetElement = window.jQuery(pAddress);
138
+ return tmpTargetElement.html();
139
+ }
140
+ else if (this.inBrowser && this.hasDocument)
141
+ {
142
+ let tmpTargetElementSet = window.document.querySelectorAll(pAddress);
143
+ if (tmpTargetElementSet.length < 1)
144
+ {
145
+ return '';
146
+ }
147
+ else if (tmpTargetElementSet.length == 1)
148
+ {
149
+ return tmpTargetElementSet[0].innerHTML;
150
+ }
151
+ }
152
+ else
153
+ {
154
+ // Just log it out for now -- nothing browser in our mix.
155
+ this.log.trace(`PICT Content READ from [${pAddress}] type [${tmpContentType}]...`);
156
+ return '';
157
+ }
158
+ }
134
159
  }
135
160
 
136
161
  module.exports = PictContentAssignment;
@@ -97,7 +97,7 @@ class PictView extends libFableServiceBase
97
97
  }
98
98
  if (this.options.RenderOnLoad)
99
99
  {
100
- return this.render(this.options.DefaultRenderable, this.options.DefaultDestinationAddress, this.options.DefaultTemplateRecordAddress);
100
+ this.render(this.options.DefaultRenderable, this.options.DefaultDestinationAddress, this.options.DefaultTemplateRecordAddress);
101
101
  }
102
102
  }
103
103