hoodcms 6.0.7 → 6.0.10
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/dist/js/admin.js +2 -2
- package/dist/js/app.js +2 -2
- package/dist/js/app.property.js +2 -2
- package/dist/js/core/Media.js +1 -1
- package/dist/js/core/Validator.d.ts +2 -2
- package/dist/js/core/Validator.js +18 -19
- package/dist/js/extensions/jqueryExtensions.d.ts +3 -3
- package/dist/js/login.js +1 -1
- package/package.json +17 -17
- package/src/js/admin.js +20 -21
- package/src/js/admin.js.map +1 -1
- package/src/js/app.js +19 -20
- package/src/js/app.js.map +1 -1
- package/src/js/app.property.js +19 -20
- package/src/js/app.property.js.map +1 -1
- package/src/js/login.js +1 -1
- package/src/ts/core/Media.ts +1 -1
- package/src/ts/core/Validator.ts +108 -109
- package/src/ts/extensions/jqueryExtensions.ts +3 -3
package/src/ts/core/Media.ts
CHANGED
|
@@ -174,7 +174,7 @@ export class MediaService {
|
|
|
174
174
|
thumbnailHeight: 80,
|
|
175
175
|
parallelUploads: 5,
|
|
176
176
|
paramName: 'files',
|
|
177
|
-
acceptedFiles: $("#media-upload").data('types') || ".png,.jpg,.jpeg,.gif",
|
|
177
|
+
acceptedFiles: $("#media-upload").data('types') || ".png,.jpg,.jpeg,.gif,.pdf",
|
|
178
178
|
autoProcessQueue: true, // Make sure the files aren't queued until manually added
|
|
179
179
|
previewsContainer: false, // Define the container to display the previews
|
|
180
180
|
clickable: "#media-add", // Define the element that should be used as click trigger to select files.
|
package/src/ts/core/Validator.ts
CHANGED
|
@@ -3,120 +3,119 @@ import { Inline } from "./Inline";
|
|
|
3
3
|
import { Response } from "./Response";
|
|
4
4
|
|
|
5
5
|
export interface ValidatorOptions {
|
|
6
|
-
|
|
6
|
+
errorAlert?: string;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Called before the submit of the form data, you can return the data to be serialised.
|
|
10
|
+
*/
|
|
11
|
+
onSubmit?: (sender: Validator) => void;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Called when submit is complete.
|
|
15
|
+
*/
|
|
16
|
+
onComplete?: (data: Response, sender?: Validator) => void;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Called when an error occurs.
|
|
20
|
+
*/
|
|
21
|
+
onError?: (jqXHR: any, textStatus: any, errorThrown: any) => void;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
useAjax?: boolean;
|
|
23
|
+
serializationFunction?: () => string;
|
|
26
24
|
|
|
25
|
+
useAjax?: boolean;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
export class Validator {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
}
|
|
29
|
+
element: HTMLFormElement;
|
|
30
|
+
options: ValidatorOptions = {
|
|
31
|
+
errorAlert: "There are errors on the form, please check your answers and try again.",
|
|
32
|
+
useAjax: true,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param element The datalist element. The element must have a data-url attribute to connect to a feed.
|
|
37
|
+
*/
|
|
38
|
+
constructor(element: HTMLFormElement, options: ValidatorOptions) {
|
|
39
|
+
this.element = element;
|
|
40
|
+
if (!this.element) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this.options.serializationFunction = function (this: Validator) {
|
|
45
|
+
let rtn = $(this.element).serialize();
|
|
46
|
+
return rtn;
|
|
47
|
+
}.bind(this);
|
|
48
|
+
|
|
49
|
+
this.options = { ...this.options, ...options };
|
|
50
|
+
|
|
51
|
+
this.element.addEventListener(
|
|
52
|
+
"submit",
|
|
53
|
+
function (this: Validator, e: Event) {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
e.stopImmediatePropagation();
|
|
56
|
+
this.submitForm();
|
|
57
|
+
}.bind(this)
|
|
58
|
+
);
|
|
59
|
+
var tag = '[data-submit="#' + this.element.id + '"]';
|
|
60
|
+
let submitButtons = $(tag);
|
|
61
|
+
if (submitButtons) {
|
|
62
|
+
submitButtons.on(
|
|
63
|
+
"click",
|
|
64
|
+
function (this: Validator, e: Event) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
e.stopImmediatePropagation();
|
|
67
|
+
let exit = $(e.currentTarget).data("exit");
|
|
68
|
+
if (exit) {
|
|
69
|
+
$(this.element).find("input#exit").remove();
|
|
70
|
+
$("<input id='exit' />").attr("type", "hidden").attr("name", "exit").attr("value", "true").appendTo(this.element);
|
|
71
|
+
}
|
|
72
|
+
this.submitForm();
|
|
73
|
+
}.bind(this)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
submitForm() {
|
|
79
|
+
this.element.classList.add("was-validated");
|
|
80
|
+
if (this.element.checkValidity()) {
|
|
81
|
+
this.element.classList.add("loading");
|
|
82
|
+
|
|
83
|
+
let checkboxes = this.element.querySelector("input[type=checkbox]");
|
|
84
|
+
if (checkboxes) {
|
|
85
|
+
Array.prototype.slice.call(checkboxes).forEach(function (checkbox: HTMLInputElement) {
|
|
86
|
+
if ($(this).is(":checked")) {
|
|
87
|
+
$(this).val("true");
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.options.onSubmit) {
|
|
93
|
+
this.options.onSubmit(this);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this.options.useAjax) {
|
|
97
|
+
let formData = this.options.serializationFunction();
|
|
98
|
+
|
|
99
|
+
$.post(
|
|
100
|
+
this.element.action,
|
|
101
|
+
formData,
|
|
102
|
+
function (this: Validator, data: any) {
|
|
103
|
+
if (this.options.onComplete) {
|
|
104
|
+
this.options.onComplete(data, this);
|
|
105
|
+
}
|
|
106
|
+
}.bind(this)
|
|
107
|
+
)
|
|
108
|
+
.fail(this.options.onError ?? Inline.handleError)
|
|
109
|
+
.always(function (this: Validator) {
|
|
110
|
+
this.element.classList.remove("loading");
|
|
111
|
+
}.bind(this));
|
|
112
|
+
} else {
|
|
113
|
+
this.element.submit();
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
if (this.options.errorAlert) {
|
|
117
|
+
Alerts.error(this.options.errorAlert, null, 5000);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -4,9 +4,9 @@ import { Alerts } from '../core/Alerts';
|
|
|
4
4
|
declare global {
|
|
5
5
|
interface JQuery {
|
|
6
6
|
exists(): number;
|
|
7
|
-
restrictToSlug(): void;
|
|
8
|
-
restrictToPageSlug(): void;
|
|
9
|
-
restrictToMetaSlug(): void;
|
|
7
|
+
restrictToSlug(restrictPattern?: RegExp): void;
|
|
8
|
+
restrictToPageSlug(restrictPattern?: RegExp): void;
|
|
9
|
+
restrictToMetaSlug(restrictPattern?: RegExp): void;
|
|
10
10
|
characterCounter(): void;
|
|
11
11
|
warningAlert(): void;
|
|
12
12
|
}
|