hoodcms 5.0.7 → 5.0.11
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/README.md +8 -6
- package/dist/js/admin.js +5 -5
- package/dist/js/app.js +4 -11
- package/dist/js/core/Alerts.d.ts +22 -0
- package/dist/js/core/Alerts.js +151 -0
- package/dist/js/core/BaseSite.d.ts +6 -0
- package/dist/js/core/BaseSite.js +14 -0
- package/dist/js/core/ColorPicker.d.ts +5 -0
- package/dist/js/core/ColorPicker.js +71 -0
- package/dist/js/core/DataList.d.ts +35 -0
- package/dist/js/core/DataList.js +56 -0
- package/dist/js/core/Editors.d.ts +16 -0
- package/dist/js/core/Editors.js +137 -0
- package/dist/js/core/Handlers.d.ts +47 -0
- package/dist/js/core/Handlers.js +160 -0
- package/dist/js/core/Helpers.d.ts +8 -0
- package/dist/js/core/Helpers.js +50 -0
- package/dist/js/core/HoodApi.d.ts +25 -0
- package/dist/js/core/HoodApi.js +22 -0
- package/dist/js/core/Inline.d.ts +27 -0
- package/dist/js/core/Inline.js +63 -0
- package/dist/js/core/Loader.d.ts +5 -0
- package/dist/js/core/Loader.js +13 -0
- package/dist/js/core/Media.d.ts +113 -0
- package/dist/js/core/Media.js +363 -0
- package/dist/js/core/Modal.d.ts +35 -0
- package/dist/js/core/Modal.js +69 -0
- package/dist/js/core/RandomStringGenerator.d.ts +11 -0
- package/dist/js/core/RandomStringGenerator.js +23 -0
- package/dist/js/core/Response.d.ts +20 -0
- package/dist/js/core/Response.js +13 -0
- package/dist/js/core/Uploader.d.ts +7 -0
- package/dist/js/core/Uploader.js +134 -0
- package/dist/js/core/Validator.d.ts +27 -0
- package/dist/js/core/Validator.js +80 -0
- package/dist/js/extensions/jqueryExtensions.d.ts +11 -0
- package/dist/js/extensions/jqueryExtensions.js +99 -0
- package/dist/js/extensions/numberExtensions.d.ts +8 -0
- package/dist/js/extensions/numberExtensions.js +19 -0
- package/dist/js/extensions/stringExtensions.d.ts +12 -0
- package/dist/js/extensions/stringExtensions.js +49 -0
- package/dist/js/index.d.ts +23 -0
- package/dist/js/index.js +23 -0
- package/dist/js/interfaces/KeyValue.d.ts +4 -0
- package/dist/js/interfaces/KeyValue.js +1 -0
- package/dist/js/login.js +1 -1
- package/dist/js/models/Content.d.ts +50 -0
- package/dist/js/models/Content.js +1 -0
- package/dist/js/models/Property.d.ts +9 -0
- package/dist/js/models/Property.js +2 -0
- package/dist/js/models/Users.d.ts +7 -0
- package/dist/js/models/Users.js +2 -0
- package/package.json +58 -55
- package/src/css/admin.css.map +1 -1
- package/src/css/editor.css.map +1 -1
- package/src/css/install.css.map +1 -1
- package/src/css/login.css.map +1 -1
- package/src/js/admin.js +231 -221
- package/src/js/admin.js.map +1 -1
- package/src/js/app.js +12 -30254
- package/src/js/app.js.map +1 -1
- package/src/js/login.js +1 -1
- package/src/scss/admin.scss +2 -6
- package/src/scss/app.scss +2 -2
- package/src/scss/editor.scss +2 -3
- package/src/scss/install.scss +1 -1
- package/src/scss/login.scss +2 -16
- package/src/ts/admin.ts +2 -6
- package/src/ts/app.ts +0 -2
- package/src/ts/core/BaseSite.ts +21 -0
- package/src/ts/core/Handlers.ts +0 -2
- package/src/ts/core/Helpers.ts +4 -0
- package/src/ts/index.ts +26 -0
- package/src/ts/hood.ts +0 -5
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SweetAlertOptions, SweetAlertResult } from 'sweetalert2';
|
|
2
|
+
import 'jquery-toast-plugin';
|
|
3
|
+
export declare class Alerts {
|
|
4
|
+
static log(message: any, type?: 'message' | 'error' | 'warning' | 'info'): void;
|
|
5
|
+
static error(message: string, title?: string, hideAfter?: number): void;
|
|
6
|
+
static warning(message: string, title?: string, hideAfter?: number): void;
|
|
7
|
+
static message(message: string, title?: string, hideAfter?: number): void;
|
|
8
|
+
static success(message: string, title?: string, hideAfter?: number): void;
|
|
9
|
+
static alert(message: string, title?: string, icon?: string, hideAfter?: number): void;
|
|
10
|
+
static sweetAlert(options: SweetAlertOptions, callback: (result: SweetAlertResult<any>) => void): void;
|
|
11
|
+
static confirm(options: SweetAlertOptions, callback: (result: SweetAlertResult<any>) => void): void;
|
|
12
|
+
static prompt(options: SweetAlertOptions, callback: (result: SweetAlertResult<any>) => void): void;
|
|
13
|
+
log(message: string, type?: 'message' | 'error' | 'warning' | 'info'): void;
|
|
14
|
+
error(message: string, title?: string, hideAfter?: number): void;
|
|
15
|
+
warning(message: string, title?: string, hideAfter?: number): void;
|
|
16
|
+
message(message: string, title?: string, hideAfter?: number): void;
|
|
17
|
+
success(message: string, title?: string, hideAfter?: number): void;
|
|
18
|
+
alert(message: string, title?: string, icon?: string, hideAfter?: number): void;
|
|
19
|
+
sweetAlert(options: SweetAlertOptions, callback: (result: SweetAlertResult<any>) => void): void;
|
|
20
|
+
confirm(options: SweetAlertOptions, callback: (result: SweetAlertResult<any>) => void): void;
|
|
21
|
+
prompt(options: SweetAlertOptions, callback: (result: SweetAlertResult<any>) => void): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import Swal from 'sweetalert2';
|
|
2
|
+
import 'jquery-toast-plugin';
|
|
3
|
+
const BootstrapSwal = Swal.mixin({
|
|
4
|
+
customClass: {
|
|
5
|
+
confirmButton: 'btn btn-success m-1 px-3',
|
|
6
|
+
cancelButton: 'btn btn-danger m-1 px-3'
|
|
7
|
+
},
|
|
8
|
+
buttonsStyling: false
|
|
9
|
+
});
|
|
10
|
+
export class Alerts {
|
|
11
|
+
static log(message, type = 'message') {
|
|
12
|
+
if (!document.body.classList.contains('dev-mode')) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
switch (type) {
|
|
16
|
+
case 'error':
|
|
17
|
+
console.error(message);
|
|
18
|
+
break;
|
|
19
|
+
case 'message':
|
|
20
|
+
console.log(message);
|
|
21
|
+
break;
|
|
22
|
+
case 'warning':
|
|
23
|
+
console.warn(message);
|
|
24
|
+
break;
|
|
25
|
+
case 'info':
|
|
26
|
+
console.info(message);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
static error(message, title = null, hideAfter = null) {
|
|
31
|
+
$.toast({
|
|
32
|
+
heading: title,
|
|
33
|
+
text: message,
|
|
34
|
+
icon: 'error',
|
|
35
|
+
position: 'bottom-left',
|
|
36
|
+
loader: false,
|
|
37
|
+
bgColor: '#d0100b',
|
|
38
|
+
textColor: 'white',
|
|
39
|
+
hideAfter: hideAfter
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
static warning(message, title = null, hideAfter = null) {
|
|
43
|
+
$.toast({
|
|
44
|
+
heading: title,
|
|
45
|
+
text: message,
|
|
46
|
+
icon: 'error',
|
|
47
|
+
position: 'bottom-left',
|
|
48
|
+
loader: false,
|
|
49
|
+
bgColor: '#ef9007',
|
|
50
|
+
textColor: 'white',
|
|
51
|
+
hideAfter: hideAfter
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
static message(message, title = null, hideAfter = null) {
|
|
55
|
+
$.toast({
|
|
56
|
+
heading: title,
|
|
57
|
+
text: message,
|
|
58
|
+
icon: 'error',
|
|
59
|
+
position: 'bottom-left',
|
|
60
|
+
loader: false,
|
|
61
|
+
bgColor: '#222222',
|
|
62
|
+
textColor: 'white',
|
|
63
|
+
hideAfter: hideAfter
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
static success(message, title = null, hideAfter = null) {
|
|
67
|
+
$.toast({
|
|
68
|
+
heading: title,
|
|
69
|
+
text: message,
|
|
70
|
+
icon: 'error',
|
|
71
|
+
position: 'bottom-left',
|
|
72
|
+
loader: false,
|
|
73
|
+
bgColor: '#28a745',
|
|
74
|
+
textColor: 'white',
|
|
75
|
+
hideAfter: hideAfter
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
static alert(message, title = null, icon = 'info', hideAfter = 10000) {
|
|
79
|
+
switch (icon) {
|
|
80
|
+
case 'error':
|
|
81
|
+
Alerts.error(message, title, hideAfter);
|
|
82
|
+
break;
|
|
83
|
+
case 'warning':
|
|
84
|
+
Alerts.warning(message, title, hideAfter);
|
|
85
|
+
break;
|
|
86
|
+
case 'info':
|
|
87
|
+
Alerts.message(message, title, hideAfter);
|
|
88
|
+
break;
|
|
89
|
+
case 'success':
|
|
90
|
+
Alerts.success(message, title, hideAfter);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
static sweetAlert(options, callback) {
|
|
95
|
+
BootstrapSwal.fire(options).then(function (result) {
|
|
96
|
+
callback(result);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
static confirm(options, callback) {
|
|
100
|
+
let baseOptions = {
|
|
101
|
+
showCancelButton: true,
|
|
102
|
+
footer: null,
|
|
103
|
+
title: 'Are you sure?',
|
|
104
|
+
html: 'Are you sure you want to do this?',
|
|
105
|
+
confirmButtonText: 'Ok',
|
|
106
|
+
cancelButtonText: 'Cancel'
|
|
107
|
+
};
|
|
108
|
+
Alerts.sweetAlert(Object.assign(Object.assign({}, baseOptions), options), callback);
|
|
109
|
+
}
|
|
110
|
+
static prompt(options, callback) {
|
|
111
|
+
let baseOptions = {
|
|
112
|
+
input: 'text',
|
|
113
|
+
inputAttributes: {
|
|
114
|
+
autocapitalize: 'off'
|
|
115
|
+
},
|
|
116
|
+
showCancelButton: true,
|
|
117
|
+
icon: 'info',
|
|
118
|
+
footer: '<span class="text-warning"><i class="fa fa-exclamation-triangle"></i> This cannot be undone.</span>',
|
|
119
|
+
confirmButtonText: 'Ok',
|
|
120
|
+
cancelButtonText: 'Cancel'
|
|
121
|
+
};
|
|
122
|
+
Alerts.sweetAlert(Object.assign(Object.assign({}, baseOptions), options), callback);
|
|
123
|
+
}
|
|
124
|
+
log(message, type = 'message') {
|
|
125
|
+
Alerts.log(message, type);
|
|
126
|
+
}
|
|
127
|
+
error(message, title = null, hideAfter = null) {
|
|
128
|
+
Alerts.error(message, title, hideAfter);
|
|
129
|
+
}
|
|
130
|
+
warning(message, title = null, hideAfter = null) {
|
|
131
|
+
Alerts.warning(message, title, hideAfter);
|
|
132
|
+
}
|
|
133
|
+
message(message, title = null, hideAfter = null) {
|
|
134
|
+
Alerts.message(message, title, hideAfter);
|
|
135
|
+
}
|
|
136
|
+
success(message, title = null, hideAfter = null) {
|
|
137
|
+
Alerts.success(message, title, hideAfter);
|
|
138
|
+
}
|
|
139
|
+
alert(message, title = null, icon = 'info', hideAfter = 10000) {
|
|
140
|
+
Alerts.alert(message, message, icon, hideAfter);
|
|
141
|
+
}
|
|
142
|
+
sweetAlert(options, callback) {
|
|
143
|
+
Alerts.sweetAlert(options, callback);
|
|
144
|
+
}
|
|
145
|
+
confirm(options, callback) {
|
|
146
|
+
Alerts.confirm(options, callback);
|
|
147
|
+
}
|
|
148
|
+
prompt(options, callback) {
|
|
149
|
+
Alerts.prompt(options, callback);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import Pickr from '@simonwep/pickr';
|
|
2
|
+
import '@simonwep/pickr';
|
|
3
|
+
export class ColorPickers {
|
|
4
|
+
constructor() {
|
|
5
|
+
}
|
|
6
|
+
loadColorPickers(tag = '.color-picker') {
|
|
7
|
+
let updateColorFieldValue = function (color, eventSource, instance) {
|
|
8
|
+
let elemId = $(instance._root.button).parent().data('target');
|
|
9
|
+
$(instance._root.button).parent().css({ 'background-color': color.toHEXA().toString() });
|
|
10
|
+
let colorHex = instance.getColor().toHEXA();
|
|
11
|
+
var result = "";
|
|
12
|
+
for (let i = colorHex.length - 1; i >= 0; i--) {
|
|
13
|
+
result = colorHex[i] + result;
|
|
14
|
+
}
|
|
15
|
+
$(elemId).val('#' + result);
|
|
16
|
+
$(elemId).change();
|
|
17
|
+
};
|
|
18
|
+
var pickrs = [];
|
|
19
|
+
// Simple example, see optional options for more configuration.
|
|
20
|
+
$(tag).each(function (index, elem) {
|
|
21
|
+
let lockOpacity = true;
|
|
22
|
+
if ($(this).data('opacity') == 'true') {
|
|
23
|
+
lockOpacity = false;
|
|
24
|
+
}
|
|
25
|
+
let pickr = Pickr.create({
|
|
26
|
+
el: elem.children[0],
|
|
27
|
+
appClass: 'custom-class',
|
|
28
|
+
theme: 'monolith',
|
|
29
|
+
useAsButton: true,
|
|
30
|
+
default: $(this).data('default') || 'none',
|
|
31
|
+
lockOpacity: lockOpacity,
|
|
32
|
+
defaultRepresentation: 'HEXA',
|
|
33
|
+
position: 'bottom-end',
|
|
34
|
+
components: {
|
|
35
|
+
opacity: true,
|
|
36
|
+
hue: true,
|
|
37
|
+
interaction: {
|
|
38
|
+
hex: false,
|
|
39
|
+
rgba: false,
|
|
40
|
+
hsva: false,
|
|
41
|
+
input: true,
|
|
42
|
+
clear: true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
.on('init', function (instance) {
|
|
47
|
+
let elemId = $(instance._root.button).parent().data('target');
|
|
48
|
+
let value = $(elemId).val();
|
|
49
|
+
$(instance._root.button).parent().on('click', $.proxy(function () {
|
|
50
|
+
this.show();
|
|
51
|
+
}, instance));
|
|
52
|
+
$(elemId).on('click', $.proxy(function () {
|
|
53
|
+
this.show();
|
|
54
|
+
}, instance));
|
|
55
|
+
if (value) {
|
|
56
|
+
instance.setColor(value);
|
|
57
|
+
updateColorFieldValue(instance.getColor(), null, instance);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.on('clear', function (instance) {
|
|
61
|
+
let elemId = $(instance._root.button).parent().data('target');
|
|
62
|
+
instance.setColor('transparent');
|
|
63
|
+
updateColorFieldValue(instance.getColor(), null, instance);
|
|
64
|
+
$(elemId).val('');
|
|
65
|
+
$(elemId).change();
|
|
66
|
+
})
|
|
67
|
+
.on('change', updateColorFieldValue);
|
|
68
|
+
pickrs.push(pickr);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface HTMLElement {
|
|
3
|
+
hoodDataList: DataList;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export interface DataListOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Called before the data is fetched.
|
|
9
|
+
*/
|
|
10
|
+
onLoad?: (sender?: HTMLElement) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Called before the fetched HTML is rendered to the list. Must return the data back to datalist to render.
|
|
13
|
+
*/
|
|
14
|
+
onRender?: (html: string, sender?: HTMLElement) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Called when loading and rendering is complete.
|
|
17
|
+
*/
|
|
18
|
+
onComplete?: (html: string, sender?: HTMLElement) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Called when an error occurs.
|
|
21
|
+
*/
|
|
22
|
+
onError?: (jqXHR: any, textStatus: any, errorThrown: any) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Attach a data list feed to an HTML element. The element must have a data-url attribute to connect to a feed.
|
|
26
|
+
*/
|
|
27
|
+
export declare class DataList {
|
|
28
|
+
element: HTMLElement;
|
|
29
|
+
options: DataListOptions;
|
|
30
|
+
/**
|
|
31
|
+
* @param element The datalist element. The element must have a data-url attribute to connect to a feed.
|
|
32
|
+
*/
|
|
33
|
+
constructor(element: HTMLElement, options: DataListOptions);
|
|
34
|
+
reload(this: DataList, url?: URL): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Alerts } from "./Alerts";
|
|
2
|
+
import { Inline } from "./Inline";
|
|
3
|
+
/**
|
|
4
|
+
* Attach a data list feed to an HTML element. The element must have a data-url attribute to connect to a feed.
|
|
5
|
+
*/
|
|
6
|
+
export class DataList {
|
|
7
|
+
/**
|
|
8
|
+
* @param element The datalist element. The element must have a data-url attribute to connect to a feed.
|
|
9
|
+
*/
|
|
10
|
+
constructor(element, options) {
|
|
11
|
+
this.element = element;
|
|
12
|
+
this.element.hoodDataList = this;
|
|
13
|
+
if (typeof (element) == 'undefined' || element == null) {
|
|
14
|
+
Alerts.log('Could not DataList to element, element does not exist.', 'error');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.options = Object.assign(Object.assign({}, this.options), options);
|
|
18
|
+
if ($(this.element).hasClass('query')) {
|
|
19
|
+
let pageUrl = $(this.element).data('url') + window.location.search;
|
|
20
|
+
$(this.element).attr('data-url', pageUrl);
|
|
21
|
+
$(this.element).data('url', pageUrl);
|
|
22
|
+
}
|
|
23
|
+
if (!$(this.element).hasClass('refresh-only')) {
|
|
24
|
+
var listUrl = document.createElement('a');
|
|
25
|
+
listUrl.href = $(this.element).data('url');
|
|
26
|
+
this.reload(new URL(listUrl.href));
|
|
27
|
+
}
|
|
28
|
+
$(this.element).on('click', '.pagination a, a.hood-inline-list-target', function (e) {
|
|
29
|
+
e.preventDefault();
|
|
30
|
+
var url = document.createElement('a');
|
|
31
|
+
url.href = e.currentTarget.href;
|
|
32
|
+
var listUrl = document.createElement('a');
|
|
33
|
+
listUrl.href = $(this.element).data('url');
|
|
34
|
+
listUrl.search = url.search;
|
|
35
|
+
this.reload(new URL(listUrl.href));
|
|
36
|
+
}.bind(this));
|
|
37
|
+
$('body').on('submit', `form.inline[data-target="#${this.element.id}"]`, function (e) {
|
|
38
|
+
e.preventDefault();
|
|
39
|
+
let $form = $(e.currentTarget);
|
|
40
|
+
var listUrl = document.createElement('a');
|
|
41
|
+
listUrl.href = $(this.element).data('url');
|
|
42
|
+
listUrl.search = "?" + $form.serialize();
|
|
43
|
+
this.reload(new URL(listUrl.href));
|
|
44
|
+
}.bind(this));
|
|
45
|
+
}
|
|
46
|
+
reload(url = null) {
|
|
47
|
+
if (url) {
|
|
48
|
+
if (history.pushState && $(this.element).hasClass('query')) {
|
|
49
|
+
let newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + (url.href.contains('?') ? "?" + url.href.substring(url.href.indexOf('?') + 1) : '');
|
|
50
|
+
window.history.pushState({ path: newurl }, '', newurl);
|
|
51
|
+
}
|
|
52
|
+
$(this.element).data('url', url);
|
|
53
|
+
}
|
|
54
|
+
Inline.load(this.element, Object.assign({}, this.options));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MediaService } from './Media';
|
|
2
|
+
import { ModalController } from './Modal';
|
|
3
|
+
export declare interface EditorOptions {
|
|
4
|
+
linkClasses?: any;
|
|
5
|
+
imageClasses?: any;
|
|
6
|
+
}
|
|
7
|
+
export declare class Editors {
|
|
8
|
+
options: EditorOptions;
|
|
9
|
+
constructor(options?: EditorOptions);
|
|
10
|
+
richTextEditors(): void;
|
|
11
|
+
mediaModal: ModalController;
|
|
12
|
+
list: HTMLElement;
|
|
13
|
+
service: MediaService;
|
|
14
|
+
currentEditor: JQuery<HTMLElement>;
|
|
15
|
+
setupCommands(editor: any): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import tinymce from 'tinymce/tinymce';
|
|
2
|
+
import { MediaService } from './Media';
|
|
3
|
+
import { ModalController } from './Modal';
|
|
4
|
+
export class Editors {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = {
|
|
7
|
+
linkClasses: [
|
|
8
|
+
{ title: 'None', value: '' },
|
|
9
|
+
{ title: 'Button link', value: 'btn btn-default' },
|
|
10
|
+
{ title: 'Theme coloured button link', value: 'btn btn-primary' },
|
|
11
|
+
{ title: 'Popup image/video', value: 'colorbox-iframe' },
|
|
12
|
+
{ title: 'Button popup link', value: 'btn btn-default colorbox-iframe' },
|
|
13
|
+
{ title: 'Theme coloured button popup link', value: 'btn btn-primary colorbox-iframe' },
|
|
14
|
+
{ title: 'Large link', value: 'font-lg' },
|
|
15
|
+
{ title: 'Large button link', value: 'btn btn-default btn-lg' },
|
|
16
|
+
{ title: 'Large theme coloured button link', value: 'btn btn-primary btn-lg' },
|
|
17
|
+
{ title: 'Large popup image/video', value: 'font-lg colorbox-iframe' },
|
|
18
|
+
{ title: 'Large Button popup link', value: 'btn btn-default btn-lg colorbox-iframe' },
|
|
19
|
+
{ title: 'Theme coloured button popup link', value: 'btn btn-primary btn-lg colorbox-iframe' }
|
|
20
|
+
],
|
|
21
|
+
imageClasses: [
|
|
22
|
+
{ title: 'None', value: '' },
|
|
23
|
+
{ title: 'Full Width', value: 'user-image full' },
|
|
24
|
+
{ title: 'Left Aligned', value: 'user-image left' },
|
|
25
|
+
{ title: 'Centered', value: 'user-image center' },
|
|
26
|
+
{ title: 'Right Aligned', value: 'user-image right' },
|
|
27
|
+
{ title: 'Inline with text, top aligned', value: 'user-image inline top' },
|
|
28
|
+
{ title: 'Inline with text, middle aligned', value: 'user-image inline' },
|
|
29
|
+
{ title: 'Inline with text, bottom aligned', value: 'user-image inline bottom' },
|
|
30
|
+
{ title: 'Pulled Left', value: 'user-image pull-left' },
|
|
31
|
+
{ title: 'Pulled Right', value: 'user-image pull-right' },
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
this.options = Object.assign(Object.assign({}, this.options), options);
|
|
35
|
+
}
|
|
36
|
+
richTextEditors() {
|
|
37
|
+
tinymce.init({
|
|
38
|
+
selector: '.tinymce-full',
|
|
39
|
+
height: 150,
|
|
40
|
+
menubar: false,
|
|
41
|
+
plugins: [
|
|
42
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
43
|
+
'searchreplace visualblocks code fullscreen',
|
|
44
|
+
'insertdatetime media contextmenu paste code textcolor'
|
|
45
|
+
],
|
|
46
|
+
toolbar: "fullscreen | styleselect forecolor backcolor | hoodimage link media image | bold italic | alignleft aligncenter alignright | bullist numlist | table | undo redo",
|
|
47
|
+
link_class_list: this.options.linkClasses,
|
|
48
|
+
image_class_list: this.options.imageClasses,
|
|
49
|
+
setup: this.setupCommands.bind(this),
|
|
50
|
+
image_dimensions: false,
|
|
51
|
+
content_css: [
|
|
52
|
+
'/dist/css/editor.css'
|
|
53
|
+
],
|
|
54
|
+
});
|
|
55
|
+
tinymce.init({
|
|
56
|
+
selector: '.tinymce-simple',
|
|
57
|
+
height: 150,
|
|
58
|
+
plugins: [
|
|
59
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
60
|
+
'searchreplace visualblocks code fullscreen',
|
|
61
|
+
'insertdatetime media contextmenu paste code'
|
|
62
|
+
],
|
|
63
|
+
menubar: false,
|
|
64
|
+
toolbar: 'fullscreen | bold italic | bullist numlist | undo redo | link',
|
|
65
|
+
link_class_list: this.options.linkClasses,
|
|
66
|
+
image_class_list: this.options.imageClasses,
|
|
67
|
+
setup: this.setupCommands.bind(this),
|
|
68
|
+
image_dimensions: false
|
|
69
|
+
});
|
|
70
|
+
tinymce.init({
|
|
71
|
+
selector: '.tinymce-full-content',
|
|
72
|
+
height: 500,
|
|
73
|
+
menubar: false,
|
|
74
|
+
plugins: [
|
|
75
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
76
|
+
'searchreplace visualblocks code fullscreen',
|
|
77
|
+
'insertdatetime media contextmenu paste code textcolor'
|
|
78
|
+
],
|
|
79
|
+
toolbar: "fullscreen | styleselect forecolor backcolor | hoodimage link media image | bold italic | alignleft aligncenter alignright | bullist numlist | table | undo redo",
|
|
80
|
+
link_class_list: this.options.linkClasses,
|
|
81
|
+
image_class_list: this.options.imageClasses,
|
|
82
|
+
setup: this.setupCommands.bind(this),
|
|
83
|
+
image_dimensions: false
|
|
84
|
+
});
|
|
85
|
+
tinymce.init({
|
|
86
|
+
selector: '.tinymce-simple-content',
|
|
87
|
+
height: 500,
|
|
88
|
+
plugins: [
|
|
89
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
90
|
+
'searchreplace visualblocks code fullscreen',
|
|
91
|
+
'insertdatetime media contextmenu paste code'
|
|
92
|
+
],
|
|
93
|
+
menubar: false,
|
|
94
|
+
toolbar: 'fullscreen | bold italic | bullist numlist | undo redo | link',
|
|
95
|
+
link_class_list: this.options.linkClasses,
|
|
96
|
+
image_class_list: this.options.imageClasses,
|
|
97
|
+
image_dimensions: false
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
setupCommands(editor) {
|
|
101
|
+
this.currentEditor = $('#' + editor.id);
|
|
102
|
+
if (this.currentEditor.data('hoodMediaList')) {
|
|
103
|
+
editor.addButton('hoodimage', {
|
|
104
|
+
text: 'Insert image...',
|
|
105
|
+
icon: false,
|
|
106
|
+
onclick: function (e) {
|
|
107
|
+
this.mediaModal = new ModalController({
|
|
108
|
+
onComplete: function (sender) {
|
|
109
|
+
this.list = document.getElementById('media-list');
|
|
110
|
+
this.service = new MediaService(this.list, {
|
|
111
|
+
action: 'insert',
|
|
112
|
+
url: this.currentEditor.data('hoodMediaList'),
|
|
113
|
+
targetEditor: editor,
|
|
114
|
+
size: this.currentEditor.data('hoodMediaSize'),
|
|
115
|
+
beforeAction: function (sender, mediaObject) {
|
|
116
|
+
}.bind(this),
|
|
117
|
+
onAction: function (sender, mediaObject) {
|
|
118
|
+
this.mediaModal.close();
|
|
119
|
+
}.bind(this),
|
|
120
|
+
onListLoad: (sender) => {
|
|
121
|
+
},
|
|
122
|
+
onListRender: (data) => {
|
|
123
|
+
return data;
|
|
124
|
+
},
|
|
125
|
+
onListComplete: (data) => {
|
|
126
|
+
},
|
|
127
|
+
onError: (jqXHR, textStatus, errorThrown) => {
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}.bind(this)
|
|
131
|
+
});
|
|
132
|
+
this.mediaModal.show(this.currentEditor.data('hoodMediaList'), e.currentTarget);
|
|
133
|
+
}.bind(this)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="jquery" />
|
|
2
|
+
export declare class Handlers {
|
|
3
|
+
constructor();
|
|
4
|
+
/**
|
|
5
|
+
* Initialise all default Hood CMS handlers.
|
|
6
|
+
*/
|
|
7
|
+
initDefaultHandlers(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Sets values of any selects that have the value set in data-selected, useful for
|
|
10
|
+
*/
|
|
11
|
+
initSelectValues(tag?: string): void;
|
|
12
|
+
initSelectValuesHandler(this: HTMLElement, index: number, element: HTMLElement): void;
|
|
13
|
+
/**
|
|
14
|
+
* Sets up any Hood Icon selector fields, requires the correct HTML setup.
|
|
15
|
+
*/
|
|
16
|
+
iconSelector(tag?: string): void;
|
|
17
|
+
iconSelectorHandler(this: HTMLElement, index: number, element: HTMLElement): void;
|
|
18
|
+
/**
|
|
19
|
+
* Submits the form when input is changed, mark inputs with .submit-on-change class.
|
|
20
|
+
*/
|
|
21
|
+
selectText(tag?: string): void;
|
|
22
|
+
selectTextHandler(this: HTMLInputElement): void;
|
|
23
|
+
/**
|
|
24
|
+
* Attaches handlers for default scrolling functions, scroll to top, scroll to target (with header.header offset calculated)
|
|
25
|
+
* and scroll to target direct (with no calculated offset).
|
|
26
|
+
*/
|
|
27
|
+
scrollHandlers(tag?: string): void;
|
|
28
|
+
scrollTop(this: HTMLAnchorElement, e: JQuery.ClickEvent): boolean;
|
|
29
|
+
scrollTarget(this: HTMLAnchorElement, e: JQuery.ClickEvent): void;
|
|
30
|
+
scrollTargetDirect(this: HTMLAnchorElement): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Compiles any selected checkboxes with matching data-hood-csv-input tags,
|
|
33
|
+
* then saves the CSV list of the values to the input given in the tag.
|
|
34
|
+
*/
|
|
35
|
+
checkboxToCsvInput(tag?: string): void;
|
|
36
|
+
checkboxToCsvInputHandler(this: HTMLInputElement, e: JQuery.ChangeEvent<HTMLElement>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Submits the form when input is changed, mark inputs with .submit-on-change class.
|
|
39
|
+
*/
|
|
40
|
+
submitOnChange(tag?: string): void;
|
|
41
|
+
submitOnChangeHandler(this: HTMLFormElement, e: JQuery.ChangeEvent): void;
|
|
42
|
+
/**
|
|
43
|
+
* Sets the value of the input [data-target] when clicked to the value in [data-value]
|
|
44
|
+
*/
|
|
45
|
+
setValueOnClick(tag?: string): void;
|
|
46
|
+
setValueOnClickHandler(this: HTMLElement): void;
|
|
47
|
+
}
|