hoodcms 5.0.14 → 5.0.15

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.
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * hoodcms v5.0.15
3
+ * A fully customisable content management system built in ASP.NET Core 5 & Bootstrap 5.
4
+ * Written by George Whysall, 2022
5
+ * Released under the GPL-3.0 License.
6
+ */
7
+ (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?f(exports,require('sweetalert2'),require('@simonwep/pickr'),require('tinymce/tinymce'),require('bootstrap')):typeof define==='function'&&define.amd?define(['exports','sweetalert2','@simonwep/pickr','tinymce/tinymce','bootstrap'],f):(g=typeof globalThis!=='undefined'?globalThis:g||self,f(g.hood={},g.Swal));})(this,(function(exports,Swal){'use strict';function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var Swal__default=/*#__PURE__*/_interopDefaultLegacy(Swal);/*! *****************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+ var extendStatics=function(t,e){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);},extendStatics(t,e)};function __extends(t,e){function r(){this.constructor=t;}extendStatics(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r);}var __assign=function(){return __assign=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},__assign.apply(this,arguments)};"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">&times;</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),!1!==this.options.bgColor&&this._toastEl.css("background-color",this.options.bgColor),!1!==this.options.textColor&&this._toastEl.css("color",this.options.textColor),this.options.textAlign&&this._toastEl.css("text-align",this.options.textAlign),!1!==this.options.icon&&(this._toastEl.addClass("jq-has-icon"),-1!==t.inArray(this.options.icon,this._defaultIcons)&&this._toastEl.addClass("jq-icon-"+this.options.icon)),!1!==this.options.class&&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-this.options.stack;i>0&&t(".jq-toast-wrap").find(".jq-toast-single").slice(0,i).remove();}this._container=o;},canAutoHide:function(){return !1!==this.options.hideAfter&&!isNaN(parseInt(this.options.hideAfter,10))},processLoader:function(){if(!this.canAutoHide()||!1===this.options.loader)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()){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);var BootstrapSwal=Swal__default["default"].mixin({customClass:{confirmButton:"btn btn-success m-1 px-3",cancelButton:"btn btn-danger m-1 px-3"},buttonsStyling:!1}),Alerts=function(){function o(){}return o.log=function(o,t){if(void 0===t&&(t="message"),document.body.classList.contains("dev-mode"))switch(t){case"error":console.error(o);break;case"message":console.log(o);break;case"warning":console.warn(o);break;case"info":console.info(o);}},o.error=function(o,t,e){void 0===t&&(t=null),void 0===e&&(e=null),$.toast({heading:t,text:o,icon:"error",position:"bottom-left",loader:!1,bgColor:"#d0100b",textColor:"white",hideAfter:e});},o.warning=function(o,t,e){void 0===t&&(t=null),void 0===e&&(e=null),$.toast({heading:t,text:o,icon:"error",position:"bottom-left",loader:!1,bgColor:"#ef9007",textColor:"white",hideAfter:e});},o.message=function(o,t,e){void 0===t&&(t=null),void 0===e&&(e=null),$.toast({heading:t,text:o,icon:"error",position:"bottom-left",loader:!1,bgColor:"#222222",textColor:"white",hideAfter:e});},o.success=function(o,t,e){void 0===t&&(t=null),void 0===e&&(e=null),$.toast({heading:t,text:o,icon:"error",position:"bottom-left",loader:!1,bgColor:"#28a745",textColor:"white",hideAfter:e});},o.alert=function(t,e,n,i){switch(void 0===e&&(e=null),void 0===n&&(n="info"),void 0===i&&(i=1e4),n){case"error":o.error(t,e,i);break;case"warning":o.warning(t,e,i);break;case"info":o.message(t,e,i);break;case"success":o.success(t,e,i);}},o.sweetAlert=function(o,t){BootstrapSwal.fire(o).then((function(o){t(o);}));},o.confirm=function(t,e){o.sweetAlert(__assign(__assign({},{showCancelButton:!0,footer:null,title:"Are you sure?",html:"Are you sure you want to do this?",confirmButtonText:"Ok",cancelButtonText:"Cancel"}),t),e);},o.prompt=function(t,e){o.sweetAlert(__assign(__assign({},{input:"text",inputAttributes:{autocapitalize:"off"},showCancelButton:!0,icon:"info",footer:'<span class="text-warning"><i class="fa fa-exclamation-triangle"></i> This cannot be undone.</span>',confirmButtonText:"Ok",cancelButtonText:"Cancel"}),t),e);},o.prototype.log=function(t,e){void 0===e&&(e="message"),o.log(t,e);},o.prototype.error=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null),o.error(t,e,n);},o.prototype.warning=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null),o.warning(t,e,n);},o.prototype.message=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null),o.message(t,e,n);},o.prototype.success=function(t,e,n){void 0===e&&(e=null),void 0===n&&(n=null),o.success(t,e,n);},o.prototype.alert=function(t,e,n,i){void 0===n&&(n="info"),void 0===i&&(i=1e4),o.alert(t,t,n,i);},o.prototype.sweetAlert=function(t,e){o.sweetAlert(t,e);},o.prototype.confirm=function(t,e){o.confirm(t,e);},o.prototype.prompt=function(t,e){o.prompt(t,e);},o}();var Inline=function(){function o(){}return o.load=function(n,r){var t,e=$(n);e.addClass("loading"),r.onLoad&&r.onLoad(n);var l=e.data("url");$.get(l,(function(o){r.onRender&&(o=r.onRender(o,n)),e.html(o),e.removeClass("loading"),r.onComplete&&r.onComplete(o,n);})).fail(null!==(t=r.onError)&&void 0!==t?t:o.handleError);},o.task=function(n,r,t,e){void 0===t&&(t=null),void 0===e&&(e=null),r&&r.classList.add("loading"),$.get(n,(function(o){r&&r.classList.remove("loading"),t&&t(o,r);})).fail(null!=e?e:o.handleError);},o.post=function(n,r,t,e){void 0===t&&(t=null),void 0===e&&(e=null),r&&r.classList.add("loading"),$.post(n,(function(o){r&&r.classList.remove("loading"),t&&t(o,r);})).fail(null!=e?e:o.handleError);},o.handleError=function(o,n,r){500===o.status?Alerts.error("There was an error processing the content, please contact an administrator if this continues.","Error "+o.status,1e4):404===o.status?Alerts.error("The content could not be found.","Error "+o.status,1e4):401===o.status&&(Alerts.error("You are not allowed to view this resource, are you logged in correctly?","Error "+o.status,1e4),window.location=window.location);},o}();var DataList=function(){function e(e,t){if(this.element=e,this.element.hoodDataList=this,void 0!==e&&null!=e){if(this.options=__assign(__assign({},this.options),t),$(this.element).hasClass("query")){var n=$(this.element).data("url")+window.location.search;$(this.element).attr("data-url",n),$(this.element).data("url",n);}if(!$(this.element).hasClass("refresh-only")){var i=document.createElement("a");i.href=$(this.element).data("url"),this.reload(new URL(i.href));}$(this.element).on("click",".pagination a, a.hood-inline-list-target",function(e){e.preventDefault();var t=document.createElement("a");t.href=e.currentTarget.href;var n=document.createElement("a");n.href=$(this.element).data("url"),n.search=t.search,this.reload(new URL(n.href));}.bind(this)),$("body").on("submit",'form.inline[data-target="#'.concat(this.element.id,'"]'),function(e){e.preventDefault();var t=$(e.currentTarget),n=document.createElement("a");n.href=$(this.element).data("url"),n.search="?"+t.serialize(),this.reload(new URL(n.href));}.bind(this));}else Alerts.log("Could not DataList to element, element does not exist.","error");}return e.prototype.reload=function(e){if(void 0===e&&(e=null),e){if(history.pushState&&$(this.element).hasClass("query")){var t=window.location.protocol+"//"+window.location.host+window.location.pathname+(e.href.contains("?")?"?"+e.href.substring(e.href.indexOf("?")+1):"");window.history.pushState({path:t},"",t);}$(this.element).data("url",e);}Inline.load(this.element,__assign({},this.options));},e}();
22
+ var Validator=function(){function t(t,i){if(this.options={errorAlert:"There are errors on the form, please check your answers and try again.",useAjax:!0},this.element=t,this.element){this.options.serializationFunction=function(){return $(this.element).serialize()}.bind(this),this.options=__assign(__assign({},this.options),i),this.element.addEventListener("submit",function(t){t.preventDefault(),t.stopImmediatePropagation(),this.submitForm();}.bind(this));var e='[data-submit="#'+this.element.id+'"]',n=$(e);n&&n.on("click",function(t){t.preventDefault(),t.stopImmediatePropagation(),$(t.currentTarget).data("exit")&&($(this.element).find("input#exit").remove(),$("<input id='exit' />").attr("type","hidden").attr("name","exit").attr("value","true").appendTo(this.element)),this.submitForm();}.bind(this));}}return t.prototype.submitForm=function(){var t;if(this.element.classList.add("was-validated"),this.element.checkValidity()){this.element.classList.add("loading");var i=this.element.querySelector("input[type=checkbox]");if(i&&Array.prototype.slice.call(i).forEach((function(t){$(this).is(":checked")&&$(this).val("true");})),this.options.onSubmit&&this.options.onSubmit(this),this.options.useAjax){var e=this.options.serializationFunction();$.post(this.element.action,e,function(t){this.options.onComplete&&this.options.onComplete(t,this);}.bind(this)).fail(null!==(t=this.options.onError)&&void 0!==t?t:Inline.handleError);}else this.element.submit();}else this.options.errorAlert&&Alerts.error(this.options.errorAlert,null,5e3);},t}();var Handlers=function(){function t(){}return t.prototype.initDefaultHandlers=function(){this.checkboxToCsvInput(),this.iconSelector(),this.initSelectValues(),this.scrollHandlers(),this.selectText(),this.setValueOnClick(),this.submitOnChange();},t.prototype.initSelectValues=function(t){void 0===t&&(t="body"),$(t).find("select[data-selected]").each(this.initSelectValuesHandler);},t.prototype.initSelectValuesHandler=function(t,e){var o=$(this).data("selected");if("undefined"!==o&&""!==o){var a=String(o);$(this).val(a);}},t.prototype.iconSelector=function(t){void 0===t&&(t="body"),$(t).find("[data-hood-icon]").each(this.iconSelectorHandler);},t.prototype.iconSelectorHandler=function(t,e){var o=$(this),a=o.find("input[data-hood-icon-input]"),n=o.find("[data-hood-icon-display]"),i=o.find(".collapse");o.find("[data-hood-icon-key][data-hood-icon-value]").on("click",(function(){o.find("[data-hood-icon-key][data-hood-icon-value]").removeClass("active"),$(this).addClass("active");var t=$(this).data("hoodIconKey"),e=$(this).data("hoodIconValue");$(this),n.html(e),a.val(t),i&&i.removeClass("show");}));},t.prototype.selectText=function(t){void 0===t&&(t="body"),$(t).on("click",".select-text",this.selectTextHandler);},t.prototype.selectTextHandler=function(){var t=$(this);t.select(),t.mouseup((function(){return t.unbind("mouseup"),!1}));},t.prototype.scrollHandlers=function(t){void 0===t&&(t="body"),$(t).on("click",".scroll-top, .scroll-to-top",this.scrollTop),$(t).on("click",".scroll-target, .scroll-to-target",this.scrollTarget),$(t).on("click",".scroll-target-direct, .scroll-to-target-direct",this.scrollTargetDirect);},t.prototype.scrollTop=function(t){return t&&t.preventDefault(),$("html, body").animate({scrollTop:0},800),!1},t.prototype.scrollTarget=function(t){t&&t.preventDefault();var e=$(this).attr("href").split("#")[0];if(e===window.location.pathname||""===e){var o=this.hash,a=$(o),n=$("header.header"),i=0;n&&(i=n.height()),$(this).data("offset")?$("html, body").stop().animate({scrollTop:a.offset().top-$(this).data("offset")},900,"swing"):$("html, body").stop().animate({scrollTop:a.offset().top-i},900,"swing");}},t.prototype.scrollTargetDirect=function(){var t=$("body").scrollTop(),e=$($(this).attr("href")).offset().top;return $("html, body").animate({scrollTop:e},Math.abs(e-t)),!1},t.prototype.checkboxToCsvInput=function(t){void 0===t&&(t="body"),$(t).on("change","input[type=checkbox][data-hood-csv-input]",this.checkboxToCsvInputHandler);},t.prototype.checkboxToCsvInputHandler=function(t){t&&t.preventDefault();var e=new Array;$('input[data-hood-csv-input="'+$(this).data("hoodCsvInput")+'"]').each((function(){$(this).is(":checked")&&e.push($(this).val());}));var o="#"+$(this).data("input"),a=JSON.stringify(e);$(o).val(a);},t.prototype.submitOnChange=function(t){void 0===t&&(t="body"),$(t).on("change",".submit-on-change",this.submitOnChangeHandler);},t.prototype.submitOnChangeHandler=function(t){t&&t.preventDefault(),$(this).parents("form").submit();},t.prototype.setValueOnClick=function(t){void 0===t&&(t="body"),$(t).on("click",".click-select[data-target][data-value]",this.setValueOnClickHandler);},t.prototype.setValueOnClickHandler=function(){var t=$(this),e="#"+t.data("target");$(e).val(t.data("value")),$(e).trigger("change"),$('.click-select.clean[data-target="'+t.data("target")+'"]').each((function(){$(this).removeClass("active");})),$('.click-select.clean[data-target="'+t.data("target")+'"][data-value="'+t.data("value")+'"]').each((function(){$(this).addClass("active");}));},t}();var Loader=function(){function e(){new CustomEvent("loader-show"),new CustomEvent("loader-hide");}return e.show=function(){$("body").trigger("loader-show");},e.hide=function(){$("body").trigger("loader-hide");},e}();new Loader;var Uploader=function(){function e(){($(".image-uploader").length||$(".gallery-uploader").length)&&($(".upload-progress-bar").hide(),$(".image-uploader").each(this.singleImage),$(".gallery-uploader").each(this.gallery));}return e.prototype.refreshImage=function(e,r){$(e.data("preview")).css({"background-image":"url("+r.media.smallUrl+")"}),$(e.data("preview")).find("img").attr("src",r.media.smallUrl);},e.prototype.singleImage=function(){var e="#"+$(this).attr("id"),r=$(e),a="#"+$(this).attr("json"),l=null;r.dropzone({url:r.data("url"),maxFiles:1,paramName:"file",parallelUploads:1,acceptedFiles:r.data("types")||".png,.jpg,.jpeg,.gif",autoProcessQueue:!0,previewsContainer:!1,clickable:e,init:function(){l=this;}}),l.on("addedfile",(function(){})),l.on("totaluploadprogress",(function(r){$(".upload-progress-bar."+e.replace("#","")+" .progress-bar").css({width:r+"%"});})),l.on("sending",(function(a){$(".upload-progress-bar."+e.replace("#","")).show(),$(r.data("preview")).addClass("loading");})),l.on("queuecomplete",(function(r){$(".upload-progress-bar."+e.replace("#","")).hide();})),l.on("success",(function(e,o){o.success?(o.media&&($(a).val(JSON.stringify(o.media)),$(r.data("preview")).css({"background-image":"url("+o.media.smallUrl+")"}),$(r.data("preview")).find("img").attr("src",o.media.smallUrl)),Alerts.success("New image added!")):Alerts.error("There was a problem adding the image: "+o.error),l.removeFile(e),$(r.data("preview")).removeClass("loading");}));},e.prototype.gallery=function(){var e="#"+$(this).attr("id"),r=$(e),a=document.querySelector(e+"-template");a.id="";var l=a.parentNode.innerHTML;a.parentNode.removeChild(a);var o=null;r.dropzone({url:r.data("url"),thumbnailWidth:80,thumbnailHeight:80,parallelUploads:5,previewTemplate:l,paramName:"files",acceptedFiles:r.data("types")||".png,.jpg,.jpeg,.gif",autoProcessQueue:!0,previewsContainer:"#previews",clickable:".fileinput-button",init:function(){o=this;}}),$(e+" .cancel").hide(),o.on("addedfile",(function(r){$(r.previewElement.querySelector(".complete")).hide(),$(r.previewElement.querySelector(".cancel")).show(),$(e+" .cancel").show();})),o.on("totaluploadprogress",(function(e,r,a){document.querySelector("#total-progress .progress-bar").style.width=e+"%";})),o.on("sending",(function(e){document.querySelector("#total-progress").style.opacity="1";})),o.on("complete",(function(e){$(e.previewElement.querySelector(".cancel")).hide(),$(e.previewElement.querySelector(".progress")).hide(),$(e.previewElement.querySelector(".complete")).show(),console.error("Uploader.Gallery.Dropzone.OnComplete - Inline.Refresh('.gallery') is not implemented.");})),o.on("queuecomplete",(function(r){document.querySelector("#total-progress").style.opacity="0",$(e+" .cancel").hide();})),o.on("success",(function(e,r){console.error("Uploader.Gallery.Dropzone.OnSuccess - Inline.Refresh('.gallery') is not implemented."),r.success?Alerts.success("New images added!"):Alerts.error("There was a problem adding the profile image: "+r.error);})),$(".actions .cancel").click((function(){o.removeAllFiles(!0);}));},e}();$.fn.exists=function(){return $(this).length},$.fn.restrictToSlug=function(t){void 0===t&&(t=/[^0-9a-zA-Z]*/g);var n=$(this),e=function(){var n=$(this).val(),e=n.replace(t,"");n!==e&&$(this).val(e);};n.on("keyup",e),n.on("paste",e),n.on("change",e);},$.fn.restrictToPageSlug=function(t){void 0===t&&(t=/[^0-9a-zA-Z-//]*/g);var n=$(this),e=function(){var n=$(this).val(),e=n.replace(t,"");if((e.match(new RegExp("/","g"))||[]).length>4){var a=e.lastIndexOf("/");e=e.substring(0,a)+e.substring(a+1),Alerts.warning("You can only have up to 4 '/' characters in a url slug.");}n!==e&&$(this).val(e);};n.on("keyup",e),n.on("paste",e),n.on("change",e);},$.fn.restrictToMetaSlug=function(t){void 0===t&&(t=/[^0-9a-zA-Z.]*/g);var n=$(this),e=function(){var n=$(this).val(),e=n.replace(t,"");if((e.match(new RegExp(".","g"))||[]).length>1){var a=e.lastIndexOf(".");e=e.substring(0,a)+e.substring(a+1),Alerts.warning("You can only have up to 1 '.' characters in a meta slug.");}n!==e&&$(this).val(e);};n.on("keyup",e),n.on("paste",e),n.on("change",e);},$.fn.characterCounter=function(){var t=$(this),n=function(){var t=$(this).data("counter"),n=Number($(this).attr("maxlength")),e=$(this).val().length;$(t).text(n-e);var a="text-success";n-e<n/10&&(a="text-danger"),$(t).parent().removeClass("text-success").removeClass("text-danger").addClass(a);};t.on("keyup",n),t.on("paste",n),t.on("change",n);},$.fn.warningAlert=function(){$(this).on("click",(function(t){t.preventDefault();return Alerts.confirm({title:$(t.currentTarget).data("title"),html:$(t.currentTarget).data("warning"),footer:$(t.currentTarget).data("footer"),icon:"warning"},(function(n){if(n.isConfirmed){var e=$(t.currentTarget).attr("href");window.location.href=e;}})),!1}));};
23
+ Number.prototype.formatCurrency=function(t){return t+" "+this.toFixed(2).replace(/./g,(function(t,e,r){return e>0&&"."!==t&&(r.length-e)%3==0?","+t:t}))},Number.prototype.formatKilobytes=function(){return (this/1024).toFixed(0).replace(/./g,(function(t,e,r){return e>0&&"."!==t&&(r.length-e)%3==0?","+t:t}))+"Kb"},Number.prototype.formatMegabytes=function(){var t=this/1024;return (t/=1024).toFixed(0).replace(/./g,(function(t,e,r){return e>0&&"."!==t&&(r.length-e)%3==0?","+t:t}))+"Mb"};String.prototype.htmlEncode=function(){return $("<div/>").text(this).html()},String.prototype.htmlDecode=function(){return $("<div/>").html(this).text()},String.prototype.contains=function(t){return -1!==this.indexOf(t)},String.prototype.pick=function(t,r){var o,n="";o=void 0===r?t:t+Math.floor(Math.random()*(r-t));for(var e=0;e<o;e++)n+=this.charAt(Math.floor(Math.random()*this.length));return n},String.prototype.shuffle=function(){var t,r,o=this.split(""),n=o.length;if(n)for(;--n;)t=o[r=Math.floor(Math.random()*(n+1))],o[r]=o[n],o[n]=t;return o.join("")},String.prototype.toSeoUrl=function(){var t=this.replace(/[^a-zA-Z0-9]/g," ").replace(/\s+/g,"-").toLowerCase();"-"===t.charAt(0)&&(t=t.substring(1));var r=t.length-1;return "-"===t.charAt(r)&&(t=t.substring(0,r)),t};var HoodApi=function(){function t(){this.alerts=new Alerts,this.handlers=new Handlers,this.uploader=new Uploader;}return t.prototype.initialise=function(){this.setupLoaders(),this.handlers.initDefaultHandlers(),this.initContactForms();},t.prototype.setupLoaders=function(){$("body").on("loader-show",(function(){document.body.classList.add("loading");})),$("body").on("loader-hide",(function(){document.body.classList.remove("loading");}));},t.prototype.initGoogleMaps=function(t){void 0===t&&(t=".google-map"),$(t).each((function(){var t=new google.maps.LatLng($(this).data("lat"),$(this).data("long"));console.log("Loading map at: "+$(this).data("lat")+", "+$(this).data("long"));var o=new google.maps.Map(this,{zoom:$(this).data("zoom")||15,center:t,scrollwheel:!1});new google.maps.Marker({position:t,map:o,title:$(this).data("marker")});$(window).on("resize",(function(){google.maps.event.trigger(o,"resize");})),google.maps.event.trigger(o,"resize");}));},t.prototype.initContactForms=function(t){void 0===t&&(t=".contact-form");var o=$(t);o.find(".thank-you").hide(),o.find(".form-content").show();var e=$(t)[0];new Validator(e,{onComplete:function(t){t.success?(o.attr("data-redirect")&&(window.location.href=o.attr("data-redirect")),o.attr("data-alert-message")&&Alerts.success(o.attr("data-alert-message")),o.find(".form").hide(),o.find(".thank-you").show()):o.attr("data-alert-error")?Alerts.error(o.attr("data-alert-error")):(console.error(t.errors),Alerts.error("There are errors on the form, please check your answers and try again."));}.bind(this)});},t}();var PropertyController=function(){function t(){this.map=null,this.center={lat:30,lng:-110},this.initList();}return t.prototype.initList=function(){this.element=document.getElementById("property-list"),this.element&&(this.list=new DataList(this.element,{onComplete:function(t,e){Alerts.log("Finished loading property list.","info");}.bind(this)}));},t.prototype.initMapList=function(){this.mapListElement=document.getElementById("property-map-list"),this.mapElement&&(this.mapList=new DataList(this.mapListElement,{onComplete:function(t,e){Alerts.log("Finished loading map list.","info"),this.reloadMarkers();}.bind(this)}));},t.prototype.initMap=function(t){void 0===t&&(t="property-map"),this.mapElement=document.getElementById(t),this.mapElement&&(this.center={lat:+this.mapElement.dataset.lat,lng:+this.mapElement.dataset.long},this.map=new google.maps.Map(this.mapElement,{zoom:+this.mapElement.dataset.zoom||15,center:this.center,scrollwheel:!1}),$(window).resize(function(){google.maps.event.trigger(this.map,"resize");}.bind(this)),google.maps.event.trigger(this.map,"resize"),this.initMapList());},t.prototype.reloadMarkers=function(){var t=null;if(this.mapElement){var e=this.map;if(this.markers)for(var i=0;i<this.markers.length;i++)this.markers[i].setMap(null);this.markers=[],$("#property-map-locations").data("locations").map(function(i,n){var o=new google.maps.Marker({position:new google.maps.LatLng(+i.Latitude,+i.Longitude),map:this.map,optimized:!0});o.info='<div class="card border-0" style="max-width:300px">\n <div style="background-image:url('.concat(i.ImageUrl,')" class="rounded img-full img img-wide"></div>\n <div class="card-body border-0">\n <p style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">\n <strong>').concat(i.Address1,", ").concat(i.Postcode,"</strong>\n </p>\n <p>").concat(i.Description,'</p>\n <a href="').concat(i.MarkerUrl,'" class="btn btn-block btn-primary">Find out more...</a>\n </div>\n</div>'),google.maps.event.addListener(o,"click",function(){t&&t.close(),(t=new google.maps.InfoWindow({content:this.info})).open(e,this);}.bind(this)),this.markers.push(o);}.bind(this));}},t}();var App=function(o){function r(){var r=o.call(this)||this;return r.initialise(),r.property=new PropertyController,r}return __extends(r,o),r}(HoodApi);window.hood=new App;exports.App=App;Object.defineProperty(exports,'__esModule',{value:true});}));
24
+ if (typeof this !== 'undefined' && this.hood){ this.hoodCMS = this.Hood = this.hoodCMS = this.HoodCMS = this.hood }
@@ -1,6 +1,4 @@
1
1
  import { Alerts } from "./Alerts";
2
- import { ColorPickers } from "./ColorPicker";
3
- import { Editors } from "./Editors";
4
2
  import { Handlers } from "./Handlers";
5
3
  import { Uploader } from "./Uploader";
6
4
  declare global {
@@ -13,13 +11,25 @@ declare global {
13
11
  hood: Hood;
14
12
  }
15
13
  }
16
- export declare class HoodApi implements Hood {
14
+ /**
15
+ * Base class for extending a Hood CMS website, ensure you call HoodApi.initialise() to setup loaders and contact form defaults.
16
+ */
17
+ export declare class HoodApi {
17
18
  alerts: Alerts;
18
- uploader: Uploader;
19
19
  handlers: Handlers;
20
- editors: Editors;
21
- colorPickers: ColorPickers;
22
- private mediaModal;
20
+ uploader: Uploader;
23
21
  constructor();
22
+ initialise(): void;
23
+ /**
24
+ * Default Hood CMS loaders, can be used however, this simply adds a "loading" class to the body tag on show/hide.
25
+ */
24
26
  setupLoaders(): void;
27
+ /**
28
+ * Default initialisation function for Google Maps, should be called as the callback from the Google Maps API script tag.
29
+ */
30
+ initGoogleMaps(tag?: string): void;
31
+ /**
32
+ * Initialisation function for contact forms on the site, will add validator, and submit/functionality to any forms matching the given tag selector string.
33
+ */
34
+ initContactForms(tag?: string): void;
25
35
  }
@@ -1,22 +1,83 @@
1
+ /// <reference types="google.maps" />
2
+ import { Validator } from "..";
1
3
  import { Alerts } from "./Alerts";
2
- import { ColorPickers } from "./ColorPicker";
3
- import { Editors } from "./Editors";
4
4
  import { Handlers } from "./Handlers";
5
- import { MediaModal } from "./Media";
6
5
  import { Uploader } from "./Uploader";
6
+ /**
7
+ * Base class for extending a Hood CMS website, ensure you call HoodApi.initialise() to setup loaders and contact form defaults.
8
+ */
7
9
  export class HoodApi {
8
10
  constructor() {
9
11
  this.alerts = new Alerts();
10
- this.uploader = new Uploader();
11
12
  this.handlers = new Handlers();
12
- this.editors = new Editors();
13
- this.colorPickers = new ColorPickers();
14
- this.mediaModal = new MediaModal();
15
- // Global Handlers
13
+ this.uploader = new Uploader();
14
+ }
15
+ // Initialise Hood CMS site defaults, can be overridden or individual setup items can be called instead of the initialise function.
16
+ initialise() {
17
+ // Initialise loaders (default, adds loading to body tag)
16
18
  this.setupLoaders();
19
+ // Hook up default handlers.
20
+ this.handlers.initDefaultHandlers();
21
+ // Init hood contact forms.
22
+ this.initContactForms();
17
23
  }
24
+ /**
25
+ * Default Hood CMS loaders, can be used however, this simply adds a "loading" class to the body tag on show/hide.
26
+ */
18
27
  setupLoaders() {
19
- $('body').on('loader-show', function () { Alerts.success("Showing loader..."); });
20
- $('body').on('loader-hide', function () { Alerts.error("Hiding loader..."); });
28
+ $('body').on('loader-show', function () { document.body.classList.add('loading'); });
29
+ $('body').on('loader-hide', function () { document.body.classList.remove('loading'); });
30
+ }
31
+ /**
32
+ * Default initialisation function for Google Maps, should be called as the callback from the Google Maps API script tag.
33
+ */
34
+ initGoogleMaps(tag = '.google-map') {
35
+ $(tag).each(function () {
36
+ var myLatLng = new google.maps.LatLng($(this).data('lat'), $(this).data('long'));
37
+ console.log('Loading map at: ' + $(this).data('lat') + ', ' + $(this).data('long'));
38
+ var map = new google.maps.Map(this, {
39
+ zoom: $(this).data('zoom') || 15,
40
+ center: myLatLng,
41
+ scrollwheel: false
42
+ });
43
+ var marker = new google.maps.Marker({
44
+ position: myLatLng,
45
+ map: map,
46
+ title: $(this).data('marker')
47
+ });
48
+ $(window).on('resize', function () {
49
+ google.maps.event.trigger(map, 'resize');
50
+ });
51
+ google.maps.event.trigger(map, 'resize');
52
+ });
53
+ }
54
+ /**
55
+ * Initialisation function for contact forms on the site, will add validator, and submit/functionality to any forms matching the given tag selector string.
56
+ */
57
+ initContactForms(tag = '.contact-form') {
58
+ let $form = $(tag);
59
+ $form.find('.thank-you').hide();
60
+ $form.find('.form-content').show();
61
+ let form = $(tag)[0];
62
+ new Validator(form, {
63
+ onComplete: function (response) {
64
+ if (response.success) {
65
+ if ($form.attr('data-redirect'))
66
+ window.location.href = $form.attr('data-redirect');
67
+ if ($form.attr('data-alert-message'))
68
+ Alerts.success($form.attr('data-alert-message'));
69
+ $form.find('.form').hide();
70
+ $form.find('.thank-you').show();
71
+ }
72
+ else {
73
+ if ($form.attr('data-alert-error'))
74
+ Alerts.error($form.attr('data-alert-error'));
75
+ else {
76
+ console.error(response.errors);
77
+ Alerts.error("There are errors on the form, please check your answers and try again.");
78
+ }
79
+ }
80
+ }.bind(this)
81
+ });
21
82
  }
22
83
  }
@@ -6,7 +6,7 @@ export class Validator {
6
6
  */
7
7
  constructor(element, options) {
8
8
  this.options = {
9
- errorAlert: 'There are errors, please check the form.',
9
+ errorAlert: 'There are errors on the form, please check your answers and try again.',
10
10
  useAjax: true
11
11
  };
12
12
  this.element = element;
@@ -3,7 +3,6 @@ export * from './models/Content';
3
3
  export * from './models/Property';
4
4
  export * from './models/Users';
5
5
  export * from './core/Alerts';
6
- export * from './core/BaseSite';
7
6
  export * from './core/ColorPicker';
8
7
  export * from './core/DataList';
9
8
  export * from './core/Editors';
package/dist/js/index.js CHANGED
@@ -3,7 +3,6 @@ export * from './models/Content';
3
3
  export * from './models/Property';
4
4
  export * from './models/Users';
5
5
  export * from './core/Alerts';
6
- export * from './core/BaseSite';
7
6
  export * from './core/ColorPicker';
8
7
  export * from './core/DataList';
9
8
  export * from './core/Editors';
package/dist/js/login.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * hoodcms v5.0.14
2
+ * hoodcms v5.0.15
3
3
  * A fully customisable content management system built in ASP.NET Core 5 & Bootstrap 5.
4
4
  * Written by George Whysall, 2022
5
5
  * Released under the GPL-3.0 License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hoodcms",
3
- "version": "5.0.14",
3
+ "version": "5.0.15",
4
4
  "description": "A fully customisable content management system built in ASP.NET Core 5 & Bootstrap 5.",
5
5
  "keywords": [
6
6
  "hood",