hoodcms 5.0.6 → 5.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/README.md +8 -6
- package/dist/css/admin.css +1 -0
- package/dist/css/app.css +1 -0
- package/dist/css/button.css +1 -0
- package/dist/css/editor.css +1 -0
- package/dist/css/install.css +1 -0
- package/dist/css/login.css +1 -0
- package/dist/js/admin.js +24 -0
- package/dist/js/app.js +23 -0
- 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/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 +22 -0
- package/dist/js/index.js +22 -0
- package/dist/js/interfaces/KeyValue.d.ts +4 -0
- package/dist/js/interfaces/KeyValue.js +1 -0
- package/dist/js/login.js +7 -0
- 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/images/arrow.jpg +0 -0
- package/images/h-black.svg +1 -0
- package/images/h-white.svg +0 -0
- package/images/hood-cms-dark.png +0 -0
- package/images/hood-cms-dark.svg +1 -0
- package/images/hood-cms-white.png +0 -0
- package/images/hood-cms-white.svg +1 -0
- package/images/hood-cms.png +0 -0
- package/images/hood-logo.svg +1 -0
- package/images/hood-square-padded.png +0 -0
- package/images/hood-square.png +0 -0
- package/images/hood-white.svg +1 -0
- package/images/hood.svg +1 -0
- package/images/icons/audio.png +0 -0
- package/images/icons/excel.png +0 -0
- package/images/icons/file.png +0 -0
- package/images/icons/pdf.png +0 -0
- package/images/icons/photoshop.png +0 -0
- package/images/icons/powerpoint.png +0 -0
- package/images/icons/video.png +0 -0
- package/images/icons/word.png +0 -0
- package/images/loading.svg +1 -0
- package/images/no-avatar.jpg +0 -0
- package/images/no-image.jpg +0 -0
- package/images/og-share.jpg +0 -0
- package/package.json +58 -55
- package/src/css/admin.css +12382 -0
- package/src/css/admin.css.map +1 -0
- package/src/css/app.css +11923 -0
- package/src/css/app.css.map +1 -0
- package/src/css/button.css +72 -0
- package/src/css/button.css.map +1 -0
- package/src/css/editor.css +11124 -0
- package/src/css/editor.css.map +1 -0
- package/src/css/install.css +11471 -0
- package/src/css/install.css.map +1 -0
- package/src/css/login.css +11455 -0
- package/src/css/login.css.map +1 -0
- package/src/js/admin.js +2595 -0
- package/src/js/admin.js.map +1 -0
- package/src/js/app.js +1578 -0
- package/src/js/app.js.map +1 -0
- package/src/js/login.js +44 -0
- package/src/js/login.js.map +1 -0
- 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/index.ts +25 -0
- package/src/ts/hood.ts +0 -5
package/src/js/admin.js
ADDED
|
@@ -0,0 +1,2595 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* hoodcms v5.0.9
|
|
3
|
+
* A fully customisable content management system built in ASP.NET Core 5 & Bootstrap 5.
|
|
4
|
+
* Written by George Whysall, 2021
|
|
5
|
+
* Released under the GPL-3.0 License.
|
|
6
|
+
*/
|
|
7
|
+
(function (global, factory) {
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('bootstrap'), require('sweetalert2'), require('@simonwep/pickr'), require('tinymce/tinymce'), require('chart.js')) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define(['bootstrap', 'sweetalert2', '@simonwep/pickr', 'tinymce/tinymce', 'chart.js'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bootstrap, global.swal, global.Pickr, global.tinymce, global.chart_js));
|
|
11
|
+
})(this, (function (bootstrap, swal, Pickr, tinymce, chart_js) { 'use strict';
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
Object.keys(e).forEach(function (k) {
|
|
20
|
+
if (k !== 'default') {
|
|
21
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return e[k]; }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
n["default"] = e;
|
|
30
|
+
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var bootstrap__namespace = /*#__PURE__*/_interopNamespace(bootstrap);
|
|
34
|
+
var swal__default = /*#__PURE__*/_interopDefaultLegacy(swal);
|
|
35
|
+
var Pickr__default = /*#__PURE__*/_interopDefaultLegacy(Pickr);
|
|
36
|
+
var tinymce__default = /*#__PURE__*/_interopDefaultLegacy(tinymce);
|
|
37
|
+
|
|
38
|
+
/*! *****************************************************************************
|
|
39
|
+
Copyright (c) Microsoft Corporation.
|
|
40
|
+
|
|
41
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
42
|
+
purpose with or without fee is hereby granted.
|
|
43
|
+
|
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
45
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
46
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
47
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
48
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
49
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
50
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
51
|
+
***************************************************************************** */
|
|
52
|
+
/* global Reflect, Promise */
|
|
53
|
+
|
|
54
|
+
var extendStatics = function(d, b) {
|
|
55
|
+
extendStatics = Object.setPrototypeOf ||
|
|
56
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
57
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
58
|
+
return extendStatics(d, b);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function __extends(d, b) {
|
|
62
|
+
extendStatics(d, b);
|
|
63
|
+
function __() { this.constructor = d; }
|
|
64
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var __assign = function() {
|
|
68
|
+
__assign = Object.assign || function __assign(t) {
|
|
69
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
70
|
+
s = arguments[i];
|
|
71
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
72
|
+
}
|
|
73
|
+
return t;
|
|
74
|
+
};
|
|
75
|
+
return __assign.apply(this, arguments);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
"function"!=typeof Object.create&&(Object.create=function(t){function o(){}return o.prototype=t,new o}),function(t,o,i,s){var n={_positionClasses:["bottom-left","bottom-right","top-right","top-left","bottom-center","top-center","mid-center"],_defaultIcons:["success","error","info","warning"],init:function(o,i){this.prepareOptions(o,t.toast.options),this.process();},prepareOptions:function(o,i){var s={};"string"==typeof o||o instanceof Array?s.text=o:s=o,this.options=t.extend({},i,s);},process:function(){this.setup(),this.addToDom(),this.position(),this.bindToast(),this.animate();},setup:function(){var o="";if(this._toastEl=this._toastEl||t("<div></div>",{"class":"jq-toast-single"}),o+='<span class="jq-toast-loader"></span>',this.options.allowToastClose&&(o+='<span class="close-jq-toast-single">×</span>'),this.options.text instanceof Array){this.options.heading&&(o+='<h2 class="jq-toast-heading">'+this.options.heading+"</h2>"),o+='<ul class="jq-toast-ul">';for(var i=0;i<this.options.text.length;i++)o+='<li class="jq-toast-li" id="jq-toast-item-'+i+'">'+this.options.text[i]+"</li>";o+="</ul>";}else this.options.heading&&(o+='<h2 class="jq-toast-heading">'+this.options.heading+"</h2>"),o+=this.options.text;this._toastEl.html(o),this.options.bgColor!==!1&&this._toastEl.css("background-color",this.options.bgColor),this.options.textColor!==!1&&this._toastEl.css("color",this.options.textColor),this.options.textAlign&&this._toastEl.css("text-align",this.options.textAlign),this.options.icon!==!1&&(this._toastEl.addClass("jq-has-icon"),-1!==t.inArray(this.options.icon,this._defaultIcons)&&this._toastEl.addClass("jq-icon-"+this.options.icon)),this.options["class"]!==!1&&this._toastEl.addClass(this.options["class"]);},position:function(){"string"==typeof this.options.position&&-1!==t.inArray(this.options.position,this._positionClasses)?"bottom-center"===this.options.position?this._container.css({left:t(o).outerWidth()/2-this._container.outerWidth()/2,bottom:20}):"top-center"===this.options.position?this._container.css({left:t(o).outerWidth()/2-this._container.outerWidth()/2,top:20}):"mid-center"===this.options.position?this._container.css({left:t(o).outerWidth()/2-this._container.outerWidth()/2,top:t(o).outerHeight()/2-this._container.outerHeight()/2}):this._container.addClass(this.options.position):"object"==typeof this.options.position?this._container.css({top:this.options.position.top?this.options.position.top:"auto",bottom:this.options.position.bottom?this.options.position.bottom:"auto",left:this.options.position.left?this.options.position.left:"auto",right:this.options.position.right?this.options.position.right:"auto"}):this._container.addClass("bottom-left");},bindToast:function(){var t=this;this._toastEl.on("afterShown",function(){t.processLoader();}),this._toastEl.find(".close-jq-toast-single").on("click",function(o){o.preventDefault(),"fade"===t.options.showHideTransition?(t._toastEl.trigger("beforeHide"),t._toastEl.fadeOut(function(){t._toastEl.trigger("afterHidden");})):"slide"===t.options.showHideTransition?(t._toastEl.trigger("beforeHide"),t._toastEl.slideUp(function(){t._toastEl.trigger("afterHidden");})):(t._toastEl.trigger("beforeHide"),t._toastEl.hide(function(){t._toastEl.trigger("afterHidden");}));}),"function"==typeof this.options.beforeShow&&this._toastEl.on("beforeShow",function(){t.options.beforeShow();}),"function"==typeof this.options.afterShown&&this._toastEl.on("afterShown",function(){t.options.afterShown();}),"function"==typeof this.options.beforeHide&&this._toastEl.on("beforeHide",function(){t.options.beforeHide();}),"function"==typeof this.options.afterHidden&&this._toastEl.on("afterHidden",function(){t.options.afterHidden();});},addToDom:function(){var o=t(".jq-toast-wrap");if(0===o.length?(o=t("<div></div>",{"class":"jq-toast-wrap"}),t("body").append(o)):(!this.options.stack||isNaN(parseInt(this.options.stack,10)))&&o.empty(),o.find(".jq-toast-single:hidden").remove(),o.append(this._toastEl),this.options.stack&&!isNaN(parseInt(this.options.stack),10)){var i=o.find(".jq-toast-single").length,s=i-this.options.stack;s>0&&t(".jq-toast-wrap").find(".jq-toast-single").slice(0,s).remove();}this._container=o;},canAutoHide:function(){return this.options.hideAfter!==!1&&!isNaN(parseInt(this.options.hideAfter,10))},processLoader:function(){if(!this.canAutoHide()||this.options.loader===!1)return !1;var t=this._toastEl.find(".jq-toast-loader"),o=(this.options.hideAfter-400)/1e3+"s",i=this.options.loaderBg,s=t.attr("style")||"";s=s.substring(0,s.indexOf("-webkit-transition")),s+="-webkit-transition: width "+o+" ease-in; -o-transition: width "+o+" ease-in; transition: width "+o+" ease-in; background-color: "+i+";",t.attr("style",s).addClass("jq-toast-loaded");},animate:function(){var t=this;if(this._toastEl.hide(),this._toastEl.trigger("beforeShow"),"fade"===this.options.showHideTransition.toLowerCase()?this._toastEl.fadeIn(function(){t._toastEl.trigger("afterShown");}):"slide"===this.options.showHideTransition.toLowerCase()?this._toastEl.slideDown(function(){t._toastEl.trigger("afterShown");}):this._toastEl.show(function(){t._toastEl.trigger("afterShown");}),this.canAutoHide()){var t=this;o.setTimeout(function(){"fade"===t.options.showHideTransition.toLowerCase()?(t._toastEl.trigger("beforeHide"),t._toastEl.fadeOut(function(){t._toastEl.trigger("afterHidden");})):"slide"===t.options.showHideTransition.toLowerCase()?(t._toastEl.trigger("beforeHide"),t._toastEl.slideUp(function(){t._toastEl.trigger("afterHidden");})):(t._toastEl.trigger("beforeHide"),t._toastEl.hide(function(){t._toastEl.trigger("afterHidden");}));},this.options.hideAfter);}},reset:function(o){"all"===o?t(".jq-toast-wrap").remove():this._toastEl.remove();},update:function(t){this.prepareOptions(t,this.options),this.setup(),this.bindToast();}};t.toast=function(t){var o=Object.create(n);return o.init(t,this),{reset:function(t){o.reset(t);},update:function(t){o.update(t);}}},t.toast.options={text:"",heading:"",showHideTransition:"fade",allowToastClose:!0,hideAfter:3e3,loader:!0,loaderBg:"#9EC600",stack:5,position:"bottom-left",bgColor:!1,textColor:!1,textAlign:"left",icon:!1,beforeShow:function(){},afterShown:function(){},beforeHide:function(){},afterHidden:function(){}};}(jQuery,window);
|
|
79
|
+
|
|
80
|
+
var BootstrapSwal = swal__default["default"].mixin({
|
|
81
|
+
customClass: {
|
|
82
|
+
confirmButton: 'btn btn-success m-1 px-3',
|
|
83
|
+
cancelButton: 'btn btn-danger m-1 px-3'
|
|
84
|
+
},
|
|
85
|
+
buttonsStyling: false
|
|
86
|
+
});
|
|
87
|
+
var Alerts = /** @class */ (function () {
|
|
88
|
+
function Alerts() {
|
|
89
|
+
}
|
|
90
|
+
Alerts.log = function (message, type) {
|
|
91
|
+
if (type === void 0) { type = 'message'; }
|
|
92
|
+
if (!document.body.classList.contains('dev-mode')) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
switch (type) {
|
|
96
|
+
case 'error':
|
|
97
|
+
console.error(message);
|
|
98
|
+
break;
|
|
99
|
+
case 'message':
|
|
100
|
+
console.log(message);
|
|
101
|
+
break;
|
|
102
|
+
case 'warning':
|
|
103
|
+
console.warn(message);
|
|
104
|
+
break;
|
|
105
|
+
case 'info':
|
|
106
|
+
console.info(message);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
Alerts.error = function (message, title, hideAfter) {
|
|
111
|
+
if (title === void 0) { title = null; }
|
|
112
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
113
|
+
$.toast({
|
|
114
|
+
heading: title,
|
|
115
|
+
text: message,
|
|
116
|
+
icon: 'error',
|
|
117
|
+
position: 'bottom-left',
|
|
118
|
+
loader: false,
|
|
119
|
+
bgColor: '#d0100b',
|
|
120
|
+
textColor: 'white',
|
|
121
|
+
hideAfter: hideAfter
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
Alerts.warning = function (message, title, hideAfter) {
|
|
125
|
+
if (title === void 0) { title = null; }
|
|
126
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
127
|
+
$.toast({
|
|
128
|
+
heading: title,
|
|
129
|
+
text: message,
|
|
130
|
+
icon: 'error',
|
|
131
|
+
position: 'bottom-left',
|
|
132
|
+
loader: false,
|
|
133
|
+
bgColor: '#ef9007',
|
|
134
|
+
textColor: 'white',
|
|
135
|
+
hideAfter: hideAfter
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
Alerts.message = function (message, title, hideAfter) {
|
|
139
|
+
if (title === void 0) { title = null; }
|
|
140
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
141
|
+
$.toast({
|
|
142
|
+
heading: title,
|
|
143
|
+
text: message,
|
|
144
|
+
icon: 'error',
|
|
145
|
+
position: 'bottom-left',
|
|
146
|
+
loader: false,
|
|
147
|
+
bgColor: '#222222',
|
|
148
|
+
textColor: 'white',
|
|
149
|
+
hideAfter: hideAfter
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
Alerts.success = function (message, title, hideAfter) {
|
|
153
|
+
if (title === void 0) { title = null; }
|
|
154
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
155
|
+
$.toast({
|
|
156
|
+
heading: title,
|
|
157
|
+
text: message,
|
|
158
|
+
icon: 'error',
|
|
159
|
+
position: 'bottom-left',
|
|
160
|
+
loader: false,
|
|
161
|
+
bgColor: '#28a745',
|
|
162
|
+
textColor: 'white',
|
|
163
|
+
hideAfter: hideAfter
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
Alerts.alert = function (message, title, icon, hideAfter) {
|
|
167
|
+
if (title === void 0) { title = null; }
|
|
168
|
+
if (icon === void 0) { icon = 'info'; }
|
|
169
|
+
if (hideAfter === void 0) { hideAfter = 10000; }
|
|
170
|
+
switch (icon) {
|
|
171
|
+
case 'error':
|
|
172
|
+
Alerts.error(message, title, hideAfter);
|
|
173
|
+
break;
|
|
174
|
+
case 'warning':
|
|
175
|
+
Alerts.warning(message, title, hideAfter);
|
|
176
|
+
break;
|
|
177
|
+
case 'info':
|
|
178
|
+
Alerts.message(message, title, hideAfter);
|
|
179
|
+
break;
|
|
180
|
+
case 'success':
|
|
181
|
+
Alerts.success(message, title, hideAfter);
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
Alerts.sweetAlert = function (options, callback) {
|
|
186
|
+
BootstrapSwal.fire(options).then(function (result) {
|
|
187
|
+
callback(result);
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
Alerts.confirm = function (options, callback) {
|
|
191
|
+
var baseOptions = {
|
|
192
|
+
showCancelButton: true,
|
|
193
|
+
footer: null,
|
|
194
|
+
title: 'Are you sure?',
|
|
195
|
+
html: 'Are you sure you want to do this?',
|
|
196
|
+
confirmButtonText: 'Ok',
|
|
197
|
+
cancelButtonText: 'Cancel'
|
|
198
|
+
};
|
|
199
|
+
Alerts.sweetAlert(__assign(__assign({}, baseOptions), options), callback);
|
|
200
|
+
};
|
|
201
|
+
Alerts.prompt = function (options, callback) {
|
|
202
|
+
var baseOptions = {
|
|
203
|
+
input: 'text',
|
|
204
|
+
inputAttributes: {
|
|
205
|
+
autocapitalize: 'off'
|
|
206
|
+
},
|
|
207
|
+
showCancelButton: true,
|
|
208
|
+
icon: 'info',
|
|
209
|
+
footer: '<span class="text-warning"><i class="fa fa-exclamation-triangle"></i> This cannot be undone.</span>',
|
|
210
|
+
confirmButtonText: 'Ok',
|
|
211
|
+
cancelButtonText: 'Cancel'
|
|
212
|
+
};
|
|
213
|
+
Alerts.sweetAlert(__assign(__assign({}, baseOptions), options), callback);
|
|
214
|
+
};
|
|
215
|
+
Alerts.prototype.log = function (message, type) {
|
|
216
|
+
if (type === void 0) { type = 'message'; }
|
|
217
|
+
Alerts.log(message, type);
|
|
218
|
+
};
|
|
219
|
+
Alerts.prototype.error = function (message, title, hideAfter) {
|
|
220
|
+
if (title === void 0) { title = null; }
|
|
221
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
222
|
+
Alerts.error(message, title, hideAfter);
|
|
223
|
+
};
|
|
224
|
+
Alerts.prototype.warning = function (message, title, hideAfter) {
|
|
225
|
+
if (title === void 0) { title = null; }
|
|
226
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
227
|
+
Alerts.warning(message, title, hideAfter);
|
|
228
|
+
};
|
|
229
|
+
Alerts.prototype.message = function (message, title, hideAfter) {
|
|
230
|
+
if (title === void 0) { title = null; }
|
|
231
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
232
|
+
Alerts.message(message, title, hideAfter);
|
|
233
|
+
};
|
|
234
|
+
Alerts.prototype.success = function (message, title, hideAfter) {
|
|
235
|
+
if (title === void 0) { title = null; }
|
|
236
|
+
if (hideAfter === void 0) { hideAfter = null; }
|
|
237
|
+
Alerts.success(message, title, hideAfter);
|
|
238
|
+
};
|
|
239
|
+
Alerts.prototype.alert = function (message, title, icon, hideAfter) {
|
|
240
|
+
if (icon === void 0) { icon = 'info'; }
|
|
241
|
+
if (hideAfter === void 0) { hideAfter = 10000; }
|
|
242
|
+
Alerts.alert(message, message, icon, hideAfter);
|
|
243
|
+
};
|
|
244
|
+
Alerts.prototype.sweetAlert = function (options, callback) {
|
|
245
|
+
Alerts.sweetAlert(options, callback);
|
|
246
|
+
};
|
|
247
|
+
Alerts.prototype.confirm = function (options, callback) {
|
|
248
|
+
Alerts.confirm(options, callback);
|
|
249
|
+
};
|
|
250
|
+
Alerts.prototype.prompt = function (options, callback) {
|
|
251
|
+
Alerts.prompt(options, callback);
|
|
252
|
+
};
|
|
253
|
+
return Alerts;
|
|
254
|
+
}());
|
|
255
|
+
|
|
256
|
+
var ColorPickers = /** @class */ (function () {
|
|
257
|
+
function ColorPickers() {
|
|
258
|
+
}
|
|
259
|
+
ColorPickers.prototype.loadColorPickers = function (tag) {
|
|
260
|
+
if (tag === void 0) { tag = '.color-picker'; }
|
|
261
|
+
var updateColorFieldValue = function (color, eventSource, instance) {
|
|
262
|
+
var elemId = $(instance._root.button).parent().data('target');
|
|
263
|
+
$(instance._root.button).parent().css({ 'background-color': color.toHEXA().toString() });
|
|
264
|
+
var colorHex = instance.getColor().toHEXA();
|
|
265
|
+
var result = "";
|
|
266
|
+
for (var i = colorHex.length - 1; i >= 0; i--) {
|
|
267
|
+
result = colorHex[i] + result;
|
|
268
|
+
}
|
|
269
|
+
$(elemId).val('#' + result);
|
|
270
|
+
$(elemId).change();
|
|
271
|
+
};
|
|
272
|
+
// Simple example, see optional options for more configuration.
|
|
273
|
+
$(tag).each(function (index, elem) {
|
|
274
|
+
var lockOpacity = true;
|
|
275
|
+
if ($(this).data('opacity') == 'true') {
|
|
276
|
+
lockOpacity = false;
|
|
277
|
+
}
|
|
278
|
+
Pickr__default["default"].create({
|
|
279
|
+
el: elem.children[0],
|
|
280
|
+
appClass: 'custom-class',
|
|
281
|
+
theme: 'monolith',
|
|
282
|
+
useAsButton: true,
|
|
283
|
+
default: $(this).data('default') || 'none',
|
|
284
|
+
lockOpacity: lockOpacity,
|
|
285
|
+
defaultRepresentation: 'HEXA',
|
|
286
|
+
position: 'bottom-end',
|
|
287
|
+
components: {
|
|
288
|
+
opacity: true,
|
|
289
|
+
hue: true,
|
|
290
|
+
interaction: {
|
|
291
|
+
hex: false,
|
|
292
|
+
rgba: false,
|
|
293
|
+
hsva: false,
|
|
294
|
+
input: true,
|
|
295
|
+
clear: true
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
.on('init', function (instance) {
|
|
300
|
+
var elemId = $(instance._root.button).parent().data('target');
|
|
301
|
+
var value = $(elemId).val();
|
|
302
|
+
$(instance._root.button).parent().on('click', $.proxy(function () {
|
|
303
|
+
this.show();
|
|
304
|
+
}, instance));
|
|
305
|
+
$(elemId).on('click', $.proxy(function () {
|
|
306
|
+
this.show();
|
|
307
|
+
}, instance));
|
|
308
|
+
if (value) {
|
|
309
|
+
instance.setColor(value);
|
|
310
|
+
updateColorFieldValue(instance.getColor(), null, instance);
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
.on('clear', function (instance) {
|
|
314
|
+
var elemId = $(instance._root.button).parent().data('target');
|
|
315
|
+
instance.setColor('transparent');
|
|
316
|
+
updateColorFieldValue(instance.getColor(), null, instance);
|
|
317
|
+
$(elemId).val('');
|
|
318
|
+
$(elemId).change();
|
|
319
|
+
})
|
|
320
|
+
.on('change', updateColorFieldValue);
|
|
321
|
+
});
|
|
322
|
+
};
|
|
323
|
+
return ColorPickers;
|
|
324
|
+
}());
|
|
325
|
+
|
|
326
|
+
var Inline = /** @class */ (function () {
|
|
327
|
+
function Inline() {
|
|
328
|
+
}
|
|
329
|
+
Inline.load = function (tag, options) {
|
|
330
|
+
var _a;
|
|
331
|
+
var $tag = $(tag);
|
|
332
|
+
$tag.addClass('loading');
|
|
333
|
+
if (options.onLoad) {
|
|
334
|
+
options.onLoad(tag);
|
|
335
|
+
}
|
|
336
|
+
var url = $tag.data('url');
|
|
337
|
+
$.get(url, function (data) {
|
|
338
|
+
if (options.onRender) {
|
|
339
|
+
data = options.onRender(data, tag);
|
|
340
|
+
}
|
|
341
|
+
$tag.html(data);
|
|
342
|
+
$tag.removeClass('loading');
|
|
343
|
+
if (options.onComplete) {
|
|
344
|
+
options.onComplete(data, tag);
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
.fail((_a = options.onError) !== null && _a !== void 0 ? _a : Inline.handleError);
|
|
348
|
+
};
|
|
349
|
+
Inline.task = function (url, sender, complete, error) {
|
|
350
|
+
if (complete === void 0) { complete = null; }
|
|
351
|
+
if (error === void 0) { error = null; }
|
|
352
|
+
if (sender) {
|
|
353
|
+
sender.classList.add('loading');
|
|
354
|
+
}
|
|
355
|
+
$.get(url, function (response) {
|
|
356
|
+
if (sender) {
|
|
357
|
+
sender.classList.remove('loading');
|
|
358
|
+
}
|
|
359
|
+
if (complete) {
|
|
360
|
+
complete(response, sender);
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
.fail(error !== null && error !== void 0 ? error : Inline.handleError);
|
|
364
|
+
};
|
|
365
|
+
Inline.post = function (url, sender, complete, error) {
|
|
366
|
+
if (complete === void 0) { complete = null; }
|
|
367
|
+
if (error === void 0) { error = null; }
|
|
368
|
+
if (sender) {
|
|
369
|
+
sender.classList.add('loading');
|
|
370
|
+
}
|
|
371
|
+
$.post(url, function (response) {
|
|
372
|
+
if (sender) {
|
|
373
|
+
sender.classList.remove('loading');
|
|
374
|
+
}
|
|
375
|
+
if (complete) {
|
|
376
|
+
complete(response, sender);
|
|
377
|
+
}
|
|
378
|
+
})
|
|
379
|
+
.fail(error !== null && error !== void 0 ? error : Inline.handleError);
|
|
380
|
+
};
|
|
381
|
+
Inline.handleError = function (xhr, textStatus, errorThrown) {
|
|
382
|
+
if (xhr.status === 500) {
|
|
383
|
+
Alerts.error("There was an error processing the content, please contact an administrator if this continues.", "Error " + xhr.status, 10000);
|
|
384
|
+
}
|
|
385
|
+
else if (xhr.status === 404) {
|
|
386
|
+
Alerts.error("The content could not be found.", "Error " + xhr.status, 10000);
|
|
387
|
+
}
|
|
388
|
+
else if (xhr.status === 401) {
|
|
389
|
+
Alerts.error("You are not allowed to view this resource, are you logged in correctly?", "Error " + xhr.status, 10000);
|
|
390
|
+
window.location = window.location;
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
return Inline;
|
|
394
|
+
}());
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Attach a data list feed to an HTML element. The element must have a data-url attribute to connect to a feed.
|
|
398
|
+
*/
|
|
399
|
+
var DataList = /** @class */ (function () {
|
|
400
|
+
/**
|
|
401
|
+
* @param element The datalist element. The element must have a data-url attribute to connect to a feed.
|
|
402
|
+
*/
|
|
403
|
+
function DataList(element, options) {
|
|
404
|
+
this.element = element;
|
|
405
|
+
this.element.hoodDataList = this;
|
|
406
|
+
if (typeof (element) == 'undefined' || element == null) {
|
|
407
|
+
Alerts.log('Could not DataList to element, element does not exist.', 'error');
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
this.options = __assign(__assign({}, this.options), options);
|
|
411
|
+
if ($(this.element).hasClass('query')) {
|
|
412
|
+
var pageUrl = $(this.element).data('url') + window.location.search;
|
|
413
|
+
$(this.element).attr('data-url', pageUrl);
|
|
414
|
+
$(this.element).data('url', pageUrl);
|
|
415
|
+
}
|
|
416
|
+
if (!$(this.element).hasClass('refresh-only')) {
|
|
417
|
+
var listUrl = document.createElement('a');
|
|
418
|
+
listUrl.href = $(this.element).data('url');
|
|
419
|
+
this.reload(new URL(listUrl.href));
|
|
420
|
+
}
|
|
421
|
+
$(this.element).on('click', '.pagination a, a.hood-inline-list-target', function (e) {
|
|
422
|
+
e.preventDefault();
|
|
423
|
+
var url = document.createElement('a');
|
|
424
|
+
url.href = e.currentTarget.href;
|
|
425
|
+
var listUrl = document.createElement('a');
|
|
426
|
+
listUrl.href = $(this.element).data('url');
|
|
427
|
+
listUrl.search = url.search;
|
|
428
|
+
this.reload(new URL(listUrl.href));
|
|
429
|
+
}.bind(this));
|
|
430
|
+
$('body').on('submit', "form.inline[data-target=\"#".concat(this.element.id, "\"]"), function (e) {
|
|
431
|
+
e.preventDefault();
|
|
432
|
+
var $form = $(e.currentTarget);
|
|
433
|
+
var listUrl = document.createElement('a');
|
|
434
|
+
listUrl.href = $(this.element).data('url');
|
|
435
|
+
listUrl.search = "?" + $form.serialize();
|
|
436
|
+
this.reload(new URL(listUrl.href));
|
|
437
|
+
}.bind(this));
|
|
438
|
+
}
|
|
439
|
+
DataList.prototype.reload = function (url) {
|
|
440
|
+
if (url === void 0) { url = null; }
|
|
441
|
+
if (url) {
|
|
442
|
+
if (history.pushState && $(this.element).hasClass('query')) {
|
|
443
|
+
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + (url.href.contains('?') ? "?" + url.href.substring(url.href.indexOf('?') + 1) : '');
|
|
444
|
+
window.history.pushState({ path: newurl }, '', newurl);
|
|
445
|
+
}
|
|
446
|
+
$(this.element).data('url', url);
|
|
447
|
+
}
|
|
448
|
+
Inline.load(this.element, __assign({}, this.options));
|
|
449
|
+
};
|
|
450
|
+
return DataList;
|
|
451
|
+
}());
|
|
452
|
+
|
|
453
|
+
var Response = /** @class */ (function () {
|
|
454
|
+
function Response() {
|
|
455
|
+
}
|
|
456
|
+
Response.process = function (data, autoHide) {
|
|
457
|
+
if (autoHide === void 0) { autoHide = 5000; }
|
|
458
|
+
if (data.success) {
|
|
459
|
+
Alerts.success(data.message, data.title, autoHide);
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
Alerts.error(data.errors, data.title, autoHide);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
return Response;
|
|
466
|
+
}());
|
|
467
|
+
|
|
468
|
+
var ModalController = /** @class */ (function () {
|
|
469
|
+
function ModalController(options) {
|
|
470
|
+
if (options === void 0) { options = null; }
|
|
471
|
+
this.isOpen = false;
|
|
472
|
+
this.options = {
|
|
473
|
+
closePrevious: true
|
|
474
|
+
};
|
|
475
|
+
this.options = __assign(__assign({}, this.options), options);
|
|
476
|
+
}
|
|
477
|
+
ModalController.prototype.show = function (url, sender) {
|
|
478
|
+
if (this.options.onLoad) {
|
|
479
|
+
this.options.onLoad(this.element);
|
|
480
|
+
}
|
|
481
|
+
if (this.isOpen) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
this.isOpen = true;
|
|
485
|
+
$.get(url, function (data) {
|
|
486
|
+
if (this.modal && this.options.closePrevious) {
|
|
487
|
+
this.close();
|
|
488
|
+
}
|
|
489
|
+
if (this.options.onRender) {
|
|
490
|
+
data = this.options.onRender(this.element, data);
|
|
491
|
+
}
|
|
492
|
+
this.element = this.createElementFromHTML(data);
|
|
493
|
+
this.element.classList.add('hood-inline-modal');
|
|
494
|
+
$('body').append(this.element);
|
|
495
|
+
this.modal = new bootstrap.Modal(this.element, {});
|
|
496
|
+
this.modal.show();
|
|
497
|
+
// Workaround for sweetalert popups.
|
|
498
|
+
this.element.addEventListener('shown.bs.modal', function () {
|
|
499
|
+
$(document).off('focusin.modal');
|
|
500
|
+
}.bind(this));
|
|
501
|
+
this.element.addEventListener('hidden.bs.modal', function () {
|
|
502
|
+
if (this.options.onHidden) {
|
|
503
|
+
this.options.onHidden(this.element);
|
|
504
|
+
}
|
|
505
|
+
this.dispose();
|
|
506
|
+
this.isOpen = false;
|
|
507
|
+
}.bind(this));
|
|
508
|
+
if (this.options.onComplete) {
|
|
509
|
+
this.options.onComplete(this.element);
|
|
510
|
+
}
|
|
511
|
+
}.bind(this))
|
|
512
|
+
.fail(function (xhr, textStatus, errorThrown) {
|
|
513
|
+
this.isOpen = false;
|
|
514
|
+
if (this.options.onError) {
|
|
515
|
+
this.options.onError(xhr, textStatus, errorThrown);
|
|
516
|
+
}
|
|
517
|
+
Inline.handleError(xhr, textStatus, errorThrown);
|
|
518
|
+
}.bind(this));
|
|
519
|
+
};
|
|
520
|
+
ModalController.prototype.close = function () {
|
|
521
|
+
if (this.modal) {
|
|
522
|
+
this.modal.hide();
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
ModalController.prototype.dispose = function () {
|
|
526
|
+
this.modal.dispose();
|
|
527
|
+
this.element.remove();
|
|
528
|
+
};
|
|
529
|
+
ModalController.prototype.createElementFromHTML = function (htmlString) {
|
|
530
|
+
var div = document.createElement('div');
|
|
531
|
+
div.innerHTML = htmlString.trim();
|
|
532
|
+
// Change this to div.childNodes to support multiple top-level nodes
|
|
533
|
+
return div.firstChild;
|
|
534
|
+
};
|
|
535
|
+
return ModalController;
|
|
536
|
+
}());
|
|
537
|
+
|
|
538
|
+
var Validator = /** @class */ (function () {
|
|
539
|
+
/**
|
|
540
|
+
* @param element The datalist element. The element must have a data-url attribute to connect to a feed.
|
|
541
|
+
*/
|
|
542
|
+
function Validator(element, options) {
|
|
543
|
+
this.options = {
|
|
544
|
+
errorAlert: 'There are errors, please check the form.',
|
|
545
|
+
useAjax: true
|
|
546
|
+
};
|
|
547
|
+
this.element = element;
|
|
548
|
+
if (!this.element) {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
this.options.serializationFunction = function () {
|
|
552
|
+
var rtn = $(this.element).serialize();
|
|
553
|
+
return rtn;
|
|
554
|
+
}.bind(this);
|
|
555
|
+
this.options = __assign(__assign({}, this.options), options);
|
|
556
|
+
this.element.addEventListener('submit', function (e) {
|
|
557
|
+
e.preventDefault();
|
|
558
|
+
e.stopImmediatePropagation();
|
|
559
|
+
this.submitForm();
|
|
560
|
+
}.bind(this));
|
|
561
|
+
var tag = '[data-submit="#' + this.element.id + '"]';
|
|
562
|
+
var submitButtons = $(tag);
|
|
563
|
+
if (submitButtons) {
|
|
564
|
+
submitButtons.on('click', function (e) {
|
|
565
|
+
e.preventDefault();
|
|
566
|
+
e.stopImmediatePropagation();
|
|
567
|
+
var exit = $(e.currentTarget).data('exit');
|
|
568
|
+
if (exit) {
|
|
569
|
+
$(this.element).find("input#exit").remove();
|
|
570
|
+
$("<input id='exit' />").attr("type", "hidden")
|
|
571
|
+
.attr("name", "exit")
|
|
572
|
+
.attr("value", "true")
|
|
573
|
+
.appendTo(this.element);
|
|
574
|
+
}
|
|
575
|
+
this.submitForm();
|
|
576
|
+
}.bind(this));
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
Validator.prototype.submitForm = function () {
|
|
580
|
+
var _a;
|
|
581
|
+
this.element.classList.add('was-validated');
|
|
582
|
+
if (this.element.checkValidity()) {
|
|
583
|
+
this.element.classList.add('loading');
|
|
584
|
+
var checkboxes = this.element.querySelector('input[type=checkbox]');
|
|
585
|
+
if (checkboxes) {
|
|
586
|
+
Array.prototype.slice.call(checkboxes)
|
|
587
|
+
.forEach(function (checkbox) {
|
|
588
|
+
if ($(this).is(':checked')) {
|
|
589
|
+
$(this).val('true');
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
if (this.options.onSubmit) {
|
|
594
|
+
this.options.onSubmit(this);
|
|
595
|
+
}
|
|
596
|
+
if (this.options.useAjax) {
|
|
597
|
+
var formData = this.options.serializationFunction();
|
|
598
|
+
$.post(this.element.action, formData, function (data) {
|
|
599
|
+
if (this.options.onComplete) {
|
|
600
|
+
this.options.onComplete(data, this);
|
|
601
|
+
}
|
|
602
|
+
}.bind(this))
|
|
603
|
+
.fail((_a = this.options.onError) !== null && _a !== void 0 ? _a : Inline.handleError);
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
this.element.submit();
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
if (this.options.errorAlert) {
|
|
611
|
+
Alerts.error(this.options.errorAlert, null, 5000);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
return Validator;
|
|
616
|
+
}());
|
|
617
|
+
|
|
618
|
+
var MediaService = /** @class */ (function () {
|
|
619
|
+
function MediaService(element, options) {
|
|
620
|
+
this.options = {
|
|
621
|
+
action: 'show',
|
|
622
|
+
size: 'large'
|
|
623
|
+
};
|
|
624
|
+
this.galleryInitialised = false;
|
|
625
|
+
this.selectedMedia = new Array();
|
|
626
|
+
this.element = element;
|
|
627
|
+
if (!this.element) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
this.options = __assign(__assign({}, this.options), options);
|
|
631
|
+
$('body').off('click', '.media-delete', this.delete.bind(this));
|
|
632
|
+
$('body').on('click', '.media-delete', this.delete.bind(this));
|
|
633
|
+
$(this.element).on('click', '.media-item', this.action.bind(this));
|
|
634
|
+
$(this.element).on('click', '.media-create-directory', this.createDirectory.bind(this));
|
|
635
|
+
$(this.element).on('click', '.media-delete-directory', this.deleteDirectory.bind(this));
|
|
636
|
+
this.media = new DataList(this.element, {
|
|
637
|
+
onLoad: this.options.onListLoad,
|
|
638
|
+
onError: this.options.onError,
|
|
639
|
+
onRender: this.options.onListRender,
|
|
640
|
+
onComplete: function (html, sender) {
|
|
641
|
+
this.initUploader();
|
|
642
|
+
// if this is gallery type, add the "Add to gallery button" and hook it to the add function
|
|
643
|
+
if (this.options.action == 'gallery' && !this.galleryInitialised) {
|
|
644
|
+
$('#media-select-modal .modal-footer').removeClass('d-none');
|
|
645
|
+
$('#media-select-modal .modal-footer').on('click', this.galleryAdd.bind(this));
|
|
646
|
+
this.galleryInitialised = true;
|
|
647
|
+
}
|
|
648
|
+
if (this.options.onListComplete) {
|
|
649
|
+
this.options.onListComplete(html, sender);
|
|
650
|
+
}
|
|
651
|
+
}.bind(this)
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
MediaService.prototype.initUploader = function () {
|
|
655
|
+
this.uploadButton = document.getElementById('media-add');
|
|
656
|
+
this.uploader = document.getElementById('media-upload');
|
|
657
|
+
if (!this.uploadButton || !this.uploader)
|
|
658
|
+
return;
|
|
659
|
+
this.progressArea = document.getElementById('media-progress');
|
|
660
|
+
this.progressText = $('<div class="progress-text text-muted mb-3"><i class="fa fa-info-circle me-2"></i>Uploading file <span></span>...</div>');
|
|
661
|
+
this.progress = $('<div class="progress"><div class= "progress-bar progress-bar-striped" role="progressbar" style="width:0%" aria-valuenow="10" aria-valuemin="0" aria-valuemax="100" ></div></div>');
|
|
662
|
+
this.progressText.appendTo(this.progressArea);
|
|
663
|
+
this.progress.appendTo(this.progressArea);
|
|
664
|
+
var dz = null;
|
|
665
|
+
$("#media-upload").dropzone({
|
|
666
|
+
url: $("#media-upload").data('url') + "?directoryId=" + $("#media-list > #upload-directory-id").val(),
|
|
667
|
+
thumbnailWidth: 80,
|
|
668
|
+
thumbnailHeight: 80,
|
|
669
|
+
parallelUploads: 5,
|
|
670
|
+
paramName: 'files',
|
|
671
|
+
acceptedFiles: $("#media-upload").data('types') || ".png,.jpg,.jpeg,.gif",
|
|
672
|
+
autoProcessQueue: true,
|
|
673
|
+
previewsContainer: false,
|
|
674
|
+
clickable: "#media-add",
|
|
675
|
+
dictDefaultMessage: '<span><i class="fa fa-cloud-upload fa-4x"></i><br />Drag and drop files here, or simply click me!</div>',
|
|
676
|
+
dictResponseError: 'Error while uploading file!',
|
|
677
|
+
init: function () {
|
|
678
|
+
dz = this;
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
dz.on("error", function (file, errormessage) {
|
|
682
|
+
Alerts.warning(errormessage);
|
|
683
|
+
}.bind(this));
|
|
684
|
+
dz.on("success", function (file, data) {
|
|
685
|
+
Response.process(data);
|
|
686
|
+
}.bind(this));
|
|
687
|
+
dz.on("addedfile", function (file) {
|
|
688
|
+
this.progress.find('.progress-bar').css({ width: 0 + "%" });
|
|
689
|
+
this.progressText.find('span').html(0 + "%");
|
|
690
|
+
}.bind(this));
|
|
691
|
+
// Update the total progress bar
|
|
692
|
+
dz.on("totaluploadprogress", function (totalProgress, totalBytes, totalBytesSent) {
|
|
693
|
+
this.progress.find('.progress-bar').css({ width: totalProgress + "%" });
|
|
694
|
+
this.progressText.find('span').html(Math.round(totalProgress) + "% - " + totalBytesSent.formatKilobytes() + " / " + totalBytes.formatKilobytes());
|
|
695
|
+
}.bind(this));
|
|
696
|
+
dz.on("sending", function (file) {
|
|
697
|
+
// Show the total progress bar when upload starts
|
|
698
|
+
this.progressArea.classList.remove('collapse');
|
|
699
|
+
this.progress.find('.progress-bar').css({ width: 0 + "%" });
|
|
700
|
+
this.progressText.find('span').html(0 + "%");
|
|
701
|
+
}.bind(this));
|
|
702
|
+
// Hide the total progress bar when nothing's uploading anymore
|
|
703
|
+
dz.on("complete", function (file) {
|
|
704
|
+
this.media.reload();
|
|
705
|
+
}.bind(this));
|
|
706
|
+
// Hide the total progress bar when nothing's uploading anymore
|
|
707
|
+
dz.on("queuecomplete", function () {
|
|
708
|
+
this.progressArea.classList.add('collapse');
|
|
709
|
+
this.media.reload();
|
|
710
|
+
}.bind(this));
|
|
711
|
+
};
|
|
712
|
+
MediaService.prototype.createDirectory = function (e) {
|
|
713
|
+
e.preventDefault();
|
|
714
|
+
e.stopPropagation();
|
|
715
|
+
var createDirectoryModal = new ModalController({
|
|
716
|
+
onComplete: function () {
|
|
717
|
+
var form = document.getElementById('content-directories-edit-form');
|
|
718
|
+
new Validator(form, {
|
|
719
|
+
onComplete: function (response) {
|
|
720
|
+
Response.process(response, 5000);
|
|
721
|
+
if (response.success) {
|
|
722
|
+
this.media.reload();
|
|
723
|
+
createDirectoryModal.close();
|
|
724
|
+
}
|
|
725
|
+
}.bind(this)
|
|
726
|
+
});
|
|
727
|
+
}.bind(this)
|
|
728
|
+
});
|
|
729
|
+
createDirectoryModal.show($(e.currentTarget).attr('href'), this.element);
|
|
730
|
+
};
|
|
731
|
+
MediaService.prototype.deleteDirectory = function (e) {
|
|
732
|
+
e.preventDefault();
|
|
733
|
+
e.stopPropagation();
|
|
734
|
+
Alerts.confirm({}, function (result) {
|
|
735
|
+
if (result.isConfirmed) {
|
|
736
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (response, sender) {
|
|
737
|
+
// Refresh the list, using the parent directory id - stored in the response's data array.
|
|
738
|
+
Response.process(response, 5000);
|
|
739
|
+
if (response.data.length > 0) {
|
|
740
|
+
var listUrl = document.createElement('a');
|
|
741
|
+
listUrl.href = $(this.element).data('url');
|
|
742
|
+
listUrl.search = "?dir=".concat(response.data[0]);
|
|
743
|
+
this.media.reload(new URL(listUrl.href));
|
|
744
|
+
}
|
|
745
|
+
}.bind(this));
|
|
746
|
+
}
|
|
747
|
+
}.bind(this));
|
|
748
|
+
};
|
|
749
|
+
MediaService.prototype.uploadUrl = function () {
|
|
750
|
+
return $("#media-upload").data('url') + "?directoryId=" + $("#media-list > #upload-directory-id").val();
|
|
751
|
+
};
|
|
752
|
+
MediaService.prototype.action = function (e) {
|
|
753
|
+
e.preventDefault();
|
|
754
|
+
e.stopPropagation();
|
|
755
|
+
// Load media object from clicked item in the media list
|
|
756
|
+
var mediaObject = $(e.currentTarget).data('json');
|
|
757
|
+
// Perform the chosen action, which is set on the service's options when loaded.
|
|
758
|
+
switch (this.options.action) {
|
|
759
|
+
case 'select':
|
|
760
|
+
this.select(mediaObject, e);
|
|
761
|
+
break;
|
|
762
|
+
case 'insert':
|
|
763
|
+
this.insert(mediaObject, e);
|
|
764
|
+
break;
|
|
765
|
+
case 'attach':
|
|
766
|
+
this.attach(mediaObject, e);
|
|
767
|
+
break;
|
|
768
|
+
case 'gallery':
|
|
769
|
+
this.galleryClick(mediaObject, e);
|
|
770
|
+
break;
|
|
771
|
+
default:
|
|
772
|
+
this.show(mediaObject, e);
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
MediaService.prototype.show = function (mediaObject, sender) {
|
|
777
|
+
// Load the media as a new blade to display.
|
|
778
|
+
this.currentBlade = new ModalController();
|
|
779
|
+
this.currentBlade.show($(sender.target).data('blade'), sender.target);
|
|
780
|
+
// TODO: On close, reload the list and reinstate the modal??
|
|
781
|
+
};
|
|
782
|
+
MediaService.prototype.select = function (mediaObject, e) {
|
|
783
|
+
Alerts.log("[MediaService.select] Selecting media object id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, " and inserting ").concat(this.options.size, " url to target: ").concat(this.options.target));
|
|
784
|
+
if (this.options.target) {
|
|
785
|
+
var target = $(this.options.target);
|
|
786
|
+
switch (this.options.size) {
|
|
787
|
+
case 'thumb':
|
|
788
|
+
target.val(mediaObject.thumbUrl);
|
|
789
|
+
break;
|
|
790
|
+
case 'small':
|
|
791
|
+
target.val(mediaObject.smallUrl);
|
|
792
|
+
break;
|
|
793
|
+
case 'medium':
|
|
794
|
+
target.val(mediaObject.mediumUrl);
|
|
795
|
+
break;
|
|
796
|
+
case 'large':
|
|
797
|
+
target.val(mediaObject.largeUrl);
|
|
798
|
+
break;
|
|
799
|
+
case 'full':
|
|
800
|
+
target.val(mediaObject.url);
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
if (this.options.refresh) {
|
|
805
|
+
MediaService.refresh(mediaObject, this.options.refresh);
|
|
806
|
+
}
|
|
807
|
+
// Run the callback for onAction
|
|
808
|
+
if (this.options.onAction) {
|
|
809
|
+
this.options.onAction(mediaObject);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
MediaService.prototype.insert = function (mediaObject, e) {
|
|
813
|
+
// basic functionality to insert the correct string from the media response (from uploader) to given input element.
|
|
814
|
+
Alerts.log("[MediaService.insert] Selecting media object id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, " and inserting ").concat(this.options.size, " image to target editor: ").concat(this.options.target));
|
|
815
|
+
this.options.targetEditor.insertContent('<img alt="' + mediaObject.filename + '" src="' + mediaObject.url + '" class="img-fluid" />');
|
|
816
|
+
// Run the callback for onAction
|
|
817
|
+
if (this.options.onAction) {
|
|
818
|
+
this.options.onAction(mediaObject);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
MediaService.prototype.attach = function (mediaObject, e) {
|
|
822
|
+
// once file is uploaded to given directory, send media id to the given attach endpoint.
|
|
823
|
+
Alerts.log("[MediaService.attach] Attaching media object id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, " to url: ").concat(this.options.url));
|
|
824
|
+
$.post(this.options.url, { mediaId: mediaObject.id }, function (response) {
|
|
825
|
+
Response.process(response, 5000);
|
|
826
|
+
MediaService.refresh(response.media, this.options.refresh);
|
|
827
|
+
// Run the callback for onAction
|
|
828
|
+
if (this.options.onAction) {
|
|
829
|
+
this.options.onAction(mediaObject);
|
|
830
|
+
}
|
|
831
|
+
}.bind(this));
|
|
832
|
+
};
|
|
833
|
+
MediaService.prototype.galleryClick = function (mediaObject, e) {
|
|
834
|
+
// once file is uploaded to given directory, send media id to the given attach endpoint.
|
|
835
|
+
if (!this.isMediaSelected(mediaObject)) {
|
|
836
|
+
Alerts.log("[MediaService.galleryClick] Adding to selected media objects - id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, "."));
|
|
837
|
+
this.selectedMedia.push(mediaObject);
|
|
838
|
+
$(e.currentTarget).parents('.media-item').addClass('active');
|
|
839
|
+
}
|
|
840
|
+
else {
|
|
841
|
+
Alerts.log("[MediaService.galleryClick] Removing media from selection - id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, ".}"));
|
|
842
|
+
this.selectedMedia = this.selectedMedia.filter(function (obj) {
|
|
843
|
+
return obj.id !== mediaObject.id;
|
|
844
|
+
});
|
|
845
|
+
$(e.currentTarget).parents('.media-item').removeClass('active');
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
MediaService.prototype.galleryAdd = function (e) {
|
|
849
|
+
e.preventDefault();
|
|
850
|
+
e.stopPropagation();
|
|
851
|
+
// once file is uploaded to given directory, send media id to the given attach endpoint.
|
|
852
|
+
Alerts.log("[MediaService.galleryAdd] Adding ".concat(this.selectedMedia.length, " selected media objects to url: ").concat(this.options.url));
|
|
853
|
+
var mediaIds = this.selectedMedia.map(function (v) {
|
|
854
|
+
return v.id;
|
|
855
|
+
});
|
|
856
|
+
// create the url to send to (add media id's to it as query params)
|
|
857
|
+
$.post(this.options.url, { media: mediaIds }, function (data) {
|
|
858
|
+
Response.process(data);
|
|
859
|
+
// refresh the gallery - -
|
|
860
|
+
var galleryEl = document.getElementById(this.options.target);
|
|
861
|
+
var gallery = galleryEl.hoodDataList;
|
|
862
|
+
gallery.reload();
|
|
863
|
+
// Run the callback for onAction
|
|
864
|
+
if (this.options.onAction) {
|
|
865
|
+
this.options.onAction(data.media);
|
|
866
|
+
}
|
|
867
|
+
}.bind(this));
|
|
868
|
+
};
|
|
869
|
+
MediaService.prototype.isMediaSelected = function (mediaObject) {
|
|
870
|
+
var added = false;
|
|
871
|
+
this.selectedMedia.forEach(function (value, index, array) {
|
|
872
|
+
if (value.id == mediaObject.id) {
|
|
873
|
+
added = true;
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
return added;
|
|
877
|
+
};
|
|
878
|
+
MediaService.refresh = function (media, refresh) {
|
|
879
|
+
var icon = media.icon;
|
|
880
|
+
if (media.genericFileType === "Image") {
|
|
881
|
+
icon = media.mediumUrl;
|
|
882
|
+
}
|
|
883
|
+
if (refresh) {
|
|
884
|
+
var $image = $(refresh);
|
|
885
|
+
$image.css({
|
|
886
|
+
'background-image': 'url(' + icon + ')'
|
|
887
|
+
});
|
|
888
|
+
$image.find('img').attr('src', icon);
|
|
889
|
+
$image.removeClass('loading');
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
MediaService.prototype.delete = function (e) {
|
|
893
|
+
e.preventDefault();
|
|
894
|
+
e.stopPropagation();
|
|
895
|
+
Alerts.confirm({
|
|
896
|
+
html: 'This file will be permanently deleted, are you sure?'
|
|
897
|
+
}, function (result) {
|
|
898
|
+
if (result.isConfirmed) {
|
|
899
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (response) {
|
|
900
|
+
Response.process(response, 5000);
|
|
901
|
+
this.media.reload();
|
|
902
|
+
if (this.currentBlade) {
|
|
903
|
+
this.currentBlade.close();
|
|
904
|
+
}
|
|
905
|
+
}.bind(this));
|
|
906
|
+
}
|
|
907
|
+
}.bind(this));
|
|
908
|
+
};
|
|
909
|
+
return MediaService;
|
|
910
|
+
}());
|
|
911
|
+
var MediaModal = /** @class */ (function () {
|
|
912
|
+
function MediaModal() {
|
|
913
|
+
$('body').on('click', '[data-hood-media=attach],[data-hood-media=select],[data-hood-media=gallery]', this.load.bind(this));
|
|
914
|
+
$('body').on('click', '[data-hood-media=clear]', this.clear.bind(this));
|
|
915
|
+
$('[data-hood-media=gallery]').each(this.initGallery.bind(this));
|
|
916
|
+
}
|
|
917
|
+
MediaModal.prototype.initGallery = function (index, element) {
|
|
918
|
+
// setup the gallery list also, just a simple list jobby, and attach it to the
|
|
919
|
+
var el = document.getElementById(element.dataset.hoodMediaTarget);
|
|
920
|
+
if (el) {
|
|
921
|
+
new DataList(el, {
|
|
922
|
+
onComplete: function (data, sender) {
|
|
923
|
+
Alerts.log('Finished loading gallery media list.', 'info');
|
|
924
|
+
}.bind(this)
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
MediaModal.prototype.load = function (e) {
|
|
929
|
+
e.preventDefault();
|
|
930
|
+
e.stopPropagation();
|
|
931
|
+
this.element = e.currentTarget;
|
|
932
|
+
if (this.modal && this.modal.isOpen) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
this.modal = new ModalController({
|
|
936
|
+
onComplete: function (sender) {
|
|
937
|
+
this.list = document.getElementById('media-list');
|
|
938
|
+
this.service = new MediaService(this.list, {
|
|
939
|
+
action: this.element.dataset.hoodMedia,
|
|
940
|
+
url: this.element.dataset.hoodMediaUrl,
|
|
941
|
+
refresh: this.element.dataset.hoodMediaRefresh,
|
|
942
|
+
target: this.element.dataset.hoodMediaTarget,
|
|
943
|
+
size: this.element.dataset.hoodMediaSize,
|
|
944
|
+
beforeAction: function (sender, mediaObject) {
|
|
945
|
+
}.bind(this),
|
|
946
|
+
onAction: function (sender, mediaObject) {
|
|
947
|
+
this.modal.close();
|
|
948
|
+
}.bind(this),
|
|
949
|
+
onListLoad: function (sender) {
|
|
950
|
+
},
|
|
951
|
+
onListRender: function (data) {
|
|
952
|
+
return data;
|
|
953
|
+
},
|
|
954
|
+
onListComplete: function (data) {
|
|
955
|
+
},
|
|
956
|
+
onError: function (jqXHR, textStatus, errorThrown) {
|
|
957
|
+
},
|
|
958
|
+
});
|
|
959
|
+
}.bind(this)
|
|
960
|
+
});
|
|
961
|
+
this.modal.show($(e.currentTarget).data('hood-media-list'), e.currentTarget);
|
|
962
|
+
};
|
|
963
|
+
MediaModal.prototype.clear = function (e) {
|
|
964
|
+
e.preventDefault();
|
|
965
|
+
e.stopPropagation();
|
|
966
|
+
Alerts.confirm({}, function (result) {
|
|
967
|
+
if (result.isConfirmed) {
|
|
968
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (response) {
|
|
969
|
+
Response.process(response, 5000);
|
|
970
|
+
MediaService.refresh(response.media, e.currentTarget.dataset.hoodMediaRefresh);
|
|
971
|
+
}.bind(this));
|
|
972
|
+
}
|
|
973
|
+
}.bind(this));
|
|
974
|
+
};
|
|
975
|
+
return MediaModal;
|
|
976
|
+
}());
|
|
977
|
+
|
|
978
|
+
var Editors = /** @class */ (function () {
|
|
979
|
+
function Editors(options) {
|
|
980
|
+
this.options = {
|
|
981
|
+
linkClasses: [
|
|
982
|
+
{ title: 'None', value: '' },
|
|
983
|
+
{ title: 'Button link', value: 'btn btn-default' },
|
|
984
|
+
{ title: 'Theme coloured button link', value: 'btn btn-primary' },
|
|
985
|
+
{ title: 'Popup image/video', value: 'colorbox-iframe' },
|
|
986
|
+
{ title: 'Button popup link', value: 'btn btn-default colorbox-iframe' },
|
|
987
|
+
{ title: 'Theme coloured button popup link', value: 'btn btn-primary colorbox-iframe' },
|
|
988
|
+
{ title: 'Large link', value: 'font-lg' },
|
|
989
|
+
{ title: 'Large button link', value: 'btn btn-default btn-lg' },
|
|
990
|
+
{ title: 'Large theme coloured button link', value: 'btn btn-primary btn-lg' },
|
|
991
|
+
{ title: 'Large popup image/video', value: 'font-lg colorbox-iframe' },
|
|
992
|
+
{ title: 'Large Button popup link', value: 'btn btn-default btn-lg colorbox-iframe' },
|
|
993
|
+
{ title: 'Theme coloured button popup link', value: 'btn btn-primary btn-lg colorbox-iframe' }
|
|
994
|
+
],
|
|
995
|
+
imageClasses: [
|
|
996
|
+
{ title: 'None', value: '' },
|
|
997
|
+
{ title: 'Full Width', value: 'user-image full' },
|
|
998
|
+
{ title: 'Left Aligned', value: 'user-image left' },
|
|
999
|
+
{ title: 'Centered', value: 'user-image center' },
|
|
1000
|
+
{ title: 'Right Aligned', value: 'user-image right' },
|
|
1001
|
+
{ title: 'Inline with text, top aligned', value: 'user-image inline top' },
|
|
1002
|
+
{ title: 'Inline with text, middle aligned', value: 'user-image inline' },
|
|
1003
|
+
{ title: 'Inline with text, bottom aligned', value: 'user-image inline bottom' },
|
|
1004
|
+
{ title: 'Pulled Left', value: 'user-image pull-left' },
|
|
1005
|
+
{ title: 'Pulled Right', value: 'user-image pull-right' },
|
|
1006
|
+
]
|
|
1007
|
+
};
|
|
1008
|
+
this.options = __assign(__assign({}, this.options), options);
|
|
1009
|
+
}
|
|
1010
|
+
Editors.prototype.richTextEditors = function () {
|
|
1011
|
+
tinymce__default["default"].init({
|
|
1012
|
+
selector: '.tinymce-full',
|
|
1013
|
+
height: 150,
|
|
1014
|
+
menubar: false,
|
|
1015
|
+
plugins: [
|
|
1016
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
1017
|
+
'searchreplace visualblocks code fullscreen',
|
|
1018
|
+
'insertdatetime media contextmenu paste code textcolor'
|
|
1019
|
+
],
|
|
1020
|
+
toolbar: "fullscreen | styleselect forecolor backcolor | hoodimage link media image | bold italic | alignleft aligncenter alignright | bullist numlist | table | undo redo",
|
|
1021
|
+
link_class_list: this.options.linkClasses,
|
|
1022
|
+
image_class_list: this.options.imageClasses,
|
|
1023
|
+
setup: this.setupCommands.bind(this),
|
|
1024
|
+
image_dimensions: false,
|
|
1025
|
+
content_css: [
|
|
1026
|
+
'/dist/css/editor.css'
|
|
1027
|
+
],
|
|
1028
|
+
});
|
|
1029
|
+
tinymce__default["default"].init({
|
|
1030
|
+
selector: '.tinymce-simple',
|
|
1031
|
+
height: 150,
|
|
1032
|
+
plugins: [
|
|
1033
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
1034
|
+
'searchreplace visualblocks code fullscreen',
|
|
1035
|
+
'insertdatetime media contextmenu paste code'
|
|
1036
|
+
],
|
|
1037
|
+
menubar: false,
|
|
1038
|
+
toolbar: 'fullscreen | bold italic | bullist numlist | undo redo | link',
|
|
1039
|
+
link_class_list: this.options.linkClasses,
|
|
1040
|
+
image_class_list: this.options.imageClasses,
|
|
1041
|
+
setup: this.setupCommands.bind(this),
|
|
1042
|
+
image_dimensions: false
|
|
1043
|
+
});
|
|
1044
|
+
tinymce__default["default"].init({
|
|
1045
|
+
selector: '.tinymce-full-content',
|
|
1046
|
+
height: 500,
|
|
1047
|
+
menubar: false,
|
|
1048
|
+
plugins: [
|
|
1049
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
1050
|
+
'searchreplace visualblocks code fullscreen',
|
|
1051
|
+
'insertdatetime media contextmenu paste code textcolor'
|
|
1052
|
+
],
|
|
1053
|
+
toolbar: "fullscreen | styleselect forecolor backcolor | hoodimage link media image | bold italic | alignleft aligncenter alignright | bullist numlist | table | undo redo",
|
|
1054
|
+
link_class_list: this.options.linkClasses,
|
|
1055
|
+
image_class_list: this.options.imageClasses,
|
|
1056
|
+
setup: this.setupCommands.bind(this),
|
|
1057
|
+
image_dimensions: false
|
|
1058
|
+
});
|
|
1059
|
+
tinymce__default["default"].init({
|
|
1060
|
+
selector: '.tinymce-simple-content',
|
|
1061
|
+
height: 500,
|
|
1062
|
+
plugins: [
|
|
1063
|
+
'advlist autolink lists link image charmap print preview anchor media',
|
|
1064
|
+
'searchreplace visualblocks code fullscreen',
|
|
1065
|
+
'insertdatetime media contextmenu paste code'
|
|
1066
|
+
],
|
|
1067
|
+
menubar: false,
|
|
1068
|
+
toolbar: 'fullscreen | bold italic | bullist numlist | undo redo | link',
|
|
1069
|
+
link_class_list: this.options.linkClasses,
|
|
1070
|
+
image_class_list: this.options.imageClasses,
|
|
1071
|
+
image_dimensions: false
|
|
1072
|
+
});
|
|
1073
|
+
};
|
|
1074
|
+
Editors.prototype.setupCommands = function (editor) {
|
|
1075
|
+
this.currentEditor = $('#' + editor.id);
|
|
1076
|
+
if (this.currentEditor.data('hoodMediaList')) {
|
|
1077
|
+
editor.addButton('hoodimage', {
|
|
1078
|
+
text: 'Insert image...',
|
|
1079
|
+
icon: false,
|
|
1080
|
+
onclick: function (e) {
|
|
1081
|
+
this.mediaModal = new ModalController({
|
|
1082
|
+
onComplete: function (sender) {
|
|
1083
|
+
this.list = document.getElementById('media-list');
|
|
1084
|
+
this.service = new MediaService(this.list, {
|
|
1085
|
+
action: 'insert',
|
|
1086
|
+
url: this.currentEditor.data('hoodMediaList'),
|
|
1087
|
+
targetEditor: editor,
|
|
1088
|
+
size: this.currentEditor.data('hoodMediaSize'),
|
|
1089
|
+
beforeAction: function (sender, mediaObject) {
|
|
1090
|
+
}.bind(this),
|
|
1091
|
+
onAction: function (sender, mediaObject) {
|
|
1092
|
+
this.mediaModal.close();
|
|
1093
|
+
}.bind(this),
|
|
1094
|
+
onListLoad: function (sender) {
|
|
1095
|
+
},
|
|
1096
|
+
onListRender: function (data) {
|
|
1097
|
+
return data;
|
|
1098
|
+
},
|
|
1099
|
+
onListComplete: function (data) {
|
|
1100
|
+
},
|
|
1101
|
+
onError: function (jqXHR, textStatus, errorThrown) {
|
|
1102
|
+
},
|
|
1103
|
+
});
|
|
1104
|
+
}.bind(this)
|
|
1105
|
+
});
|
|
1106
|
+
this.mediaModal.show(this.currentEditor.data('hoodMediaList'), e.currentTarget);
|
|
1107
|
+
}.bind(this)
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
return Editors;
|
|
1112
|
+
}());
|
|
1113
|
+
|
|
1114
|
+
var Handlers = /** @class */ (function () {
|
|
1115
|
+
function Handlers() {
|
|
1116
|
+
}
|
|
1117
|
+
/**
|
|
1118
|
+
* Initialise all default Hood CMS handlers.
|
|
1119
|
+
*/
|
|
1120
|
+
Handlers.prototype.initDefaultHandlers = function () {
|
|
1121
|
+
this.checkboxToCsvInput();
|
|
1122
|
+
this.iconSelector();
|
|
1123
|
+
this.initSelectValues();
|
|
1124
|
+
this.scrollHandlers();
|
|
1125
|
+
this.selectText();
|
|
1126
|
+
this.setValueOnClick();
|
|
1127
|
+
this.submitOnChange();
|
|
1128
|
+
};
|
|
1129
|
+
/**
|
|
1130
|
+
* Sets values of any selects that have the value set in data-selected, useful for
|
|
1131
|
+
*/
|
|
1132
|
+
Handlers.prototype.initSelectValues = function (tag) {
|
|
1133
|
+
if (tag === void 0) { tag = 'body'; }
|
|
1134
|
+
$(tag).find('select[data-selected]').each(this.initSelectValuesHandler);
|
|
1135
|
+
};
|
|
1136
|
+
Handlers.prototype.initSelectValuesHandler = function (index, element) {
|
|
1137
|
+
var sel = $(this).data('selected');
|
|
1138
|
+
if (sel !== 'undefined' && sel !== '') {
|
|
1139
|
+
var selected = String(sel);
|
|
1140
|
+
$(this).val(selected);
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
1143
|
+
/**
|
|
1144
|
+
* Sets up any Hood Icon selector fields, requires the correct HTML setup.
|
|
1145
|
+
*/
|
|
1146
|
+
Handlers.prototype.iconSelector = function (tag) {
|
|
1147
|
+
if (tag === void 0) { tag = 'body'; }
|
|
1148
|
+
$(tag).find('[data-hood-icon]').each(this.iconSelectorHandler);
|
|
1149
|
+
};
|
|
1150
|
+
Handlers.prototype.iconSelectorHandler = function (index, element) {
|
|
1151
|
+
var $tag = $(this);
|
|
1152
|
+
var input = $tag.find('input[data-hood-icon-input]');
|
|
1153
|
+
var display = $tag.find('[data-hood-icon-display]');
|
|
1154
|
+
var collapse = $tag.find('.collapse');
|
|
1155
|
+
$tag.find('[data-hood-icon-key][data-hood-icon-value]').on('click', function () {
|
|
1156
|
+
$tag.find('[data-hood-icon-key][data-hood-icon-value]').removeClass('active');
|
|
1157
|
+
$(this).addClass('active');
|
|
1158
|
+
var key = $(this).data('hoodIconKey');
|
|
1159
|
+
var value = $(this).data('hoodIconValue');
|
|
1160
|
+
$(this);
|
|
1161
|
+
display.html(value);
|
|
1162
|
+
input.val(key);
|
|
1163
|
+
if (collapse) {
|
|
1164
|
+
collapse.removeClass('show');
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1168
|
+
/**
|
|
1169
|
+
* Submits the form when input is changed, mark inputs with .submit-on-change class.
|
|
1170
|
+
*/
|
|
1171
|
+
Handlers.prototype.selectText = function (tag) {
|
|
1172
|
+
if (tag === void 0) { tag = 'body'; }
|
|
1173
|
+
$(tag).on('click', '.select-text', this.selectTextHandler);
|
|
1174
|
+
};
|
|
1175
|
+
Handlers.prototype.selectTextHandler = function () {
|
|
1176
|
+
var $this = $(this);
|
|
1177
|
+
$this.select();
|
|
1178
|
+
// Work around Chrome's little problem
|
|
1179
|
+
$this.mouseup(function () {
|
|
1180
|
+
// Prevent further mouseup intervention
|
|
1181
|
+
$this.unbind("mouseup");
|
|
1182
|
+
return false;
|
|
1183
|
+
});
|
|
1184
|
+
};
|
|
1185
|
+
/**
|
|
1186
|
+
* Attaches handlers for default scrolling functions, scroll to top, scroll to target (with header.header offset calculated)
|
|
1187
|
+
* and scroll to target direct (with no calculated offset).
|
|
1188
|
+
*/
|
|
1189
|
+
Handlers.prototype.scrollHandlers = function (tag) {
|
|
1190
|
+
if (tag === void 0) { tag = 'body'; }
|
|
1191
|
+
$(tag).on('click', '.scroll-top, .scroll-to-top', this.scrollTop);
|
|
1192
|
+
$(tag).on('click', '.scroll-target, .scroll-to-target', this.scrollTarget);
|
|
1193
|
+
$(tag).on('click', '.scroll-target-direct, .scroll-to-target-direct', this.scrollTargetDirect);
|
|
1194
|
+
};
|
|
1195
|
+
Handlers.prototype.scrollTop = function (e) {
|
|
1196
|
+
if (e)
|
|
1197
|
+
e.preventDefault();
|
|
1198
|
+
$('html, body').animate({ scrollTop: 0 }, 800);
|
|
1199
|
+
return false;
|
|
1200
|
+
};
|
|
1201
|
+
Handlers.prototype.scrollTarget = function (e) {
|
|
1202
|
+
if (e)
|
|
1203
|
+
e.preventDefault();
|
|
1204
|
+
var url = $(this).attr('href').split('#')[0];
|
|
1205
|
+
if (url !== window.location.pathname && url !== "") {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
var target = this.hash;
|
|
1209
|
+
var $target = $(target);
|
|
1210
|
+
var $header = $('header.header');
|
|
1211
|
+
var headerOffset = 0;
|
|
1212
|
+
if ($header) {
|
|
1213
|
+
headerOffset = $header.height();
|
|
1214
|
+
}
|
|
1215
|
+
if ($(this).data('offset'))
|
|
1216
|
+
$('html, body').stop().animate({
|
|
1217
|
+
'scrollTop': $target.offset().top - $(this).data('offset')
|
|
1218
|
+
}, 900, 'swing');
|
|
1219
|
+
else
|
|
1220
|
+
$('html, body').stop().animate({
|
|
1221
|
+
'scrollTop': $target.offset().top - headerOffset
|
|
1222
|
+
}, 900, 'swing');
|
|
1223
|
+
};
|
|
1224
|
+
Handlers.prototype.scrollTargetDirect = function () {
|
|
1225
|
+
var scrollTop = $('body').scrollTop();
|
|
1226
|
+
var top = $($(this).attr('href')).offset().top;
|
|
1227
|
+
$('html, body').animate({
|
|
1228
|
+
scrollTop: top
|
|
1229
|
+
}, Math.abs(top - scrollTop));
|
|
1230
|
+
return false;
|
|
1231
|
+
};
|
|
1232
|
+
/**
|
|
1233
|
+
* Compiles any selected checkboxes with matching data-hood-csv-input tags,
|
|
1234
|
+
* then saves the CSV list of the values to the input given in the tag.
|
|
1235
|
+
*/
|
|
1236
|
+
Handlers.prototype.checkboxToCsvInput = function (tag) {
|
|
1237
|
+
if (tag === void 0) { tag = 'body'; }
|
|
1238
|
+
$(tag).on('change', 'input[type=checkbox][data-hood-csv-input]', this.checkboxToCsvInputHandler);
|
|
1239
|
+
};
|
|
1240
|
+
Handlers.prototype.checkboxToCsvInputHandler = function (e) {
|
|
1241
|
+
if (e)
|
|
1242
|
+
e.preventDefault();
|
|
1243
|
+
// when i change - create an array, with any other checked of the same data-input checkboxes. and add to the data-input referenced tag.
|
|
1244
|
+
var items = new Array();
|
|
1245
|
+
$('input[data-hood-csv-input="' + $(this).data('hoodCsvInput') + '"]').each(function () {
|
|
1246
|
+
if ($(this).is(":checked"))
|
|
1247
|
+
items.push($(this).val());
|
|
1248
|
+
});
|
|
1249
|
+
var id = '#' + $(this).data('input');
|
|
1250
|
+
var vals = JSON.stringify(items);
|
|
1251
|
+
$(id).val(vals);
|
|
1252
|
+
};
|
|
1253
|
+
/**
|
|
1254
|
+
* Submits the form when input is changed, mark inputs with .submit-on-change class.
|
|
1255
|
+
*/
|
|
1256
|
+
Handlers.prototype.submitOnChange = function (tag) {
|
|
1257
|
+
if (tag === void 0) { tag = 'body'; }
|
|
1258
|
+
$(tag).on('change', '.submit-on-change', this.submitOnChangeHandler);
|
|
1259
|
+
};
|
|
1260
|
+
Handlers.prototype.submitOnChangeHandler = function (e) {
|
|
1261
|
+
if (e)
|
|
1262
|
+
e.preventDefault();
|
|
1263
|
+
$(this).parents('form').submit();
|
|
1264
|
+
};
|
|
1265
|
+
/**
|
|
1266
|
+
* Sets the value of the input [data-target] when clicked to the value in [data-value]
|
|
1267
|
+
*/
|
|
1268
|
+
Handlers.prototype.setValueOnClick = function (tag) {
|
|
1269
|
+
if (tag === void 0) { tag = 'body'; }
|
|
1270
|
+
$(tag).on('click', '.click-select[data-target][data-value]', this.setValueOnClickHandler);
|
|
1271
|
+
};
|
|
1272
|
+
Handlers.prototype.setValueOnClickHandler = function () {
|
|
1273
|
+
var $this = $(this);
|
|
1274
|
+
var targetId = '#' + $this.data('target');
|
|
1275
|
+
$(targetId).val($this.data('value'));
|
|
1276
|
+
$(targetId).trigger('change');
|
|
1277
|
+
$('.click-select.clean[data-target="' + $this.data('target') + '"]').each(function () { $(this).removeClass('active'); });
|
|
1278
|
+
$('.click-select.clean[data-target="' + $this.data('target') + '"][data-value="' + $this.data('value') + '"]').each(function () { $(this).addClass('active'); });
|
|
1279
|
+
};
|
|
1280
|
+
return Handlers;
|
|
1281
|
+
}());
|
|
1282
|
+
|
|
1283
|
+
var Uploader = /** @class */ (function () {
|
|
1284
|
+
function Uploader() {
|
|
1285
|
+
if ($('.image-uploader').length || $('.gallery-uploader').length) {
|
|
1286
|
+
$(".upload-progress-bar").hide();
|
|
1287
|
+
$('.image-uploader').each(this.singleImage);
|
|
1288
|
+
$('.gallery-uploader').each(this.gallery);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
Uploader.prototype.refreshImage = function (sender, data) {
|
|
1292
|
+
$(sender.data('preview')).css({
|
|
1293
|
+
'background-image': 'url(' + data.media.smallUrl + ')'
|
|
1294
|
+
});
|
|
1295
|
+
$(sender.data('preview')).find('img').attr('src', data.media.smallUrl);
|
|
1296
|
+
};
|
|
1297
|
+
Uploader.prototype.singleImage = function () {
|
|
1298
|
+
var tag = '#' + $(this).attr('id');
|
|
1299
|
+
var $tag = $(tag);
|
|
1300
|
+
var jsontag = '#' + $(this).attr('json');
|
|
1301
|
+
var avatarDropzone = null;
|
|
1302
|
+
$tag.dropzone({
|
|
1303
|
+
url: $tag.data('url'),
|
|
1304
|
+
maxFiles: 1,
|
|
1305
|
+
paramName: 'file',
|
|
1306
|
+
parallelUploads: 1,
|
|
1307
|
+
acceptedFiles: $tag.data('types') || ".png,.jpg,.jpeg,.gif",
|
|
1308
|
+
autoProcessQueue: true,
|
|
1309
|
+
previewsContainer: false,
|
|
1310
|
+
clickable: tag,
|
|
1311
|
+
init: function () {
|
|
1312
|
+
avatarDropzone = this;
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
avatarDropzone.on("addedfile", function () {
|
|
1316
|
+
});
|
|
1317
|
+
avatarDropzone.on("totaluploadprogress", function (progress) {
|
|
1318
|
+
$(".upload-progress-bar." + tag.replace('#', '') + " .progress-bar").css({ width: progress + "%" });
|
|
1319
|
+
});
|
|
1320
|
+
avatarDropzone.on("sending", function (file) {
|
|
1321
|
+
$(".upload-progress-bar." + tag.replace('#', '')).show();
|
|
1322
|
+
$($tag.data('preview')).addClass('loading');
|
|
1323
|
+
});
|
|
1324
|
+
avatarDropzone.on("queuecomplete", function (progress) {
|
|
1325
|
+
$(".upload-progress-bar." + tag.replace('#', '')).hide();
|
|
1326
|
+
});
|
|
1327
|
+
avatarDropzone.on("success", function (file, response) {
|
|
1328
|
+
if (response.success) {
|
|
1329
|
+
if (response.media) {
|
|
1330
|
+
$(jsontag).val(JSON.stringify(response.media));
|
|
1331
|
+
$($tag.data('preview')).css({
|
|
1332
|
+
'background-image': 'url(' + response.media.smallUrl + ')'
|
|
1333
|
+
});
|
|
1334
|
+
$($tag.data('preview')).find('img').attr('src', response.media.smallUrl);
|
|
1335
|
+
}
|
|
1336
|
+
Alerts.success("New image added!");
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
Alerts.error("There was a problem adding the image: " + response.error);
|
|
1340
|
+
}
|
|
1341
|
+
avatarDropzone.removeFile(file);
|
|
1342
|
+
$($tag.data('preview')).removeClass('loading');
|
|
1343
|
+
});
|
|
1344
|
+
};
|
|
1345
|
+
Uploader.prototype.gallery = function () {
|
|
1346
|
+
var tag = '#' + $(this).attr('id');
|
|
1347
|
+
var $tag = $(tag);
|
|
1348
|
+
var previewNode = document.querySelector(tag + "-template");
|
|
1349
|
+
previewNode.id = "";
|
|
1350
|
+
var previewTemplate = previewNode.parentNode.innerHTML;
|
|
1351
|
+
previewNode.parentNode.removeChild(previewNode);
|
|
1352
|
+
var galleryDropzone = null;
|
|
1353
|
+
$tag.dropzone({
|
|
1354
|
+
url: $tag.data('url'),
|
|
1355
|
+
thumbnailWidth: 80,
|
|
1356
|
+
thumbnailHeight: 80,
|
|
1357
|
+
parallelUploads: 5,
|
|
1358
|
+
previewTemplate: previewTemplate,
|
|
1359
|
+
paramName: 'files',
|
|
1360
|
+
acceptedFiles: $tag.data('types') || ".png,.jpg,.jpeg,.gif",
|
|
1361
|
+
autoProcessQueue: true,
|
|
1362
|
+
previewsContainer: "#previews",
|
|
1363
|
+
clickable: ".fileinput-button",
|
|
1364
|
+
init: function () {
|
|
1365
|
+
galleryDropzone = this;
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
$(tag + " .cancel").hide();
|
|
1369
|
+
galleryDropzone.on("addedfile", function (file) {
|
|
1370
|
+
$(file.previewElement.querySelector(".complete")).hide();
|
|
1371
|
+
$(file.previewElement.querySelector(".cancel")).show();
|
|
1372
|
+
$(tag + " .cancel").show();
|
|
1373
|
+
});
|
|
1374
|
+
// Update the total progress bar
|
|
1375
|
+
galleryDropzone.on("totaluploadprogress", function (totalProgress, totalBytes, totalBytesSent) {
|
|
1376
|
+
var progressBar = document.querySelector("#total-progress .progress-bar");
|
|
1377
|
+
progressBar.style.width = totalProgress + "%";
|
|
1378
|
+
});
|
|
1379
|
+
galleryDropzone.on("sending", function (file) {
|
|
1380
|
+
// Show the total progress bar when upload starts
|
|
1381
|
+
var progressBar = document.querySelector("#total-progress");
|
|
1382
|
+
progressBar.style.opacity = "1";
|
|
1383
|
+
});
|
|
1384
|
+
// Hide the total progress bar when nothing's uploading anymore
|
|
1385
|
+
galleryDropzone.on("complete", function (file) {
|
|
1386
|
+
$(file.previewElement.querySelector(".cancel")).hide();
|
|
1387
|
+
$(file.previewElement.querySelector(".progress")).hide();
|
|
1388
|
+
$(file.previewElement.querySelector(".complete")).show();
|
|
1389
|
+
console.error("Uploader.Gallery.Dropzone.OnComplete - Inline.Refresh('.gallery') is not implemented.");
|
|
1390
|
+
//Inline.Refresh('.gallery');
|
|
1391
|
+
});
|
|
1392
|
+
// Hide the total progress bar when nothing's uploading anymore
|
|
1393
|
+
galleryDropzone.on("queuecomplete", function (progress) {
|
|
1394
|
+
var totalProgress = document.querySelector("#total-progress");
|
|
1395
|
+
totalProgress.style.opacity = "0";
|
|
1396
|
+
$(tag + " .cancel").hide();
|
|
1397
|
+
});
|
|
1398
|
+
galleryDropzone.on("success", function (file, response) {
|
|
1399
|
+
console.error("Uploader.Gallery.Dropzone.OnSuccess - Inline.Refresh('.gallery') is not implemented.");
|
|
1400
|
+
//Inline.Refresh('.gallery');
|
|
1401
|
+
if (response.success) {
|
|
1402
|
+
Alerts.success("New images added!");
|
|
1403
|
+
}
|
|
1404
|
+
else {
|
|
1405
|
+
Alerts.error("There was a problem adding the profile image: " + response.error);
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
// Setup the buttons for all transfers
|
|
1409
|
+
// The "add files" button doesn't need to be setup because the config
|
|
1410
|
+
// `clickable` has already been specified.
|
|
1411
|
+
$(".actions .cancel").click(function () {
|
|
1412
|
+
galleryDropzone.removeAllFiles(true);
|
|
1413
|
+
});
|
|
1414
|
+
};
|
|
1415
|
+
return Uploader;
|
|
1416
|
+
}());
|
|
1417
|
+
|
|
1418
|
+
var HoodApi = /** @class */ (function () {
|
|
1419
|
+
function HoodApi() {
|
|
1420
|
+
this.alerts = new Alerts();
|
|
1421
|
+
this.uploader = new Uploader();
|
|
1422
|
+
this.handlers = new Handlers();
|
|
1423
|
+
this.editors = new Editors();
|
|
1424
|
+
this.colorPickers = new ColorPickers();
|
|
1425
|
+
this.mediaModal = new MediaModal();
|
|
1426
|
+
// Global Handlers
|
|
1427
|
+
this.setupLoaders();
|
|
1428
|
+
}
|
|
1429
|
+
HoodApi.prototype.setupLoaders = function () {
|
|
1430
|
+
$('body').on('loader-show', function () { Alerts.success("Showing loader..."); });
|
|
1431
|
+
$('body').on('loader-hide', function () { Alerts.error("Hiding loader..."); });
|
|
1432
|
+
};
|
|
1433
|
+
return HoodApi;
|
|
1434
|
+
}());
|
|
1435
|
+
|
|
1436
|
+
var Loader = /** @class */ (function () {
|
|
1437
|
+
function Loader() {
|
|
1438
|
+
new CustomEvent('loader-show');
|
|
1439
|
+
new CustomEvent('loader-hide');
|
|
1440
|
+
}
|
|
1441
|
+
Loader.show = function () {
|
|
1442
|
+
$('body').trigger('loader-show');
|
|
1443
|
+
};
|
|
1444
|
+
Loader.hide = function () {
|
|
1445
|
+
$('body').trigger('loader-hide');
|
|
1446
|
+
};
|
|
1447
|
+
return Loader;
|
|
1448
|
+
}());
|
|
1449
|
+
new Loader();
|
|
1450
|
+
|
|
1451
|
+
var RandomStringGenerator = /** @class */ (function () {
|
|
1452
|
+
function RandomStringGenerator(options) {
|
|
1453
|
+
this.options = {
|
|
1454
|
+
specials: '!@#$&*',
|
|
1455
|
+
alpha: 'abcdefghijklmnopqrstuvwxyz',
|
|
1456
|
+
numeric: '0123456789',
|
|
1457
|
+
numSpecial: 2
|
|
1458
|
+
};
|
|
1459
|
+
this.options = __assign(__assign({}, this.options), options);
|
|
1460
|
+
}
|
|
1461
|
+
RandomStringGenerator.prototype.generate = function (length) {
|
|
1462
|
+
var password = '';
|
|
1463
|
+
var len = Math.ceil((length - this.options.numSpecial) / 2);
|
|
1464
|
+
for (var i = 0; i < len; i++) {
|
|
1465
|
+
password += this.options.alpha.charAt(Math.floor(Math.random() * this.options.alpha.length));
|
|
1466
|
+
password += this.options.numeric.charAt(Math.floor(Math.random() * this.options.numeric.length));
|
|
1467
|
+
}
|
|
1468
|
+
for (var j = 0; j < this.options.numSpecial; j++)
|
|
1469
|
+
password += this.options.specials.charAt(Math.floor(Math.random() * this.options.specials.length));
|
|
1470
|
+
password = password.split('').sort(function () { return 0.5 - Math.random(); }).join('');
|
|
1471
|
+
return password;
|
|
1472
|
+
};
|
|
1473
|
+
return RandomStringGenerator;
|
|
1474
|
+
}());
|
|
1475
|
+
|
|
1476
|
+
$.fn.exists = function () {
|
|
1477
|
+
return $(this).length;
|
|
1478
|
+
};
|
|
1479
|
+
$.fn.restrictToSlug = function (restrictPattern) {
|
|
1480
|
+
if (restrictPattern === void 0) { restrictPattern = /[^0-9a-zA-Z]*/g; }
|
|
1481
|
+
var targets = $(this);
|
|
1482
|
+
// The characters inside this pattern are accepted
|
|
1483
|
+
// and everything else will be 'cleaned'
|
|
1484
|
+
// For example 'ABCdEfGhI5' become 'ABCEGI5'
|
|
1485
|
+
var restrictHandler = function () {
|
|
1486
|
+
var val = $(this).val();
|
|
1487
|
+
var newVal = val.replace(restrictPattern, '');
|
|
1488
|
+
// This condition is to prevent selection and keyboard navigation issues
|
|
1489
|
+
if (val !== newVal) {
|
|
1490
|
+
$(this).val(newVal);
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
targets.on('keyup', restrictHandler);
|
|
1494
|
+
targets.on('paste', restrictHandler);
|
|
1495
|
+
targets.on('change', restrictHandler);
|
|
1496
|
+
};
|
|
1497
|
+
$.fn.restrictToPageSlug = function (restrictPattern) {
|
|
1498
|
+
if (restrictPattern === void 0) { restrictPattern = /[^0-9a-zA-Z-//]*/g; }
|
|
1499
|
+
var targets = $(this);
|
|
1500
|
+
// The characters inside this pattern are accepted
|
|
1501
|
+
// and everything else will be 'cleaned'
|
|
1502
|
+
var restrictHandler = function () {
|
|
1503
|
+
var val = $(this).val();
|
|
1504
|
+
var newVal = val.replace(restrictPattern, '');
|
|
1505
|
+
if ((newVal.match(new RegExp("/", "g")) || []).length > 4) {
|
|
1506
|
+
var pos = newVal.lastIndexOf('/');
|
|
1507
|
+
newVal = newVal.substring(0, pos) + newVal.substring(pos + 1);
|
|
1508
|
+
Alerts.warning("You can only have up to 4 '/' characters in a url slug.");
|
|
1509
|
+
}
|
|
1510
|
+
// This condition is to prevent selection and keyboard navigation issues
|
|
1511
|
+
if (val !== newVal) {
|
|
1512
|
+
$(this).val(newVal);
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
targets.on('keyup', restrictHandler);
|
|
1516
|
+
targets.on('paste', restrictHandler);
|
|
1517
|
+
targets.on('change', restrictHandler);
|
|
1518
|
+
};
|
|
1519
|
+
$.fn.restrictToMetaSlug = function (restrictPattern) {
|
|
1520
|
+
if (restrictPattern === void 0) { restrictPattern = /[^0-9a-zA-Z.]*/g; }
|
|
1521
|
+
var targets = $(this);
|
|
1522
|
+
// The characters inside this pattern are accepted
|
|
1523
|
+
// and everything else will be 'cleaned'
|
|
1524
|
+
var restrictHandler = function () {
|
|
1525
|
+
var val = $(this).val();
|
|
1526
|
+
var newVal = val.replace(restrictPattern, '');
|
|
1527
|
+
if ((newVal.match(new RegExp(".", "g")) || []).length > 1) {
|
|
1528
|
+
var pos = newVal.lastIndexOf('.');
|
|
1529
|
+
newVal = newVal.substring(0, pos) + newVal.substring(pos + 1);
|
|
1530
|
+
Alerts.warning("You can only have up to 1 '.' characters in a meta slug.");
|
|
1531
|
+
}
|
|
1532
|
+
// This condition is to prevent selection and keyboard navigation issues
|
|
1533
|
+
if (val !== newVal) {
|
|
1534
|
+
$(this).val(newVal);
|
|
1535
|
+
}
|
|
1536
|
+
};
|
|
1537
|
+
targets.on('keyup', restrictHandler);
|
|
1538
|
+
targets.on('paste', restrictHandler);
|
|
1539
|
+
targets.on('change', restrictHandler);
|
|
1540
|
+
};
|
|
1541
|
+
$.fn.characterCounter = function () {
|
|
1542
|
+
var targets = $(this);
|
|
1543
|
+
var characterCounterHandler = function () {
|
|
1544
|
+
var counter = $(this).data('counter');
|
|
1545
|
+
var max = Number($(this).attr('maxlength'));
|
|
1546
|
+
var len = $(this).val().length;
|
|
1547
|
+
$(counter).text(max - len);
|
|
1548
|
+
var cls = "text-success";
|
|
1549
|
+
if (max - len < max / 10)
|
|
1550
|
+
cls = "text-danger";
|
|
1551
|
+
$(counter).parent().removeClass('text-success').removeClass('text-danger').addClass(cls);
|
|
1552
|
+
};
|
|
1553
|
+
targets.on('keyup', characterCounterHandler);
|
|
1554
|
+
targets.on('paste', characterCounterHandler);
|
|
1555
|
+
targets.on('change', characterCounterHandler);
|
|
1556
|
+
};
|
|
1557
|
+
$.fn.warningAlert = function () {
|
|
1558
|
+
var targets = $(this);
|
|
1559
|
+
var warningAlertHandler = function (e) {
|
|
1560
|
+
e.preventDefault();
|
|
1561
|
+
var warningAlertCallback = function (result) {
|
|
1562
|
+
if (result.isConfirmed) {
|
|
1563
|
+
var url = $(e.currentTarget).attr('href');
|
|
1564
|
+
window.location.href = url;
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
Alerts.confirm({
|
|
1568
|
+
title: $(e.currentTarget).data('title'),
|
|
1569
|
+
html: $(e.currentTarget).data('warning'),
|
|
1570
|
+
footer: $(e.currentTarget).data('footer'),
|
|
1571
|
+
icon: 'warning'
|
|
1572
|
+
}, warningAlertCallback);
|
|
1573
|
+
return false;
|
|
1574
|
+
};
|
|
1575
|
+
targets.on('click', warningAlertHandler);
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
Number.prototype.formatCurrency = function (currency) {
|
|
1579
|
+
return currency + " " + this.toFixed(2).replace(/./g, function (c, i, a) {
|
|
1580
|
+
return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
|
|
1581
|
+
});
|
|
1582
|
+
};
|
|
1583
|
+
Number.prototype.formatKilobytes = function () {
|
|
1584
|
+
var n = this / 1024;
|
|
1585
|
+
return n.toFixed(0).replace(/./g, function (c, i, a) {
|
|
1586
|
+
return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
|
|
1587
|
+
}) + "Kb";
|
|
1588
|
+
};
|
|
1589
|
+
Number.prototype.formatMegabytes = function () {
|
|
1590
|
+
var n = this / 1024;
|
|
1591
|
+
n = n / 1024;
|
|
1592
|
+
return n.toFixed(0).replace(/./g, function (c, i, a) {
|
|
1593
|
+
return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
|
|
1594
|
+
}) + "Mb";
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
String.prototype.htmlEncode = function () {
|
|
1598
|
+
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
|
|
1599
|
+
//then grab the encoded contents back out. The div never exists on the page.
|
|
1600
|
+
return $('<div/>').text(this).html();
|
|
1601
|
+
};
|
|
1602
|
+
String.prototype.htmlDecode = function () {
|
|
1603
|
+
return $('<div/>').html(this).text();
|
|
1604
|
+
};
|
|
1605
|
+
String.prototype.contains = function (it) {
|
|
1606
|
+
return this.indexOf(it) !== -1;
|
|
1607
|
+
};
|
|
1608
|
+
String.prototype.pick = function (min, max) {
|
|
1609
|
+
var n, chars = '';
|
|
1610
|
+
if (typeof max === 'undefined') {
|
|
1611
|
+
n = min;
|
|
1612
|
+
}
|
|
1613
|
+
else {
|
|
1614
|
+
n = min + Math.floor(Math.random() * (max - min));
|
|
1615
|
+
}
|
|
1616
|
+
for (var i = 0; i < n; i++) {
|
|
1617
|
+
chars += this.charAt(Math.floor(Math.random() * this.length));
|
|
1618
|
+
}
|
|
1619
|
+
return chars;
|
|
1620
|
+
};
|
|
1621
|
+
// Credit to @Christoph: http://stackoverflow.com/a/962890/464744
|
|
1622
|
+
String.prototype.shuffle = function () {
|
|
1623
|
+
var array = this.split('');
|
|
1624
|
+
var tmp, current, top = array.length;
|
|
1625
|
+
if (top)
|
|
1626
|
+
while (--top) {
|
|
1627
|
+
current = Math.floor(Math.random() * (top + 1));
|
|
1628
|
+
tmp = array[current];
|
|
1629
|
+
array[current] = array[top];
|
|
1630
|
+
array[top] = tmp;
|
|
1631
|
+
}
|
|
1632
|
+
return array.join('');
|
|
1633
|
+
};
|
|
1634
|
+
String.prototype.toSeoUrl = function () {
|
|
1635
|
+
var output = this.replace(/[^a-zA-Z0-9]/g, ' ').replace(/\s+/g, "-").toLowerCase();
|
|
1636
|
+
/* remove first dash */
|
|
1637
|
+
if (output.charAt(0) === '-')
|
|
1638
|
+
output = output.substring(1);
|
|
1639
|
+
/* remove last dash */
|
|
1640
|
+
var last = output.length - 1;
|
|
1641
|
+
if (output.charAt(last) === '-')
|
|
1642
|
+
output = output.substring(0, last);
|
|
1643
|
+
return output;
|
|
1644
|
+
};
|
|
1645
|
+
|
|
1646
|
+
var HomeController = /** @class */ (function () {
|
|
1647
|
+
function HomeController() {
|
|
1648
|
+
if ($('#admin-chart-area').length) {
|
|
1649
|
+
var $this_1 = this;
|
|
1650
|
+
$this_1.LoadChart();
|
|
1651
|
+
$('body').on('change', '#history', function () {
|
|
1652
|
+
$this_1.LoadChart();
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
HomeController.prototype.LoadChart = function () {
|
|
1657
|
+
var $this = this;
|
|
1658
|
+
$.get('/admin/stats/', function (data) {
|
|
1659
|
+
$('#admin-chart-area').empty();
|
|
1660
|
+
$('#admin-chart-area').html('<canvas id="admin-stats-chart"></canvas>');
|
|
1661
|
+
$this.LoadStats(data);
|
|
1662
|
+
$this.DrawChart(data);
|
|
1663
|
+
});
|
|
1664
|
+
};
|
|
1665
|
+
HomeController.prototype.DrawChart = function (data) {
|
|
1666
|
+
var datasets = [];
|
|
1667
|
+
var dataLabels = [];
|
|
1668
|
+
var contentColour = '#fabd07';
|
|
1669
|
+
var propertyColour = '#20c997';
|
|
1670
|
+
var userColour = '#fd7e14';
|
|
1671
|
+
// 12 months
|
|
1672
|
+
var labels = [];
|
|
1673
|
+
// Content by day
|
|
1674
|
+
var contentSet = [];
|
|
1675
|
+
data.content.months.forEach(function (element) {
|
|
1676
|
+
contentSet.push(element.value);
|
|
1677
|
+
labels.push(element.key);
|
|
1678
|
+
});
|
|
1679
|
+
datasets.push({
|
|
1680
|
+
label: 'New Content',
|
|
1681
|
+
data: contentSet,
|
|
1682
|
+
borderColor: contentColour,
|
|
1683
|
+
backgroundColor: contentColour,
|
|
1684
|
+
pointBackgroundColor: contentColour,
|
|
1685
|
+
pointBorderColor: '#ffffff'
|
|
1686
|
+
});
|
|
1687
|
+
// users by day
|
|
1688
|
+
contentSet = [];
|
|
1689
|
+
data.users.months.forEach(function (element) {
|
|
1690
|
+
contentSet.push(element.value);
|
|
1691
|
+
});
|
|
1692
|
+
datasets.push({
|
|
1693
|
+
label: 'New Users',
|
|
1694
|
+
data: contentSet,
|
|
1695
|
+
borderColor: userColour,
|
|
1696
|
+
backgroundColor: userColour,
|
|
1697
|
+
pointBackgroundColor: userColour,
|
|
1698
|
+
pointBorderColor: '#ffffff'
|
|
1699
|
+
});
|
|
1700
|
+
// Properties by day
|
|
1701
|
+
contentSet = [];
|
|
1702
|
+
data.properties.months.forEach(function (element) {
|
|
1703
|
+
contentSet.push(element.value);
|
|
1704
|
+
});
|
|
1705
|
+
datasets.push({
|
|
1706
|
+
label: 'New Properties',
|
|
1707
|
+
data: contentSet,
|
|
1708
|
+
borderColor: propertyColour,
|
|
1709
|
+
backgroundColor: propertyColour,
|
|
1710
|
+
pointBackgroundColor: propertyColour,
|
|
1711
|
+
pointBorderColor: '#ffffff'
|
|
1712
|
+
});
|
|
1713
|
+
dataLabels = labels;
|
|
1714
|
+
this.canvas = document.getElementById("admin-stats-chart");
|
|
1715
|
+
this.ctx = this.canvas.getContext('2d');
|
|
1716
|
+
this.chart = new chart_js.Chart(this.ctx, {
|
|
1717
|
+
type: 'bar',
|
|
1718
|
+
data: {
|
|
1719
|
+
labels: dataLabels,
|
|
1720
|
+
datasets: datasets
|
|
1721
|
+
},
|
|
1722
|
+
options: {
|
|
1723
|
+
responsive: true,
|
|
1724
|
+
maintainAspectRatio: false,
|
|
1725
|
+
scales: {
|
|
1726
|
+
ticks: {
|
|
1727
|
+
beginAtZero: true
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
});
|
|
1732
|
+
};
|
|
1733
|
+
HomeController.prototype.LoadStats = function (data) {
|
|
1734
|
+
if (data.content) {
|
|
1735
|
+
$('.content-totalPosts').text(data.content.totalPosts);
|
|
1736
|
+
$('.content-totalPublished').text(data.content.totalPublished);
|
|
1737
|
+
if (data.content.byType) {
|
|
1738
|
+
for (var i = 0; i < data.content.byType.length; i++) {
|
|
1739
|
+
$('.content-' + data.content.byType[i].name + '-total').text(data.content.byType[i].total);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (data.users) {
|
|
1744
|
+
$('.users-totalUsers').text(data.users.totalUsers);
|
|
1745
|
+
$('.users-totalAdmins').text(data.users.totalAdmins);
|
|
1746
|
+
}
|
|
1747
|
+
if (data.properties) {
|
|
1748
|
+
$('.properties-totalPosts').text(data.properties.totalProperties);
|
|
1749
|
+
$('.properties-totalPublished').text(data.properties.totalPublished);
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
return HomeController;
|
|
1753
|
+
}());
|
|
1754
|
+
|
|
1755
|
+
var MediaController = /** @class */ (function () {
|
|
1756
|
+
function MediaController() {
|
|
1757
|
+
this.manage();
|
|
1758
|
+
}
|
|
1759
|
+
MediaController.prototype.manage = function () {
|
|
1760
|
+
this.list = document.getElementById('media-list');
|
|
1761
|
+
this.service = new MediaService(this.list, {
|
|
1762
|
+
action: 'show',
|
|
1763
|
+
onAction: function (mediaObject) {
|
|
1764
|
+
Alerts.log("Showing media object id ".concat(mediaObject.id, " - ").concat(mediaObject.filename));
|
|
1765
|
+
}.bind(this),
|
|
1766
|
+
onListLoad: function () {
|
|
1767
|
+
Alerts.log('Commencing media list fetch.');
|
|
1768
|
+
},
|
|
1769
|
+
onError: function (jqXHR, textStatus, errorThrown) {
|
|
1770
|
+
Alerts.log("Error loading media list: ".concat(textStatus));
|
|
1771
|
+
},
|
|
1772
|
+
onListRender: function (data) {
|
|
1773
|
+
Alerts.log('Fetched media list data.');
|
|
1774
|
+
return data;
|
|
1775
|
+
},
|
|
1776
|
+
onListComplete: function () {
|
|
1777
|
+
Alerts.log('Finished loading media list...', 'info');
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
};
|
|
1781
|
+
return MediaController;
|
|
1782
|
+
}());
|
|
1783
|
+
|
|
1784
|
+
var ContentController = /** @class */ (function () {
|
|
1785
|
+
function ContentController() {
|
|
1786
|
+
this.manage();
|
|
1787
|
+
$('body').on('click', '.content-create', this.create.bind(this));
|
|
1788
|
+
$('body').on('click', '.content-delete', this.delete.bind(this));
|
|
1789
|
+
$('body').on('click', '.content-set-status', this.setStatus.bind(this));
|
|
1790
|
+
$('body').on('click', '.content-categories-delete', this.deleteCategory.bind(this));
|
|
1791
|
+
$('body').on('click', '.content-categories-create,.content-categories-edit', this.createOrEditCategory.bind(this));
|
|
1792
|
+
$('body').on('change', '.content-categories-check', this.toggleCategory.bind(this));
|
|
1793
|
+
$('body').on('click', '.content-media-delete', this.removeMedia.bind(this));
|
|
1794
|
+
$('body').on('keyup', '#Slug', function () {
|
|
1795
|
+
var slugValue = $(this).val();
|
|
1796
|
+
$('.slug-display').html(slugValue);
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
ContentController.prototype.manage = function () {
|
|
1800
|
+
this.element = document.getElementById('content-list');
|
|
1801
|
+
if (this.element) {
|
|
1802
|
+
this.list = new DataList(this.element, {
|
|
1803
|
+
onComplete: function (data, sender) {
|
|
1804
|
+
Alerts.log('Finished loading content list.', 'info');
|
|
1805
|
+
}.bind(this)
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
this.categoryElement = document.getElementById('content-categories-list');
|
|
1809
|
+
if (this.categoryElement) {
|
|
1810
|
+
this.categoryList = new DataList(this.categoryElement, {
|
|
1811
|
+
onComplete: function (data, sender) {
|
|
1812
|
+
Alerts.log('Finished loading category list.', 'info');
|
|
1813
|
+
}.bind(this)
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
ContentController.prototype.create = function (e) {
|
|
1818
|
+
e.preventDefault();
|
|
1819
|
+
e.stopPropagation();
|
|
1820
|
+
var createContentModal = new ModalController({
|
|
1821
|
+
onComplete: function () {
|
|
1822
|
+
var form = document.getElementById('content-create-form');
|
|
1823
|
+
new Validator(form, {
|
|
1824
|
+
onComplete: function (response) {
|
|
1825
|
+
Response.process(response, 5000);
|
|
1826
|
+
if (this.list) {
|
|
1827
|
+
this.list.reload();
|
|
1828
|
+
}
|
|
1829
|
+
if (response.success) {
|
|
1830
|
+
createContentModal.close();
|
|
1831
|
+
}
|
|
1832
|
+
}.bind(this)
|
|
1833
|
+
});
|
|
1834
|
+
}.bind(this)
|
|
1835
|
+
});
|
|
1836
|
+
createContentModal.show($(e.currentTarget).attr('href'), this.element);
|
|
1837
|
+
};
|
|
1838
|
+
ContentController.prototype.delete = function (e) {
|
|
1839
|
+
e.preventDefault();
|
|
1840
|
+
e.stopPropagation();
|
|
1841
|
+
Alerts.confirm({
|
|
1842
|
+
// Confirm options...
|
|
1843
|
+
title: "Are you sure?",
|
|
1844
|
+
html: "The content will be permanently removed."
|
|
1845
|
+
}, function (result) {
|
|
1846
|
+
if (result.isConfirmed) {
|
|
1847
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
1848
|
+
Response.process(data, 5000);
|
|
1849
|
+
if (this.list) {
|
|
1850
|
+
this.list.reload();
|
|
1851
|
+
}
|
|
1852
|
+
if (e.currentTarget.dataset.redirect) {
|
|
1853
|
+
Alerts.message('Just taking you back to the content list.', 'Redirecting...');
|
|
1854
|
+
setTimeout(function () {
|
|
1855
|
+
window.location = e.currentTarget.dataset.redirect;
|
|
1856
|
+
}, 1500);
|
|
1857
|
+
}
|
|
1858
|
+
}.bind(this));
|
|
1859
|
+
}
|
|
1860
|
+
}.bind(this));
|
|
1861
|
+
};
|
|
1862
|
+
ContentController.prototype.setStatus = function (e) {
|
|
1863
|
+
e.preventDefault();
|
|
1864
|
+
e.stopPropagation();
|
|
1865
|
+
Alerts.confirm({
|
|
1866
|
+
// Confirm options...
|
|
1867
|
+
title: "Are you sure?",
|
|
1868
|
+
html: "The change will happen immediately."
|
|
1869
|
+
}, function (result) {
|
|
1870
|
+
if (result.isConfirmed) {
|
|
1871
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
1872
|
+
Response.process(data, 5000);
|
|
1873
|
+
if (this.list) {
|
|
1874
|
+
this.list.reload();
|
|
1875
|
+
}
|
|
1876
|
+
}.bind(this));
|
|
1877
|
+
}
|
|
1878
|
+
}.bind(this));
|
|
1879
|
+
};
|
|
1880
|
+
ContentController.prototype.clone = function (e) {
|
|
1881
|
+
e.preventDefault();
|
|
1882
|
+
e.stopPropagation();
|
|
1883
|
+
Alerts.confirm({
|
|
1884
|
+
// Confirm options...
|
|
1885
|
+
title: "Are you sure?",
|
|
1886
|
+
html: "This will duplicate the content and everything inside it."
|
|
1887
|
+
}, function (result) {
|
|
1888
|
+
if (result.isConfirmed) {
|
|
1889
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
1890
|
+
Response.process(data, 5000);
|
|
1891
|
+
if (this.list) {
|
|
1892
|
+
this.list.reload();
|
|
1893
|
+
}
|
|
1894
|
+
}.bind(this));
|
|
1895
|
+
}
|
|
1896
|
+
}.bind(this));
|
|
1897
|
+
};
|
|
1898
|
+
ContentController.prototype.createOrEditCategory = function (e) {
|
|
1899
|
+
e.preventDefault();
|
|
1900
|
+
e.stopPropagation();
|
|
1901
|
+
var createCategoryModal = new ModalController({
|
|
1902
|
+
onComplete: function () {
|
|
1903
|
+
var form = document.getElementById('content-categories-edit-form');
|
|
1904
|
+
new Validator(form, {
|
|
1905
|
+
onComplete: function (response) {
|
|
1906
|
+
Response.process(response, 5000);
|
|
1907
|
+
if (this.list) {
|
|
1908
|
+
this.list.reload();
|
|
1909
|
+
}
|
|
1910
|
+
if (response.success) {
|
|
1911
|
+
this.categoryList.reload();
|
|
1912
|
+
createCategoryModal.close();
|
|
1913
|
+
}
|
|
1914
|
+
}.bind(this)
|
|
1915
|
+
});
|
|
1916
|
+
}.bind(this)
|
|
1917
|
+
});
|
|
1918
|
+
createCategoryModal.show($(e.currentTarget).attr('href'), this.element);
|
|
1919
|
+
};
|
|
1920
|
+
ContentController.prototype.deleteCategory = function (e) {
|
|
1921
|
+
e.preventDefault();
|
|
1922
|
+
e.stopPropagation();
|
|
1923
|
+
Alerts.confirm({
|
|
1924
|
+
// Confirm options...
|
|
1925
|
+
}, function (result) {
|
|
1926
|
+
if (result.isConfirmed) {
|
|
1927
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
1928
|
+
// category deleted...
|
|
1929
|
+
Response.process(data, 5000);
|
|
1930
|
+
this.categoryList.reload();
|
|
1931
|
+
}.bind(this));
|
|
1932
|
+
}
|
|
1933
|
+
}.bind(this));
|
|
1934
|
+
};
|
|
1935
|
+
ContentController.prototype.toggleCategory = function (e) {
|
|
1936
|
+
e.preventDefault();
|
|
1937
|
+
e.stopPropagation();
|
|
1938
|
+
$.post($(e.currentTarget).data('url'), { categoryId: $(e.currentTarget).val(), add: $(e.currentTarget).is(':checked') }, function (response) {
|
|
1939
|
+
Response.process(response, 5000);
|
|
1940
|
+
if (this.categoryList) {
|
|
1941
|
+
this.categoryList.reload();
|
|
1942
|
+
}
|
|
1943
|
+
}.bind(this));
|
|
1944
|
+
};
|
|
1945
|
+
ContentController.prototype.removeMedia = function (e) {
|
|
1946
|
+
e.preventDefault();
|
|
1947
|
+
e.stopPropagation();
|
|
1948
|
+
Alerts.confirm({
|
|
1949
|
+
// Confirm options...
|
|
1950
|
+
title: "Are you sure?",
|
|
1951
|
+
html: "The media will be removed from the property, but will still be in the media collection."
|
|
1952
|
+
}, function (result) {
|
|
1953
|
+
if (result.isConfirmed) {
|
|
1954
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
1955
|
+
Response.process(data, 5000);
|
|
1956
|
+
// reload the property media gallery, should be attached to #property-gallery-list
|
|
1957
|
+
var mediaGalleryEl = document.getElementById('content-gallery-list');
|
|
1958
|
+
if (mediaGalleryEl.hoodDataList) {
|
|
1959
|
+
mediaGalleryEl.hoodDataList.reload();
|
|
1960
|
+
}
|
|
1961
|
+
}.bind(this));
|
|
1962
|
+
}
|
|
1963
|
+
}.bind(this));
|
|
1964
|
+
};
|
|
1965
|
+
return ContentController;
|
|
1966
|
+
}());
|
|
1967
|
+
|
|
1968
|
+
var PropertyController = /** @class */ (function () {
|
|
1969
|
+
function PropertyController() {
|
|
1970
|
+
this.manage();
|
|
1971
|
+
$('body').on('click', '.property-create', this.create.bind(this));
|
|
1972
|
+
$('body').on('click', '.property-delete', this.delete.bind(this));
|
|
1973
|
+
$('body').on('click', '.property-set-status', this.setStatus.bind(this));
|
|
1974
|
+
$('body').on('click', '.property-media-delete', this.removeMedia.bind(this));
|
|
1975
|
+
$('body').on('click', '.property-floorplan-delete', this.removeMedia.bind(this));
|
|
1976
|
+
$('body').on('keyup', '#Slug', function () {
|
|
1977
|
+
var slugValue = $(this).val();
|
|
1978
|
+
$('.slug-display').html(slugValue);
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
PropertyController.prototype.manage = function () {
|
|
1982
|
+
this.element = document.getElementById('property-list');
|
|
1983
|
+
if (this.element) {
|
|
1984
|
+
this.list = new DataList(this.element, {
|
|
1985
|
+
onComplete: function (data, sender) {
|
|
1986
|
+
Alerts.log('Finished loading property list.', 'info');
|
|
1987
|
+
}.bind(this)
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
PropertyController.prototype.create = function (e) {
|
|
1992
|
+
e.preventDefault();
|
|
1993
|
+
e.stopPropagation();
|
|
1994
|
+
var createPropertyModal = new ModalController({
|
|
1995
|
+
onComplete: function () {
|
|
1996
|
+
var form = document.getElementById('property-create-form');
|
|
1997
|
+
new Validator(form, {
|
|
1998
|
+
onComplete: function (response) {
|
|
1999
|
+
Response.process(response, 5000);
|
|
2000
|
+
if (this.list) {
|
|
2001
|
+
this.list.reload();
|
|
2002
|
+
}
|
|
2003
|
+
if (response.success) {
|
|
2004
|
+
createPropertyModal.close();
|
|
2005
|
+
}
|
|
2006
|
+
}.bind(this)
|
|
2007
|
+
});
|
|
2008
|
+
}.bind(this)
|
|
2009
|
+
});
|
|
2010
|
+
createPropertyModal.show($(e.currentTarget).attr('href'), this.element);
|
|
2011
|
+
};
|
|
2012
|
+
PropertyController.prototype.delete = function (e) {
|
|
2013
|
+
e.preventDefault();
|
|
2014
|
+
e.stopPropagation();
|
|
2015
|
+
Alerts.confirm({
|
|
2016
|
+
// Confirm options...
|
|
2017
|
+
title: "Are you sure?",
|
|
2018
|
+
html: "The property will be permanently removed."
|
|
2019
|
+
}, function (result) {
|
|
2020
|
+
if (result.isConfirmed) {
|
|
2021
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2022
|
+
Response.process(data, 5000);
|
|
2023
|
+
if (this.list) {
|
|
2024
|
+
this.list.reload();
|
|
2025
|
+
}
|
|
2026
|
+
if (e.currentTarget.dataset.redirect) {
|
|
2027
|
+
Alerts.message('Just taking you back to the property list.', 'Redirecting...');
|
|
2028
|
+
setTimeout(function () {
|
|
2029
|
+
window.location = e.currentTarget.dataset.redirect;
|
|
2030
|
+
}, 1500);
|
|
2031
|
+
}
|
|
2032
|
+
}.bind(this));
|
|
2033
|
+
}
|
|
2034
|
+
}.bind(this));
|
|
2035
|
+
};
|
|
2036
|
+
PropertyController.prototype.setStatus = function (e) {
|
|
2037
|
+
e.preventDefault();
|
|
2038
|
+
e.stopPropagation();
|
|
2039
|
+
Alerts.confirm({
|
|
2040
|
+
// Confirm options...
|
|
2041
|
+
title: "Are you sure?",
|
|
2042
|
+
html: "The change will happen immediately."
|
|
2043
|
+
}, function (result) {
|
|
2044
|
+
if (result.isConfirmed) {
|
|
2045
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2046
|
+
Response.process(data, 5000);
|
|
2047
|
+
if (this.list) {
|
|
2048
|
+
this.list.reload();
|
|
2049
|
+
}
|
|
2050
|
+
}.bind(this));
|
|
2051
|
+
}
|
|
2052
|
+
}.bind(this));
|
|
2053
|
+
};
|
|
2054
|
+
PropertyController.prototype.removeMedia = function (e) {
|
|
2055
|
+
e.preventDefault();
|
|
2056
|
+
e.stopPropagation();
|
|
2057
|
+
Alerts.confirm({
|
|
2058
|
+
// Confirm options...
|
|
2059
|
+
title: "Are you sure?",
|
|
2060
|
+
html: "The media will be removed from the property, but will still be in the media collection."
|
|
2061
|
+
}, function (result) {
|
|
2062
|
+
if (result.isConfirmed) {
|
|
2063
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2064
|
+
Response.process(data, 5000);
|
|
2065
|
+
// reload the property media gallery, should be attached to #property-gallery-list
|
|
2066
|
+
var mediaGalleryEl = document.getElementById('property-gallery-list');
|
|
2067
|
+
if (mediaGalleryEl.hoodDataList) {
|
|
2068
|
+
mediaGalleryEl.hoodDataList.reload();
|
|
2069
|
+
}
|
|
2070
|
+
// reload the property media gallery, should be attached to #property-gallery-list
|
|
2071
|
+
var mfpGalleryEl = document.getElementById('property-floorplan-list');
|
|
2072
|
+
if (mfpGalleryEl && mfpGalleryEl.hoodDataList) {
|
|
2073
|
+
mfpGalleryEl.hoodDataList.reload();
|
|
2074
|
+
}
|
|
2075
|
+
}.bind(this));
|
|
2076
|
+
}
|
|
2077
|
+
}.bind(this));
|
|
2078
|
+
};
|
|
2079
|
+
return PropertyController;
|
|
2080
|
+
}());
|
|
2081
|
+
|
|
2082
|
+
var UsersController = /** @class */ (function () {
|
|
2083
|
+
function UsersController() {
|
|
2084
|
+
this.initLists();
|
|
2085
|
+
$('body').on('click', '.user-create', this.create.bind(this));
|
|
2086
|
+
$('body').on('click', '.user-delete', this.delete.bind(this));
|
|
2087
|
+
$('body').on('change', '#user-create-form #GeneratePassword', this.generatePassword);
|
|
2088
|
+
$('body').on('change', '.user-role-check', this.toggleUserRole);
|
|
2089
|
+
$('body').on('click', '.user-reset-password', this.resetPassword);
|
|
2090
|
+
$('body').on('click', '.user-notes-add', this.addNote.bind(this));
|
|
2091
|
+
$('body').on('click', '.user-notes-delete', this.deleteNote.bind(this));
|
|
2092
|
+
}
|
|
2093
|
+
UsersController.prototype.initLists = function () {
|
|
2094
|
+
this.element = document.getElementById('user-list');
|
|
2095
|
+
if (this.element) {
|
|
2096
|
+
this.list = new DataList(this.element, {
|
|
2097
|
+
onComplete: function (data, sender) {
|
|
2098
|
+
Alerts.log('Finished loading users list.', 'info');
|
|
2099
|
+
}.bind(this)
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
this.notesEl = document.getElementById('user-notes');
|
|
2103
|
+
if (this.notesEl) {
|
|
2104
|
+
this.notesList = new DataList(this.notesEl, {
|
|
2105
|
+
onComplete: function (data, sender) {
|
|
2106
|
+
Alerts.log('Finished loading user notes list.', 'info');
|
|
2107
|
+
}.bind(this)
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
UsersController.prototype.create = function (e) {
|
|
2112
|
+
e.preventDefault();
|
|
2113
|
+
e.stopPropagation();
|
|
2114
|
+
var createUserModal = new ModalController({
|
|
2115
|
+
onComplete: function () {
|
|
2116
|
+
var form = document.getElementById('user-create-form');
|
|
2117
|
+
new Validator(form, {
|
|
2118
|
+
onComplete: function (response) {
|
|
2119
|
+
Response.process(response, 5000);
|
|
2120
|
+
if (this.list) {
|
|
2121
|
+
this.list.reload();
|
|
2122
|
+
}
|
|
2123
|
+
if (response.success) {
|
|
2124
|
+
createUserModal.close();
|
|
2125
|
+
}
|
|
2126
|
+
}.bind(this)
|
|
2127
|
+
});
|
|
2128
|
+
}.bind(this)
|
|
2129
|
+
});
|
|
2130
|
+
createUserModal.show($(e.currentTarget).attr('href'), this.element);
|
|
2131
|
+
};
|
|
2132
|
+
UsersController.prototype.delete = function (e) {
|
|
2133
|
+
e.preventDefault();
|
|
2134
|
+
e.stopPropagation();
|
|
2135
|
+
Alerts.confirm({
|
|
2136
|
+
// Confirm options...
|
|
2137
|
+
title: "Are you sure?",
|
|
2138
|
+
html: "The user will be permanently removed."
|
|
2139
|
+
}, function (result) {
|
|
2140
|
+
if (result.isConfirmed) {
|
|
2141
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2142
|
+
Response.process(data, 5000);
|
|
2143
|
+
if (this.list) {
|
|
2144
|
+
this.list.reload();
|
|
2145
|
+
}
|
|
2146
|
+
if (e.currentTarget.dataset.redirect) {
|
|
2147
|
+
Alerts.message('Just taking you back to the content list.', 'Redirecting...');
|
|
2148
|
+
setTimeout(function () {
|
|
2149
|
+
window.location = e.currentTarget.dataset.redirect;
|
|
2150
|
+
}, 1500);
|
|
2151
|
+
}
|
|
2152
|
+
}.bind(this));
|
|
2153
|
+
}
|
|
2154
|
+
}.bind(this));
|
|
2155
|
+
};
|
|
2156
|
+
UsersController.prototype.generatePassword = function () {
|
|
2157
|
+
if ($(this).is(':checked')) {
|
|
2158
|
+
var generator = new RandomStringGenerator({ numSpecial: 1 });
|
|
2159
|
+
$('#user-create-form #Password').val(generator.generate(8));
|
|
2160
|
+
$('#user-create-form #Password').attr('type', 'text');
|
|
2161
|
+
}
|
|
2162
|
+
else {
|
|
2163
|
+
$('#user-create-form #Password').val('');
|
|
2164
|
+
$('#user-create-form #Password').attr('type', 'password');
|
|
2165
|
+
}
|
|
2166
|
+
};
|
|
2167
|
+
UsersController.prototype.toggleUserRole = function () {
|
|
2168
|
+
if ($(this).is(':checked')) {
|
|
2169
|
+
$.post($(this).data('url'), { role: $(this).val(), add: true }, function (data) {
|
|
2170
|
+
Response.process(data);
|
|
2171
|
+
});
|
|
2172
|
+
}
|
|
2173
|
+
else {
|
|
2174
|
+
$.post($(this).data('url'), { role: $(this).val(), add: false }, function (data) {
|
|
2175
|
+
Response.process(data);
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
};
|
|
2179
|
+
UsersController.prototype.resetPassword = function (e) {
|
|
2180
|
+
e.preventDefault();
|
|
2181
|
+
e.stopPropagation();
|
|
2182
|
+
Alerts.prompt({
|
|
2183
|
+
// Confirm options...
|
|
2184
|
+
title: "Reset Password",
|
|
2185
|
+
html: "Please enter a new password for the user...",
|
|
2186
|
+
preConfirm: function (inputValue) {
|
|
2187
|
+
if (inputValue === false)
|
|
2188
|
+
return false;
|
|
2189
|
+
if (inputValue === "") {
|
|
2190
|
+
swal__default["default"].showValidationMessage("You didn't supply a new password, we can't reset the password without it!");
|
|
2191
|
+
return false;
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
}, function (result) {
|
|
2195
|
+
if (result.isDismissed) {
|
|
2196
|
+
return false;
|
|
2197
|
+
}
|
|
2198
|
+
$.post(e.currentTarget.href, { password: result.value }, function (data) {
|
|
2199
|
+
Response.process(data, 5000);
|
|
2200
|
+
});
|
|
2201
|
+
}.bind(this));
|
|
2202
|
+
};
|
|
2203
|
+
UsersController.prototype.addNote = function (e) {
|
|
2204
|
+
e.preventDefault();
|
|
2205
|
+
e.stopPropagation();
|
|
2206
|
+
Alerts.prompt({
|
|
2207
|
+
// Confirm options...
|
|
2208
|
+
title: "Add a note",
|
|
2209
|
+
html: "Enter and store a note about this user.",
|
|
2210
|
+
input: 'textarea',
|
|
2211
|
+
preConfirm: function (inputValue) {
|
|
2212
|
+
if (inputValue === false)
|
|
2213
|
+
return false;
|
|
2214
|
+
if (inputValue === "") {
|
|
2215
|
+
swal__default["default"].showValidationMessage("You didn't enter a note!");
|
|
2216
|
+
return false;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}, function (result) {
|
|
2220
|
+
if (result.isDismissed) {
|
|
2221
|
+
return false;
|
|
2222
|
+
}
|
|
2223
|
+
$.post(e.currentTarget.href, { note: result.value }, function (data) {
|
|
2224
|
+
Response.process(data, 5000);
|
|
2225
|
+
if (this.notesList) {
|
|
2226
|
+
this.notesList.reload();
|
|
2227
|
+
}
|
|
2228
|
+
}.bind(this));
|
|
2229
|
+
}.bind(this));
|
|
2230
|
+
};
|
|
2231
|
+
UsersController.prototype.deleteNote = function (e) {
|
|
2232
|
+
e.preventDefault();
|
|
2233
|
+
e.stopPropagation();
|
|
2234
|
+
Alerts.confirm({
|
|
2235
|
+
// Confirm options...
|
|
2236
|
+
title: "Are you sure?",
|
|
2237
|
+
html: "The note will be permanently removed."
|
|
2238
|
+
}, function (result) {
|
|
2239
|
+
if (result.isConfirmed) {
|
|
2240
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2241
|
+
Response.process(data, 5000);
|
|
2242
|
+
if (this.notesList) {
|
|
2243
|
+
this.notesList.reload();
|
|
2244
|
+
}
|
|
2245
|
+
}.bind(this));
|
|
2246
|
+
}
|
|
2247
|
+
}.bind(this));
|
|
2248
|
+
};
|
|
2249
|
+
return UsersController;
|
|
2250
|
+
}());
|
|
2251
|
+
|
|
2252
|
+
var ThemesController = /** @class */ (function () {
|
|
2253
|
+
function ThemesController() {
|
|
2254
|
+
$('body').on('click', '.activate-theme', this.activate.bind(this));
|
|
2255
|
+
this.element = document.getElementById('themes-list');
|
|
2256
|
+
if (this.element) {
|
|
2257
|
+
this.list = new DataList(this.element, {
|
|
2258
|
+
onComplete: function (data, sender) {
|
|
2259
|
+
Alerts.log('Finished loading users list.', 'info');
|
|
2260
|
+
}.bind(this)
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
ThemesController.prototype.activate = function (e) {
|
|
2265
|
+
e.preventDefault();
|
|
2266
|
+
e.stopPropagation();
|
|
2267
|
+
Alerts.confirm({
|
|
2268
|
+
// Confirm options...
|
|
2269
|
+
title: "Are you sure?",
|
|
2270
|
+
html: "The site will change themes, and the selected theme will be live right away."
|
|
2271
|
+
}, function (result) {
|
|
2272
|
+
if (result.isConfirmed) {
|
|
2273
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2274
|
+
Response.process(data, 5000);
|
|
2275
|
+
setTimeout(function () {
|
|
2276
|
+
if (this.list) {
|
|
2277
|
+
this.list.reload();
|
|
2278
|
+
}
|
|
2279
|
+
}.bind(this), 2000);
|
|
2280
|
+
}.bind(this));
|
|
2281
|
+
}
|
|
2282
|
+
}.bind(this));
|
|
2283
|
+
};
|
|
2284
|
+
return ThemesController;
|
|
2285
|
+
}());
|
|
2286
|
+
|
|
2287
|
+
var ContentTypeController = /** @class */ (function () {
|
|
2288
|
+
function ContentTypeController() {
|
|
2289
|
+
this.manage();
|
|
2290
|
+
$('body').on('click', '.content-type-create', this.create.bind(this));
|
|
2291
|
+
$('body').on('click', '.content-type-delete', this.delete.bind(this));
|
|
2292
|
+
$('body').on('click', '.content-type-set-status', this.setStatus.bind(this));
|
|
2293
|
+
$('body').on('click', '.content-custom-field-create', this.createField.bind(this));
|
|
2294
|
+
$('body').on('click', '.content-custom-field-delete', this.deleteField.bind(this));
|
|
2295
|
+
$('body').on('keyup', '#Slug', function () {
|
|
2296
|
+
var slugValue = $(this).val();
|
|
2297
|
+
$('.slug-display').html(slugValue);
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
ContentTypeController.prototype.manage = function () {
|
|
2301
|
+
this.element = document.getElementById('content-type-list');
|
|
2302
|
+
if (this.element) {
|
|
2303
|
+
this.list = new DataList(this.element, {
|
|
2304
|
+
onComplete: function (data, sender) {
|
|
2305
|
+
Alerts.log('Finished loading content type list.', 'info');
|
|
2306
|
+
}.bind(this)
|
|
2307
|
+
});
|
|
2308
|
+
}
|
|
2309
|
+
this.fieldsElement = document.getElementById('content-custom-field-list');
|
|
2310
|
+
if (this.fieldsElement) {
|
|
2311
|
+
this.fieldsList = new DataList(this.fieldsElement, {
|
|
2312
|
+
onComplete: function (data, sender) {
|
|
2313
|
+
Alerts.log('Finished loading content type list.', 'info');
|
|
2314
|
+
}.bind(this)
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
ContentTypeController.prototype.create = function (e) {
|
|
2319
|
+
e.preventDefault();
|
|
2320
|
+
e.stopPropagation();
|
|
2321
|
+
var createContentModal = new ModalController({
|
|
2322
|
+
onComplete: function () {
|
|
2323
|
+
var form = document.getElementById('content-type-create-form');
|
|
2324
|
+
new Validator(form, {
|
|
2325
|
+
onComplete: function (response) {
|
|
2326
|
+
Response.process(response, 5000);
|
|
2327
|
+
if (this.list) {
|
|
2328
|
+
this.list.reload();
|
|
2329
|
+
}
|
|
2330
|
+
if (response.success) {
|
|
2331
|
+
createContentModal.close();
|
|
2332
|
+
}
|
|
2333
|
+
}.bind(this)
|
|
2334
|
+
});
|
|
2335
|
+
}.bind(this)
|
|
2336
|
+
});
|
|
2337
|
+
createContentModal.show($(e.currentTarget).attr('href'), this.element);
|
|
2338
|
+
};
|
|
2339
|
+
ContentTypeController.prototype.delete = function (e) {
|
|
2340
|
+
e.preventDefault();
|
|
2341
|
+
e.stopPropagation();
|
|
2342
|
+
Alerts.confirm({
|
|
2343
|
+
// Confirm options...
|
|
2344
|
+
title: "Are you sure?",
|
|
2345
|
+
html: "The content type will be permanently removed. Content will remain, but will be unusable and marked as the old content type."
|
|
2346
|
+
}, function (result) {
|
|
2347
|
+
if (result.isConfirmed) {
|
|
2348
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2349
|
+
Response.process(data, 5000);
|
|
2350
|
+
if (this.list) {
|
|
2351
|
+
this.list.reload();
|
|
2352
|
+
}
|
|
2353
|
+
if (e.currentTarget.dataset.redirect) {
|
|
2354
|
+
Alerts.message('Just taking you back to the content list.', 'Redirecting...');
|
|
2355
|
+
setTimeout(function () {
|
|
2356
|
+
window.location = e.currentTarget.dataset.redirect;
|
|
2357
|
+
}, 1500);
|
|
2358
|
+
}
|
|
2359
|
+
}.bind(this));
|
|
2360
|
+
}
|
|
2361
|
+
}.bind(this));
|
|
2362
|
+
};
|
|
2363
|
+
ContentTypeController.prototype.setStatus = function (e) {
|
|
2364
|
+
e.preventDefault();
|
|
2365
|
+
e.stopPropagation();
|
|
2366
|
+
Alerts.confirm({
|
|
2367
|
+
// Confirm options...
|
|
2368
|
+
title: "Are you sure?",
|
|
2369
|
+
html: "The change will happen immediately."
|
|
2370
|
+
}, function (result) {
|
|
2371
|
+
if (result.isConfirmed) {
|
|
2372
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2373
|
+
Response.process(data, 5000);
|
|
2374
|
+
if (this.list) {
|
|
2375
|
+
this.list.reload();
|
|
2376
|
+
}
|
|
2377
|
+
}.bind(this));
|
|
2378
|
+
}
|
|
2379
|
+
}.bind(this));
|
|
2380
|
+
};
|
|
2381
|
+
ContentTypeController.prototype.createField = function (e) {
|
|
2382
|
+
e.preventDefault();
|
|
2383
|
+
e.stopPropagation();
|
|
2384
|
+
var createContentModal = new ModalController({
|
|
2385
|
+
onComplete: function () {
|
|
2386
|
+
var form = document.getElementById('content-custom-field-create-form');
|
|
2387
|
+
new Validator(form, {
|
|
2388
|
+
onComplete: function (response) {
|
|
2389
|
+
Response.process(response, 5000);
|
|
2390
|
+
if (this.fieldsList) {
|
|
2391
|
+
this.fieldsList.reload();
|
|
2392
|
+
}
|
|
2393
|
+
if (response.success) {
|
|
2394
|
+
createContentModal.close();
|
|
2395
|
+
}
|
|
2396
|
+
}.bind(this)
|
|
2397
|
+
});
|
|
2398
|
+
}.bind(this)
|
|
2399
|
+
});
|
|
2400
|
+
createContentModal.show($(e.currentTarget).attr('href'), this.element);
|
|
2401
|
+
};
|
|
2402
|
+
ContentTypeController.prototype.deleteField = function (e) {
|
|
2403
|
+
e.preventDefault();
|
|
2404
|
+
e.stopPropagation();
|
|
2405
|
+
Alerts.confirm({
|
|
2406
|
+
// Confirm options...
|
|
2407
|
+
title: "Are you sure?",
|
|
2408
|
+
html: "The field will be permanently removed. However fields will still be attached to content."
|
|
2409
|
+
}, function (result) {
|
|
2410
|
+
if (result.isConfirmed) {
|
|
2411
|
+
Inline.post(e.currentTarget.href, e.currentTarget, function (data) {
|
|
2412
|
+
Response.process(data, 5000);
|
|
2413
|
+
if (this.fieldsList) {
|
|
2414
|
+
this.fieldsList.reload();
|
|
2415
|
+
}
|
|
2416
|
+
}.bind(this));
|
|
2417
|
+
}
|
|
2418
|
+
}.bind(this));
|
|
2419
|
+
};
|
|
2420
|
+
return ContentTypeController;
|
|
2421
|
+
}());
|
|
2422
|
+
|
|
2423
|
+
var LogsController = /** @class */ (function () {
|
|
2424
|
+
function LogsController() {
|
|
2425
|
+
this.element = document.getElementById('log-list');
|
|
2426
|
+
if (this.element) {
|
|
2427
|
+
this.list = new DataList(this.element, {
|
|
2428
|
+
onComplete: function (data, sender) {
|
|
2429
|
+
Alerts.log('Finished loading logs list.', 'info');
|
|
2430
|
+
}.bind(this)
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
return LogsController;
|
|
2435
|
+
}());
|
|
2436
|
+
|
|
2437
|
+
var PropertyImporter = /** @class */ (function () {
|
|
2438
|
+
function PropertyImporter() {
|
|
2439
|
+
if ($('#import-property-start').length > 0) {
|
|
2440
|
+
this.update();
|
|
2441
|
+
$('#import-property-start').click(function () {
|
|
2442
|
+
$.ajax({
|
|
2443
|
+
url: $('#import-property-start').data('url'),
|
|
2444
|
+
type: "POST",
|
|
2445
|
+
error: Inline.handleError,
|
|
2446
|
+
success: function () {
|
|
2447
|
+
this.update();
|
|
2448
|
+
}.bind(this)
|
|
2449
|
+
});
|
|
2450
|
+
}.bind(this));
|
|
2451
|
+
$('#import-property-cancel').click(function () {
|
|
2452
|
+
$.ajax({
|
|
2453
|
+
url: $('#import-property-cancel').data('url'),
|
|
2454
|
+
type: "POST",
|
|
2455
|
+
error: Inline.handleError,
|
|
2456
|
+
success: function () {
|
|
2457
|
+
this.update();
|
|
2458
|
+
}.bind(this)
|
|
2459
|
+
});
|
|
2460
|
+
}.bind(this));
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
PropertyImporter.prototype.update = function () {
|
|
2464
|
+
$.ajax({
|
|
2465
|
+
url: $('#import-property-status').data('url'),
|
|
2466
|
+
type: "POST",
|
|
2467
|
+
error: Inline.handleError,
|
|
2468
|
+
success: function (result) {
|
|
2469
|
+
if (result.importer.running) {
|
|
2470
|
+
this.showInfo();
|
|
2471
|
+
clearInterval(this.updateInterval);
|
|
2472
|
+
this.updateInterval = window.setTimeout(this.update, 250);
|
|
2473
|
+
}
|
|
2474
|
+
else {
|
|
2475
|
+
clearInterval(this.updateInterval);
|
|
2476
|
+
this.hideInfo();
|
|
2477
|
+
}
|
|
2478
|
+
$('.tp').html(result.importer.total.toString());
|
|
2479
|
+
$('#pu').html(result.importer.updated.toString());
|
|
2480
|
+
$('#pa').html(result.importer.added.toString());
|
|
2481
|
+
$('#pp').html(result.importer.processed.toString());
|
|
2482
|
+
$('#pd').html(result.importer.deleted.toString());
|
|
2483
|
+
$('#ToAdd').html(result.importer.toAdd.toString());
|
|
2484
|
+
$('#ToUpdate').html(result.importer.toUpdate.toString());
|
|
2485
|
+
$('#ToDelete').html(result.importer.toDelete.toString());
|
|
2486
|
+
$('#pt').html(result.importer.statusMessage.toString());
|
|
2487
|
+
var ftpPercentComplete = Math.round(result.ftp.complete * 100) / 100;
|
|
2488
|
+
$('#fp').html(ftpPercentComplete.toString());
|
|
2489
|
+
$('#ft').html(result.ftp.statusMessage);
|
|
2490
|
+
var percentComplete = Math.round(result.importer.complete * 100) / 100;
|
|
2491
|
+
$('.pc').html(percentComplete.toString());
|
|
2492
|
+
$('#progressbar').css({
|
|
2493
|
+
width: result.importer.complete + "%"
|
|
2494
|
+
});
|
|
2495
|
+
if (result.importer.errors.length) {
|
|
2496
|
+
var errorHtml = "";
|
|
2497
|
+
for (var i = result.importer.errors.length - 1; i >= 0; i--) {
|
|
2498
|
+
errorHtml += '<div class="text-danger">' + result.importer.errors[i] + '</div>';
|
|
2499
|
+
}
|
|
2500
|
+
$('#import-property-errors').html(errorHtml);
|
|
2501
|
+
}
|
|
2502
|
+
else {
|
|
2503
|
+
$('#import-property-errors').html("<div>No errors reported.</div>");
|
|
2504
|
+
}
|
|
2505
|
+
if (result.importer.warnings.length) {
|
|
2506
|
+
var warningHtml = "";
|
|
2507
|
+
for (var j = result.importer.warnings.length - 1; j >= 0; j--) {
|
|
2508
|
+
warningHtml += '<div class="text-warning">' + result.importer.warnings[j] + '</div>';
|
|
2509
|
+
}
|
|
2510
|
+
$('#import-property-warnings').html(warningHtml);
|
|
2511
|
+
}
|
|
2512
|
+
else {
|
|
2513
|
+
$('#import-property-warnings').html("<div>No warnings reported.</div>");
|
|
2514
|
+
}
|
|
2515
|
+
}.bind(this)
|
|
2516
|
+
});
|
|
2517
|
+
};
|
|
2518
|
+
PropertyImporter.prototype.hideInfo = function () {
|
|
2519
|
+
$('#import-property-start').removeAttr('disabled');
|
|
2520
|
+
$('#import-property-cancel').attr('disabled', 'disabled');
|
|
2521
|
+
$('#import-property-progress').removeClass('d-block');
|
|
2522
|
+
$('#import-property-progress').addClass('d-none');
|
|
2523
|
+
};
|
|
2524
|
+
PropertyImporter.prototype.showInfo = function () {
|
|
2525
|
+
$('#import-property-cancel').removeAttr('disabled');
|
|
2526
|
+
$('#import-property-start').attr('disabled', 'disabled');
|
|
2527
|
+
$('#import-property-progress').addClass('d-block');
|
|
2528
|
+
$('#import-property-progress').removeClass('d-none');
|
|
2529
|
+
};
|
|
2530
|
+
return PropertyImporter;
|
|
2531
|
+
}());
|
|
2532
|
+
|
|
2533
|
+
var Admin = /** @class */ (function (_super) {
|
|
2534
|
+
__extends(Admin, _super);
|
|
2535
|
+
function Admin() {
|
|
2536
|
+
var _this = _super.call(this) || this;
|
|
2537
|
+
// Hook up default handlers.
|
|
2538
|
+
_this.handlers.initDefaultHandlers();
|
|
2539
|
+
// Admin Controllers
|
|
2540
|
+
_this.home = new HomeController();
|
|
2541
|
+
_this.media = new MediaController();
|
|
2542
|
+
_this.content = new ContentController();
|
|
2543
|
+
_this.contentType = new ContentTypeController();
|
|
2544
|
+
_this.logs = new LogsController();
|
|
2545
|
+
_this.property = new PropertyController();
|
|
2546
|
+
_this.propertyImporter = new PropertyImporter();
|
|
2547
|
+
_this.themes = new ThemesController();
|
|
2548
|
+
_this.users = new UsersController();
|
|
2549
|
+
// Hook up rich text editors
|
|
2550
|
+
_this.editors.richTextEditors();
|
|
2551
|
+
// Hook up colour pickers
|
|
2552
|
+
_this.colorPickers.loadColorPickers();
|
|
2553
|
+
if ($('#page-tabs').length > 0) {
|
|
2554
|
+
_this.checkAndLoadTabs('#page-tabs');
|
|
2555
|
+
}
|
|
2556
|
+
// Admin Handlers
|
|
2557
|
+
$('.restrict-to-slug').restrictToSlug();
|
|
2558
|
+
$('.restrict-to-page-slug').restrictToPageSlug();
|
|
2559
|
+
$('.restrict-to-meta-slug').restrictToMetaSlug();
|
|
2560
|
+
$('.character-counter').characterCounter();
|
|
2561
|
+
$('.character-counter').trigger('change');
|
|
2562
|
+
$('.warning-alert').warningAlert();
|
|
2563
|
+
$('.mobile-sidebar-toggle').on('click', function () {
|
|
2564
|
+
$('nav.sidebar').toggleClass('open');
|
|
2565
|
+
});
|
|
2566
|
+
$('.right-sidebar-toggle').on('click', function () {
|
|
2567
|
+
$('#right-sidebar').toggleClass('sidebar-open');
|
|
2568
|
+
});
|
|
2569
|
+
$(".alert.auto-dismiss").fadeTo(5000, 500).slideUp(500, function () {
|
|
2570
|
+
$(".alert.auto-dismiss").slideUp(500);
|
|
2571
|
+
});
|
|
2572
|
+
return _this;
|
|
2573
|
+
}
|
|
2574
|
+
Admin.prototype.checkAndLoadTabs = function (tag) {
|
|
2575
|
+
$(tag + ' a[data-bs-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
2576
|
+
var store = JSON.parse(localStorage.getItem('tabs-' + tag)) || {};
|
|
2577
|
+
store['tab-' + $(tag).data('hoodTabs')] = $(e.target).attr('href');
|
|
2578
|
+
localStorage.setItem('tabs-' + tag, JSON.stringify(store));
|
|
2579
|
+
});
|
|
2580
|
+
var store = JSON.parse(localStorage.getItem('tabs-' + tag)) || {};
|
|
2581
|
+
var activeTab = store['tab-' + $(tag).data('hoodTabs')];
|
|
2582
|
+
var triggerEl = $(tag + ' a[data-bs-toggle="tab"]')[0];
|
|
2583
|
+
if (activeTab) {
|
|
2584
|
+
triggerEl = document.querySelector(tag + ' a[href="' + activeTab + '"]');
|
|
2585
|
+
}
|
|
2586
|
+
var tabTrigger = new bootstrap__namespace.Tab(triggerEl);
|
|
2587
|
+
tabTrigger.show();
|
|
2588
|
+
};
|
|
2589
|
+
return Admin;
|
|
2590
|
+
}(HoodApi));
|
|
2591
|
+
window.hood = new Admin();
|
|
2592
|
+
|
|
2593
|
+
}));
|
|
2594
|
+
if (typeof this !== 'undefined' && this.hood){ this.hoodCMS = this.Hood = this.hoodCMS = this.HoodCMS = this.hood }
|
|
2595
|
+
//# sourceMappingURL=admin.js.map
|