powerpagestoolkit 1.0.12 → 1.0.14
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/index.d.ts +3 -3
- package/package.json +9 -2
- package/.babelrc +0 -3
- package/.eslintrc.cjs +0 -29
- package/lib/API.js +0 -70
- package/lib/DOMNodeReferences.js +0 -270
- package/lib/FieldValidation.class.js +0 -25
- package/lib/common_functions.js +0 -24
- package/lib/createInfoElement.js +0 -62
- package/lib/safeAjax.js +0 -31
- package/webpack.config.cjs +0 -29
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare module powerpagestoolkit {
|
|
2
|
-
|
|
1
|
+
declare module "powerpagestoolkit" {
|
|
2
|
+
class DOMNodeReference {
|
|
3
3
|
constructor(querySelector: string);
|
|
4
4
|
element: HTMLElement | null;
|
|
5
5
|
isLoaded: boolean;
|
|
@@ -30,7 +30,7 @@ declare module powerpagestoolkit {
|
|
|
30
30
|
onceLoaded(callback: (instance: this) => void): void;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function createDOMNodeReference(
|
|
33
|
+
export async function createDOMNodeReference(
|
|
34
34
|
querySelector: string
|
|
35
35
|
): Promise<DOMNodeReference>;
|
|
36
36
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "powerpagestoolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "Reference, manipulate, and engage with Power Pages sites through the nodes in the DOM; use a variety of custom methods that allow customizing your power pages site quicker and easier. ",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
9
|
},
|
|
9
10
|
"devDependencies": {
|
|
10
11
|
"@babel/core": "^7.25.8",
|
|
11
12
|
"@babel/preset-env": "^7.25.8",
|
|
13
|
+
"@types/node": "^22.8.0",
|
|
12
14
|
"babel-loader": "^9.2.1",
|
|
13
15
|
"eslint": "^8.57.1",
|
|
16
|
+
"typescript": "^5.6.3",
|
|
14
17
|
"webpack": "^5.95.0",
|
|
15
18
|
"webpack-cli": "^5.1.4"
|
|
16
19
|
},
|
|
@@ -20,5 +23,9 @@
|
|
|
20
23
|
"repository": {
|
|
21
24
|
"type": "git",
|
|
22
25
|
"url": "https://github.com/Keaton-Brewster/PowerPagesToolKit"
|
|
23
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"index.js",
|
|
29
|
+
"index.d.ts"
|
|
30
|
+
]
|
|
24
31
|
}
|
package/.babelrc
DELETED
package/.eslintrc.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
es2021: true,
|
|
5
|
-
},
|
|
6
|
-
extends: "eslint:recommended",
|
|
7
|
-
overrides: [
|
|
8
|
-
{
|
|
9
|
-
env: {
|
|
10
|
-
node: true,
|
|
11
|
-
},
|
|
12
|
-
files: [".eslintrc.{js,cjs}"],
|
|
13
|
-
parserOptions: {
|
|
14
|
-
sourceType: "script",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
parserOptions: {
|
|
19
|
-
ecmaVersion: "latest",
|
|
20
|
-
sourceType: "module",
|
|
21
|
-
},
|
|
22
|
-
rules: {
|
|
23
|
-
"no-undef": "error",
|
|
24
|
-
"no-unused-vars": "warn",
|
|
25
|
-
},
|
|
26
|
-
globals: {
|
|
27
|
-
$: "readonly",
|
|
28
|
-
},
|
|
29
|
-
};
|
package/lib/API.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import safeAjax from "./safeAjax.js";
|
|
2
|
-
const API = {
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @param {Class} schema an instance of a schema class, containing the desired information for the POST request
|
|
6
|
-
* @returns a Promise resolving the successful results *[record id]* of the POST request, or rejecting the failed results *[error]* of the POST request.
|
|
7
|
-
*/
|
|
8
|
-
createRecord(schema) {
|
|
9
|
-
return new Promise((resolve, reject) => {
|
|
10
|
-
safeAjax({
|
|
11
|
-
type: "POST",
|
|
12
|
-
url: `/_api/${schema.logicalName()}`,
|
|
13
|
-
data: schema.value(),
|
|
14
|
-
contentType: "application/json",
|
|
15
|
-
success: function (response, status, xhr) {
|
|
16
|
-
resolve(xhr.getResponseHeader("entityid"));
|
|
17
|
-
},
|
|
18
|
-
error: (error) => {
|
|
19
|
-
reject(error);
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {string} tableSetName The DataVerse SET name of the table being queried
|
|
27
|
-
* @param {string} recordID the GUID of the records to be retrieved
|
|
28
|
-
* @param {string} selectColumns *OPTIONAL* if desired, enter your own custom OData query for advanced GET results. Format = select=column1,column2,column3...
|
|
29
|
-
* @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
|
|
30
|
-
*/
|
|
31
|
-
getRecord(tableSetName, recordID, selectColumns) {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
const url = `/_api/${tableSetName}(${recordID})${
|
|
34
|
-
selectColumns ? `?$${selectColumns}` : ""
|
|
35
|
-
}`;
|
|
36
|
-
|
|
37
|
-
safeAjax({
|
|
38
|
-
type: "GET",
|
|
39
|
-
url: url,
|
|
40
|
-
success: resolve,
|
|
41
|
-
error: reject,
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param {String} tableSetName The DataVerse SET name of the table being queried
|
|
48
|
-
* @param {String} queryParameters *OPTIONAL* the OData query parameters for refining search results: *format = $filter=filters&$select=columns*
|
|
49
|
-
* @returns a Promise resolving the successful results of the GET request, or rejecting the failed results of the GET request
|
|
50
|
-
*/
|
|
51
|
-
getMultiple(tableSetName, queryParameters) {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
// Construct the URL based on the presence of query parameters
|
|
54
|
-
const url = `/_api/${tableSetName}${
|
|
55
|
-
queryParameters ? `?${queryParameters}` : ""
|
|
56
|
-
}`;
|
|
57
|
-
|
|
58
|
-
safeAjax({
|
|
59
|
-
type: "GET",
|
|
60
|
-
url: url,
|
|
61
|
-
success: function (response) {
|
|
62
|
-
resolve(response.value);
|
|
63
|
-
},
|
|
64
|
-
error: reject,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default API;
|
package/lib/DOMNodeReferences.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { waitFor } from "./common_functions.js";
|
|
2
|
-
import FieldValidation from "./FieldValidation.class.js";
|
|
3
|
-
import createInfoEl from "./createInfoElement.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Class representing a reference to a DOM node.
|
|
7
|
-
*/
|
|
8
|
-
class DOMNodeReference {
|
|
9
|
-
/**
|
|
10
|
-
* Creates an instance of DOMNodeReference.
|
|
11
|
-
* @param {string} querySelector - The CSS selector to find the desired DOM element.
|
|
12
|
-
*/
|
|
13
|
-
constructor(querySelector) {
|
|
14
|
-
this.querySelector = querySelector;
|
|
15
|
-
this.element = null;
|
|
16
|
-
this.isLoaded = false;
|
|
17
|
-
// Deferred initialization
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Initializes the DOMNodeReference instance by waiting for the element to be available in the DOM.
|
|
22
|
-
* @returns {Promise<Proxy>} A promise that resolves to a Proxy of the DOMNodeReference instance.
|
|
23
|
-
* @throws {Error} Throws an error if the element cannot be found using the provided query selector.
|
|
24
|
-
*/
|
|
25
|
-
async init() {
|
|
26
|
-
const element = await waitFor(this.querySelector);
|
|
27
|
-
if (!element) {
|
|
28
|
-
throw new Error(
|
|
29
|
-
`[SYNACT] No Element could be found with the provided query selector: ${this.querySelector}`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
this.element = element;
|
|
34
|
-
this.parentElement = element.parentElement;
|
|
35
|
-
this.container = element.parentElement.parentElement.parentElement;
|
|
36
|
-
this.isLoaded = true;
|
|
37
|
-
|
|
38
|
-
if (this.element.classList.contains("boolean-radio")) {
|
|
39
|
-
this.yesRadio = new DOMNodeReference(`#${this.element.id}_1`);
|
|
40
|
-
this.noRadio = new DOMNodeReference(`#${this.element.id}_0`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
this.defaultDisplay = this.element.style.display || "block";
|
|
44
|
-
this.defaultParentDisplay = this.parentElement.style.display || "block";
|
|
45
|
-
this.defaultContainerDisplay = this.container.style.display || "block";
|
|
46
|
-
|
|
47
|
-
return new Proxy(this, {
|
|
48
|
-
get: (target, prop) => {
|
|
49
|
-
const value = target[prop];
|
|
50
|
-
if (typeof value === "function" && prop !== "onceLoaded") {
|
|
51
|
-
return (...args) =>
|
|
52
|
-
target.onceLoaded(() => value.apply(target, args));
|
|
53
|
-
}
|
|
54
|
-
return value;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Hides the element by setting its display style to "none".
|
|
61
|
-
* @method hide
|
|
62
|
-
*/
|
|
63
|
-
hide() {
|
|
64
|
-
this.element.style.display = "none";
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Shows the element by restoring its default display style.
|
|
69
|
-
* @method show
|
|
70
|
-
*/
|
|
71
|
-
show() {
|
|
72
|
-
this.element.style.display = this.defaultDisplay;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Hides the parent element by setting its display style to "none".
|
|
77
|
-
* @method hideParent
|
|
78
|
-
*/
|
|
79
|
-
hideParent() {
|
|
80
|
-
this.parentElement.style.display = "none";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Shows the parent element by restoring its default display style.
|
|
85
|
-
* @method showParent
|
|
86
|
-
*/
|
|
87
|
-
showParent() {
|
|
88
|
-
this.parentElement.style.display = this.defaultParentDisplay;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Hides the container (grandparent of the element) by setting its display style to "none".
|
|
93
|
-
* @method hideContainer
|
|
94
|
-
*/
|
|
95
|
-
hideContainer() {
|
|
96
|
-
this.element.parentElement.parentElement.parentElement.style.display =
|
|
97
|
-
"none";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Shows the container (grandparent of the element) by restoring its default display style.
|
|
102
|
-
* @method showContainer
|
|
103
|
-
*/
|
|
104
|
-
showContainer() {
|
|
105
|
-
this.element.parentElement.parentElement.parentElement.style.display =
|
|
106
|
-
this.defaultContainerDisplay;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Sets the value of the HTML element.
|
|
111
|
-
* @method setValue
|
|
112
|
-
* @param {string} value - The value to set for the HTML element.
|
|
113
|
-
*/
|
|
114
|
-
setValue(value) {
|
|
115
|
-
this.element.value = value;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Gets the value of the HTML element.
|
|
120
|
-
* @method getValue
|
|
121
|
-
* @returns {string} The current value of the HTML element.
|
|
122
|
-
*/
|
|
123
|
-
getValue() {
|
|
124
|
-
return this.element.value;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Appends child elements to the HTML element.
|
|
129
|
-
* @method append
|
|
130
|
-
* @param {...HTMLElement} elements - The elements to append to the HTML element.
|
|
131
|
-
*/
|
|
132
|
-
append(...elements) {
|
|
133
|
-
this.element.append(...elements);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Inserts elements after the HTML element.
|
|
138
|
-
* @method after
|
|
139
|
-
* @param {...HTMLElement} elements - The elements to insert after the HTML element.
|
|
140
|
-
*/
|
|
141
|
-
after(...elements) {
|
|
142
|
-
this.element.after(...elements);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Retrieves the label associated with the HTML element.
|
|
147
|
-
* @method getLabel
|
|
148
|
-
* @returns {HTMLElement} The label element associated with this element.
|
|
149
|
-
* @throws {Error} Throws an error if the label cannot be found.
|
|
150
|
-
*/
|
|
151
|
-
getLabel() {
|
|
152
|
-
return document.querySelector(`#${this.element.id}_label`);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Appends child elements to the label associated with the HTML element.
|
|
157
|
-
* @method appendToLabel
|
|
158
|
-
* @param {...HTMLElement} elements - The elements to append to the label.
|
|
159
|
-
*/
|
|
160
|
-
appendToLabel(...elements) {
|
|
161
|
-
let label = this.getLabel();
|
|
162
|
-
label.append(" ", ...elements);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Adds a click event listener to the HTML element.
|
|
167
|
-
* @method addClickListener
|
|
168
|
-
* @param {Function} eventHandler - The function to execute when the element is clicked.
|
|
169
|
-
*/
|
|
170
|
-
addClickListener(eventHandler) {
|
|
171
|
-
this.element.addEventListener("click", (e) => {
|
|
172
|
-
e.preventDefault();
|
|
173
|
-
eventHandler();
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Adds a change event listener to the HTML element.
|
|
179
|
-
* @method addChangeListener
|
|
180
|
-
* @param {Function} eventHandler - The function to execute when the element's value changes.
|
|
181
|
-
*/
|
|
182
|
-
addChangeListener(eventHandler) {
|
|
183
|
-
this.element.addEventListener("change", (e) => {
|
|
184
|
-
e.preventDefault();
|
|
185
|
-
eventHandler();
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Unchecks both the yes and no radio buttons if they exist.
|
|
191
|
-
* @method uncheckRadios
|
|
192
|
-
*/
|
|
193
|
-
uncheckRadios() {
|
|
194
|
-
if (this.yesRadio && this.noRadio) {
|
|
195
|
-
this.yesRadio.element.checked = false;
|
|
196
|
-
this.noRadio.element.checked = false;
|
|
197
|
-
} else {
|
|
198
|
-
console.error(
|
|
199
|
-
"[SYNACT] Attempted to uncheck radios for an element that has no radios"
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Creates a validation instance for the field.
|
|
206
|
-
* @method createValidation
|
|
207
|
-
* @param {Function} evaluationFunction - The function used to evaluate the field.
|
|
208
|
-
* @param {string} fieldDisplayName - The field name to display in error if validation fails.
|
|
209
|
-
*/
|
|
210
|
-
createValidation(evaluationFunction, fieldDisplayName) {
|
|
211
|
-
new FieldValidation(this.id, `'${fieldDisplayName}'`, evaluationFunction);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Adds a tooltip with specified text to the label associated with the HTML element.
|
|
216
|
-
* @method addLabelTooltip
|
|
217
|
-
* @param {string} text - The text to display in the tooltip.
|
|
218
|
-
*/
|
|
219
|
-
addLabelTooltip(text) {
|
|
220
|
-
this.appendToLabel(createInfoEl(text));
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Sets the inner HTML content of the HTML element.
|
|
225
|
-
* @method setTextContent
|
|
226
|
-
* @param {string} text - The text to set as the inner HTML of the element.
|
|
227
|
-
*/
|
|
228
|
-
setTextContent(text) {
|
|
229
|
-
this.element.innerHTML = text;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Executes a callback function once the element is fully loaded.
|
|
234
|
-
* If the element is already loaded, the callback is called immediately.
|
|
235
|
-
* Otherwise, a MutationObserver is used to detect when the element is added to the DOM.
|
|
236
|
-
* @method onceLoaded
|
|
237
|
-
* @param {Function} callback - A callback function to execute once the element is loaded.
|
|
238
|
-
*/
|
|
239
|
-
onceLoaded(callback) {
|
|
240
|
-
console.log("loading element");
|
|
241
|
-
if (this.isLoaded) {
|
|
242
|
-
callback(this);
|
|
243
|
-
} else {
|
|
244
|
-
const observer = new MutationObserver(() => {
|
|
245
|
-
if (document.querySelector(this.querySelector)) {
|
|
246
|
-
observer.disconnect(); // Stop observing once loaded
|
|
247
|
-
this.isLoaded = true;
|
|
248
|
-
callback(this); // Call the provided callback
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
observer.observe(document.body, {
|
|
253
|
-
subtree: true,
|
|
254
|
-
childList: true,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Creates and initializes a DOMNodeReference instance.
|
|
262
|
-
* @async
|
|
263
|
-
* @function createDOMNodeReference
|
|
264
|
-
* @param {string} querySelector - The CSS selector for the desired DOM element.
|
|
265
|
-
* @returns {Promise<Proxy>} A promise that resolves to a Proxy of the initialized DOMNodeReference instance.
|
|
266
|
-
*/
|
|
267
|
-
export default async function createDOMNodeReference(querySelector) {
|
|
268
|
-
const instance = new DOMNodeReference(querySelector);
|
|
269
|
-
return await instance.init();
|
|
270
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export default class FieldValidation {
|
|
2
|
-
constructor(fieldLogicalName, fieldDisplayname, evaluationFunction) {
|
|
3
|
-
this.fieldLogicalName = fieldLogicalName;
|
|
4
|
-
this.fieldDisplayname = fieldDisplayname;
|
|
5
|
-
this.evaluationFunction = evaluationFunction.bind(this);
|
|
6
|
-
|
|
7
|
-
this.createValidator();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
createValidator = function () {
|
|
11
|
-
if (typeof Page_Validators == "undefined") return;
|
|
12
|
-
// Create new validator
|
|
13
|
-
var newValidator = document.createElement("span");
|
|
14
|
-
newValidator.style.display = "none";
|
|
15
|
-
newValidator.id = `${this.fieldLogicalName}Validator`;
|
|
16
|
-
newValidator.controltovalidate = `${this.fieldLogicalName}`;
|
|
17
|
-
newValidator.errormessage = `<a href='#${this.fieldDisplayname}_label'>${this.fieldDisplayname} is a required field</a>`;
|
|
18
|
-
newValidator.validationGroup = ""; // Set this if you have set ValidationGroup on the form
|
|
19
|
-
newValidator.initialvalue = "";
|
|
20
|
-
newValidator.evaluationfunction = this.evaluationFunction;
|
|
21
|
-
// Add the new validator to the page validators array:
|
|
22
|
-
// eslint-disable-next-line no-undef
|
|
23
|
-
Page_Validators.push(newValidator);
|
|
24
|
-
};
|
|
25
|
-
}
|
package/lib/common_functions.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description a function that will wait for a targeted element to appear in the DOM, and then resolve a promise to allow further action to be performed after the targeted elements appears
|
|
3
|
-
* @param {String} selector a query selector expression to target a specific element that you want to appear in the DOM before taking further action
|
|
4
|
-
* @returns {Promise} the element targeted by ID *selector*
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export function waitFor(selector) {
|
|
8
|
-
return new Promise((resolve) => {
|
|
9
|
-
if (document.querySelector(selector)) {
|
|
10
|
-
return resolve(document.querySelector(selector));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const observer = new MutationObserver(() => {
|
|
14
|
-
if (document.querySelector(selector)) {
|
|
15
|
-
observer.disconnect();
|
|
16
|
-
resolve(document.querySelector(selector));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
observer.observe(document.body, {
|
|
21
|
-
subtree: true,
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
package/lib/createInfoElement.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export default function CreateInfoEl(titleString) {
|
|
2
|
-
// Create a container span
|
|
3
|
-
const span = document.createElement("span");
|
|
4
|
-
span.style.position = "relative";
|
|
5
|
-
span.style.display = "inline-block"; // Ensure proper placement
|
|
6
|
-
|
|
7
|
-
// Create the "i" icon
|
|
8
|
-
const icon = document.createElement("i");
|
|
9
|
-
icon.classList.add("fa", "fa-solid", "fa-info-circle");
|
|
10
|
-
icon.setAttribute("aria-label", "Info"); // For accessibility
|
|
11
|
-
icon.style.cursor = "pointer"; // Ensure it's clear it's interactive
|
|
12
|
-
|
|
13
|
-
// Create the flyout content
|
|
14
|
-
const flyoutContent = document.createElement("div");
|
|
15
|
-
flyoutContent.innerHTML = titleString;
|
|
16
|
-
flyoutContent.style.display = "none";
|
|
17
|
-
flyoutContent.style.position = "absolute";
|
|
18
|
-
flyoutContent.style.top = "100%";
|
|
19
|
-
flyoutContent.style.left = "0";
|
|
20
|
-
flyoutContent.style.backgroundColor = "#f9f9f9";
|
|
21
|
-
flyoutContent.style.padding = "10px";
|
|
22
|
-
flyoutContent.style.border = "1px solid #ddd";
|
|
23
|
-
flyoutContent.style.zIndex = "1";
|
|
24
|
-
flyoutContent.style.width = "max-content"; // Default for larger screens
|
|
25
|
-
|
|
26
|
-
// Responsive Design Adjustments
|
|
27
|
-
flyoutContent.style.maxWidth = "90vw"; // Ensure it doesn't overflow on mobile
|
|
28
|
-
flyoutContent.style.boxShadow = "0px 4px 8px rgba(0, 0, 0, 0.1)"; // Add shadow for clarity
|
|
29
|
-
flyoutContent.style.borderRadius = "4px"; // Make it more modern with rounded corners
|
|
30
|
-
|
|
31
|
-
// Append the icon and flyout content to the container
|
|
32
|
-
span.appendChild(icon);
|
|
33
|
-
span.appendChild(flyoutContent);
|
|
34
|
-
|
|
35
|
-
// Event listeners for desktop (hover)
|
|
36
|
-
icon.addEventListener("mouseenter", () => {
|
|
37
|
-
flyoutContent.style.display = "block";
|
|
38
|
-
});
|
|
39
|
-
icon.addEventListener("mouseleave", () => {
|
|
40
|
-
flyoutContent.style.display = "none";
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Event listeners for mobile (touch)
|
|
44
|
-
icon.addEventListener("touchstart", (event) => {
|
|
45
|
-
event.preventDefault(); // Prevent triggering other touch events like click
|
|
46
|
-
if (flyoutContent.style.display === "none") {
|
|
47
|
-
flyoutContent.style.display = "block";
|
|
48
|
-
} else {
|
|
49
|
-
flyoutContent.style.display = "none";
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Optional: Add an "x" button or click-away to close the flyout on mobile
|
|
54
|
-
document.body.addEventListener("click", (event) => {
|
|
55
|
-
if (!span.contains(event.target)) {
|
|
56
|
-
flyoutContent.style.display = "none"; // Hide if clicked outside
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Return the span element which holds the icon and flyout content
|
|
61
|
-
return span;
|
|
62
|
-
}
|
package/lib/safeAjax.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default function safeAjax(ajaxOptions) {
|
|
2
|
-
var deferredAjax = $.Deferred();
|
|
3
|
-
|
|
4
|
-
// shell is only available via runtime in a PowerPages portal
|
|
5
|
-
//eslint-disable-next-line
|
|
6
|
-
shell
|
|
7
|
-
.getTokenDeferred()
|
|
8
|
-
.done(function (token) {
|
|
9
|
-
// add headers for AJAX
|
|
10
|
-
if (!ajaxOptions.headers) {
|
|
11
|
-
$.extend(ajaxOptions, {
|
|
12
|
-
headers: {
|
|
13
|
-
__RequestVerificationToken: token,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
} else {
|
|
17
|
-
ajaxOptions.headers["__RequestVerificationToken"] = token;
|
|
18
|
-
}
|
|
19
|
-
$.ajax(ajaxOptions)
|
|
20
|
-
.done(function (data, textStatus, jqXHR) {
|
|
21
|
-
//eslint-disable-next-line
|
|
22
|
-
validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
|
|
23
|
-
})
|
|
24
|
-
.fail(deferredAjax.reject); //AJAX
|
|
25
|
-
})
|
|
26
|
-
.fail(function () {
|
|
27
|
-
deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return deferredAjax.promise();
|
|
31
|
-
}
|
package/webpack.config.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
// Define multiple entry points
|
|
6
|
-
entry: {
|
|
7
|
-
investorDetails: "./JavaScript/Investor/InvestorDetails.basicform.js",
|
|
8
|
-
},
|
|
9
|
-
output: {
|
|
10
|
-
// Set the output filename pattern and location
|
|
11
|
-
filename: "[name].bundle.js", // [name] will be replaced by entry key
|
|
12
|
-
path: path.resolve(__dirname, "./dist"), // Output directory
|
|
13
|
-
},
|
|
14
|
-
mode: "production", // Set the build mode
|
|
15
|
-
module: {
|
|
16
|
-
rules: [
|
|
17
|
-
{
|
|
18
|
-
test: /\.js$/, // Transpile JavaScript files
|
|
19
|
-
exclude: /node_modules/,
|
|
20
|
-
use: {
|
|
21
|
-
loader: "babel-loader",
|
|
22
|
-
options: {
|
|
23
|
-
presets: ["@babel/preset-env"],
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
};
|