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 +1 -1
- package/source/Pict-Application.js +1 -1
- package/source/Pict-Content-Assignment.js +150 -125
- package/source/Pict-View.js +1 -1
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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;
|
package/source/Pict-View.js
CHANGED
|
@@ -97,7 +97,7 @@ class PictView extends libFableServiceBase
|
|
|
97
97
|
}
|
|
98
98
|
if (this.options.RenderOnLoad)
|
|
99
99
|
{
|
|
100
|
-
|
|
100
|
+
this.render(this.options.DefaultRenderable, this.options.DefaultDestinationAddress, this.options.DefaultTemplateRecordAddress);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|