hoodcms 5.0.5 → 5.0.9

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.
Files changed (93) hide show
  1. package/dist/css/admin.css +1 -1
  2. package/dist/css/app.css +1 -1
  3. package/dist/css/button.css +1 -1
  4. package/dist/css/editor.css +1 -1
  5. package/dist/css/install.css +1 -1
  6. package/dist/css/login.css +1 -1
  7. package/dist/js/admin.js +8 -6
  8. package/dist/js/app.js +7 -6
  9. package/dist/js/core/Alerts.d.ts +22 -0
  10. package/dist/js/core/Alerts.js +151 -0
  11. package/dist/js/core/BaseSite.d.ts +6 -0
  12. package/dist/js/core/BaseSite.js +14 -0
  13. package/dist/js/core/ColorPicker.d.ts +5 -0
  14. package/dist/js/core/ColorPicker.js +71 -0
  15. package/dist/js/core/DataList.d.ts +35 -0
  16. package/dist/js/core/DataList.js +56 -0
  17. package/dist/js/core/Editors.d.ts +16 -0
  18. package/dist/js/core/Editors.js +137 -0
  19. package/dist/js/core/Handlers.d.ts +47 -0
  20. package/dist/js/core/Handlers.js +160 -0
  21. package/dist/js/core/HoodApi.d.ts +25 -0
  22. package/dist/js/core/HoodApi.js +22 -0
  23. package/dist/js/core/Inline.d.ts +27 -0
  24. package/dist/js/core/Inline.js +63 -0
  25. package/dist/js/core/Loader.d.ts +5 -0
  26. package/dist/js/core/Loader.js +13 -0
  27. package/dist/js/core/Media.d.ts +113 -0
  28. package/dist/js/core/Media.js +363 -0
  29. package/dist/js/core/Modal.d.ts +35 -0
  30. package/dist/js/core/Modal.js +69 -0
  31. package/dist/js/core/RandomStringGenerator.d.ts +11 -0
  32. package/dist/js/core/RandomStringGenerator.js +23 -0
  33. package/dist/js/core/Response.d.ts +20 -0
  34. package/dist/js/core/Response.js +13 -0
  35. package/dist/js/core/Uploader.d.ts +7 -0
  36. package/dist/js/core/Uploader.js +134 -0
  37. package/dist/js/core/Validator.d.ts +27 -0
  38. package/dist/js/core/Validator.js +80 -0
  39. package/dist/js/extensions/jqueryExtensions.d.ts +11 -0
  40. package/dist/js/extensions/jqueryExtensions.js +99 -0
  41. package/dist/js/extensions/numberExtensions.d.ts +8 -0
  42. package/dist/js/extensions/numberExtensions.js +19 -0
  43. package/dist/js/extensions/stringExtensions.d.ts +12 -0
  44. package/dist/js/extensions/stringExtensions.js +49 -0
  45. package/dist/js/index.d.ts +22 -0
  46. package/dist/js/index.js +22 -0
  47. package/dist/js/interfaces/KeyValue.d.ts +4 -0
  48. package/dist/js/interfaces/KeyValue.js +1 -0
  49. package/dist/js/login.js +4 -3
  50. package/dist/js/models/Content.d.ts +50 -0
  51. package/dist/js/models/Content.js +1 -0
  52. package/dist/js/models/Property.d.ts +9 -0
  53. package/dist/js/models/Property.js +2 -0
  54. package/dist/js/models/Users.d.ts +7 -0
  55. package/dist/js/models/Users.js +2 -0
  56. package/package.json +59 -55
  57. package/src/css/admin.css +580 -187
  58. package/src/css/admin.css.map +1 -1
  59. package/src/css/app.css +576 -183
  60. package/src/css/app.css.map +1 -1
  61. package/src/css/button.css +0 -3
  62. package/src/css/button.css.map +1 -1
  63. package/src/css/editor.css +576 -183
  64. package/src/css/editor.css.map +1 -1
  65. package/src/css/install.css +576 -183
  66. package/src/css/install.css.map +1 -1
  67. package/src/css/login.css +576 -183
  68. package/src/css/login.css.map +1 -1
  69. package/src/js/admin.js +717 -699
  70. package/src/js/admin.js.map +1 -1
  71. package/src/js/app.js +395 -351
  72. package/src/js/app.js.map +1 -1
  73. package/src/js/login.js +8 -7
  74. package/src/js/login.js.map +1 -1
  75. package/src/scss/admin/layout/content/footer.scss +3 -4
  76. package/src/scss/admin/layout/content/title.scss +3 -6
  77. package/src/scss/admin/layout/content.scss +3 -5
  78. package/src/scss/admin/media.scss +13 -22
  79. package/src/scss/admin.scss +2 -6
  80. package/src/scss/app.scss +2 -2
  81. package/src/scss/button.scss +1 -14
  82. package/src/scss/editor.scss +2 -3
  83. package/src/scss/install.scss +1 -1
  84. package/src/scss/login.scss +2 -16
  85. package/src/ts/admin.ts +7 -8
  86. package/src/ts/app.ts +0 -2
  87. package/src/ts/core/BaseSite.ts +21 -0
  88. package/src/ts/core/ColorPicker.ts +5 -1
  89. package/src/ts/core/Editors.ts +6 -7
  90. package/src/ts/core/HoodApi.ts +5 -0
  91. package/src/ts/core/Media.ts +4 -0
  92. package/src/ts/index.ts +25 -0
  93. package/src/ts/hood.ts +0 -5
package/src/js/app.js CHANGED
@@ -1,16 +1,20 @@
1
1
  /*!
2
- * hoodcms v5.0.5
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
3
5
  * Released under the GPL-3.0 License.
4
6
  */
5
7
  (function (global, factory) {
6
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('sweetalert2'), require('bootstrap')) :
7
- typeof define === 'function' && define.amd ? define(['exports', 'sweetalert2', 'bootstrap'], factory) :
8
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.HoodCMS = {}, global.Swal, global.bootstrap));
9
- }(this, (function (exports, Swal, bootstrap) { 'use strict';
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('sweetalert2'), require('@simonwep/pickr'), require('tinymce/tinymce'), require('bootstrap')) :
9
+ typeof define === 'function' && define.amd ? define(['exports', 'sweetalert2', '@simonwep/pickr', 'tinymce/tinymce', 'bootstrap'], factory) :
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.hood = {}, global.Swal, global.Pickr, global.tinymce, global.bootstrap));
11
+ })(this, (function (exports, Swal, Pickr, tinymce, bootstrap) { 'use strict';
10
12
 
11
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
14
 
13
15
  var Swal__default = /*#__PURE__*/_interopDefaultLegacy(Swal);
16
+ var Pickr__default = /*#__PURE__*/_interopDefaultLegacy(Pickr);
17
+ var tinymce__default = /*#__PURE__*/_interopDefaultLegacy(tinymce);
14
18
 
15
19
  /*! *****************************************************************************
16
20
  Copyright (c) Microsoft Corporation.
@@ -54,7 +58,7 @@
54
58
 
55
59
  "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),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);
56
60
 
57
- var BootstrapSwal = Swal__default['default'].mixin({
61
+ var BootstrapSwal = Swal__default["default"].mixin({
58
62
  customClass: {
59
63
  confirmButton: 'btn btn-success m-1 px-3',
60
64
  cancelButton: 'btn btn-danger m-1 px-3'
@@ -230,173 +234,74 @@
230
234
  return Alerts;
231
235
  }());
232
236
 
233
- var Handlers = /** @class */ (function () {
234
- function Handlers() {
237
+ var ColorPickers = /** @class */ (function () {
238
+ function ColorPickers() {
235
239
  }
236
- /**
237
- * Initialise all default Hood CMS handlers.
238
- */
239
- Handlers.prototype.initDefaultHandlers = function () {
240
- this.checkboxToCsvInput();
241
- this.iconSelector();
242
- this.initSelectValues();
243
- this.scrollHandlers();
244
- this.selectText();
245
- this.setValueOnClick();
246
- this.submitOnChange();
247
- };
248
- /**
249
- * Sets values of any selects that have the value set in data-selected, useful for
250
- */
251
- Handlers.prototype.initSelectValues = function (tag) {
252
- if (tag === void 0) { tag = 'body'; }
253
- $(tag).find('select[data-selected]').each(this.initSelectValuesHandler);
254
- };
255
- Handlers.prototype.initSelectValuesHandler = function (index, element) {
256
- var sel = $(this).data('selected');
257
- if (sel !== 'undefined' && sel !== '') {
258
- var selected = String(sel);
259
- $(this).val(selected);
260
- }
261
- };
262
- /**
263
- * Sets up any Hood Icon selector fields, requires the correct HTML setup.
264
- */
265
- Handlers.prototype.iconSelector = function (tag) {
266
- if (tag === void 0) { tag = 'body'; }
267
- $(tag).find('[data-hood-icon]').each(this.iconSelectorHandler);
268
- };
269
- Handlers.prototype.iconSelectorHandler = function (index, element) {
270
- var $tag = $(this);
271
- var input = $tag.find('input[data-hood-icon-input]');
272
- var display = $tag.find('[data-hood-icon-display]');
273
- var collapse = $tag.find('.collapse');
274
- $tag.find('[data-hood-icon-key][data-hood-icon-value]').on('click', function () {
275
- $tag.find('[data-hood-icon-key][data-hood-icon-value]').removeClass('active');
276
- $(this).addClass('active');
277
- var key = $(this).data('hoodIconKey');
278
- var value = $(this).data('hoodIconValue');
279
- $(this);
280
- display.html(value);
281
- input.val(key);
282
- if (collapse) {
283
- collapse.removeClass('show');
240
+ ColorPickers.prototype.loadColorPickers = function (tag) {
241
+ if (tag === void 0) { tag = '.color-picker'; }
242
+ var updateColorFieldValue = function (color, eventSource, instance) {
243
+ var elemId = $(instance._root.button).parent().data('target');
244
+ $(instance._root.button).parent().css({ 'background-color': color.toHEXA().toString() });
245
+ var colorHex = instance.getColor().toHEXA();
246
+ var result = "";
247
+ for (var i = colorHex.length - 1; i >= 0; i--) {
248
+ result = colorHex[i] + result;
284
249
  }
250
+ $(elemId).val('#' + result);
251
+ $(elemId).change();
252
+ };
253
+ // Simple example, see optional options for more configuration.
254
+ $(tag).each(function (index, elem) {
255
+ var lockOpacity = true;
256
+ if ($(this).data('opacity') == 'true') {
257
+ lockOpacity = false;
258
+ }
259
+ Pickr__default["default"].create({
260
+ el: elem.children[0],
261
+ appClass: 'custom-class',
262
+ theme: 'monolith',
263
+ useAsButton: true,
264
+ default: $(this).data('default') || 'none',
265
+ lockOpacity: lockOpacity,
266
+ defaultRepresentation: 'HEXA',
267
+ position: 'bottom-end',
268
+ components: {
269
+ opacity: true,
270
+ hue: true,
271
+ interaction: {
272
+ hex: false,
273
+ rgba: false,
274
+ hsva: false,
275
+ input: true,
276
+ clear: true
277
+ }
278
+ }
279
+ })
280
+ .on('init', function (instance) {
281
+ var elemId = $(instance._root.button).parent().data('target');
282
+ var value = $(elemId).val();
283
+ $(instance._root.button).parent().on('click', $.proxy(function () {
284
+ this.show();
285
+ }, instance));
286
+ $(elemId).on('click', $.proxy(function () {
287
+ this.show();
288
+ }, instance));
289
+ if (value) {
290
+ instance.setColor(value);
291
+ updateColorFieldValue(instance.getColor(), null, instance);
292
+ }
293
+ })
294
+ .on('clear', function (instance) {
295
+ var elemId = $(instance._root.button).parent().data('target');
296
+ instance.setColor('transparent');
297
+ updateColorFieldValue(instance.getColor(), null, instance);
298
+ $(elemId).val('');
299
+ $(elemId).change();
300
+ })
301
+ .on('change', updateColorFieldValue);
285
302
  });
286
303
  };
287
- /**
288
- * Submits the form when input is changed, mark inputs with .submit-on-change class.
289
- */
290
- Handlers.prototype.selectText = function (tag) {
291
- if (tag === void 0) { tag = 'body'; }
292
- $(tag).on('click', '.select-text', this.selectTextHandler);
293
- };
294
- Handlers.prototype.selectTextHandler = function () {
295
- var $this = $(this);
296
- $this.select();
297
- // Work around Chrome's little problem
298
- $this.mouseup(function () {
299
- // Prevent further mouseup intervention
300
- $this.unbind("mouseup");
301
- return false;
302
- });
303
- };
304
- /**
305
- * Attaches handlers for default scrolling functions, scroll to top, scroll to target (with header.header offset calculated)
306
- * and scroll to target direct (with no calculated offset).
307
- */
308
- Handlers.prototype.scrollHandlers = function (tag) {
309
- if (tag === void 0) { tag = 'body'; }
310
- $(tag).on('click', '.scroll-top, .scroll-to-top', this.scrollTop);
311
- $(tag).on('click', '.scroll-target, .scroll-to-target', this.scrollTarget);
312
- $(tag).on('click', '.scroll-target-direct, .scroll-to-target-direct', this.scrollTargetDirect);
313
- };
314
- Handlers.prototype.scrollTop = function (e) {
315
- if (e)
316
- e.preventDefault();
317
- $('html, body').animate({ scrollTop: 0 }, 800);
318
- return false;
319
- };
320
- Handlers.prototype.scrollTarget = function (e) {
321
- if (e)
322
- e.preventDefault();
323
- var url = $(this).attr('href').split('#')[0];
324
- if (url !== window.location.pathname && url !== "") {
325
- return;
326
- }
327
- var target = this.hash;
328
- var $target = $(target);
329
- var $header = $('header.header');
330
- var headerOffset = 0;
331
- if ($header) {
332
- headerOffset = $header.height();
333
- }
334
- if ($(this).data('offset'))
335
- $('html, body').stop().animate({
336
- 'scrollTop': $target.offset().top - $(this).data('offset')
337
- }, 900, 'swing');
338
- else
339
- $('html, body').stop().animate({
340
- 'scrollTop': $target.offset().top - headerOffset
341
- }, 900, 'swing');
342
- };
343
- Handlers.prototype.scrollTargetDirect = function () {
344
- var scrollTop = $('body').scrollTop();
345
- var top = $($(this).attr('href')).offset().top;
346
- $('html, body').animate({
347
- scrollTop: top
348
- }, Math.abs(top - scrollTop));
349
- return false;
350
- };
351
- /**
352
- * Compiles any selected checkboxes with matching data-hood-csv-input tags,
353
- * then saves the CSV list of the values to the input given in the tag.
354
- */
355
- Handlers.prototype.checkboxToCsvInput = function (tag) {
356
- if (tag === void 0) { tag = 'body'; }
357
- $(tag).on('change', 'input[type=checkbox][data-hood-csv-input]', this.checkboxToCsvInputHandler);
358
- };
359
- Handlers.prototype.checkboxToCsvInputHandler = function (e) {
360
- if (e)
361
- e.preventDefault();
362
- // when i change - create an array, with any other checked of the same data-input checkboxes. and add to the data-input referenced tag.
363
- var items = new Array();
364
- $('input[data-hood-csv-input="' + $(this).data('hoodCsvInput') + '"]').each(function () {
365
- if ($(this).is(":checked"))
366
- items.push($(this).val());
367
- });
368
- var id = '#' + $(this).data('input');
369
- var vals = JSON.stringify(items);
370
- $(id).val(vals);
371
- };
372
- /**
373
- * Submits the form when input is changed, mark inputs with .submit-on-change class.
374
- */
375
- Handlers.prototype.submitOnChange = function (tag) {
376
- if (tag === void 0) { tag = 'body'; }
377
- $(tag).on('change', '.submit-on-change', this.submitOnChangeHandler);
378
- };
379
- Handlers.prototype.submitOnChangeHandler = function (e) {
380
- if (e)
381
- e.preventDefault();
382
- $(this).parents('form').submit();
383
- };
384
- /**
385
- * Sets the value of the input [data-target] when clicked to the value in [data-value]
386
- */
387
- Handlers.prototype.setValueOnClick = function (tag) {
388
- if (tag === void 0) { tag = 'body'; }
389
- $(tag).on('click', '.click-select[data-target][data-value]', this.setValueOnClickHandler);
390
- };
391
- Handlers.prototype.setValueOnClickHandler = function () {
392
- var $this = $(this);
393
- var targetId = '#' + $this.data('target');
394
- $(targetId).val($this.data('value'));
395
- $(targetId).trigger('change');
396
- $('.click-select.clean[data-target="' + $this.data('target') + '"]').each(function () { $(this).removeClass('active'); });
397
- $('.click-select.clean[data-target="' + $this.data('target') + '"][data-value="' + $this.data('value') + '"]').each(function () { $(this).addClass('active'); });
398
- };
399
- return Handlers;
304
+ return ColorPickers;
400
305
  }());
401
306
 
402
307
  var Response = /** @class */ (function () {
@@ -518,7 +423,7 @@
518
423
  listUrl.search = url.search;
519
424
  this.reload(new URL(listUrl.href));
520
425
  }.bind(this));
521
- $('body').on('submit', "form.inline[data-target=\"#" + this.element.id + "\"]", function (e) {
426
+ $('body').on('submit', "form.inline[data-target=\"#".concat(this.element.id, "\"]"), function (e) {
522
427
  e.preventDefault();
523
428
  var $form = $(e.currentTarget);
524
429
  var listUrl = document.createElement('a');
@@ -754,6 +659,9 @@
754
659
  dz = this;
755
660
  }
756
661
  });
662
+ dz.on("error", function (file, errormessage) {
663
+ Alerts.warning(errormessage);
664
+ }.bind(this));
757
665
  dz.on("success", function (file, data) {
758
666
  Response.process(data);
759
667
  }.bind(this));
@@ -812,7 +720,7 @@
812
720
  if (response.data.length > 0) {
813
721
  var listUrl = document.createElement('a');
814
722
  listUrl.href = $(this.element).data('url');
815
- listUrl.search = "?dir=" + response.data[0];
723
+ listUrl.search = "?dir=".concat(response.data[0]);
816
724
  this.media.reload(new URL(listUrl.href));
817
725
  }
818
726
  }.bind(this));
@@ -853,7 +761,7 @@
853
761
  // TODO: On close, reload the list and reinstate the modal??
854
762
  };
855
763
  MediaService.prototype.select = function (mediaObject, e) {
856
- Alerts.log("[MediaService.select] Selecting media object id " + mediaObject.id + " - " + mediaObject.filename + " and inserting " + this.options.size + " url to target: " + this.options.target);
764
+ 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));
857
765
  if (this.options.target) {
858
766
  var target = $(this.options.target);
859
767
  switch (this.options.size) {
@@ -884,7 +792,7 @@
884
792
  };
885
793
  MediaService.prototype.insert = function (mediaObject, e) {
886
794
  // basic functionality to insert the correct string from the media response (from uploader) to given input element.
887
- Alerts.log("[MediaService.insert] Selecting media object id " + mediaObject.id + " - " + mediaObject.filename + " and inserting " + this.options.size + " image to target editor: " + this.options.target);
795
+ 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));
888
796
  this.options.targetEditor.insertContent('<img alt="' + mediaObject.filename + '" src="' + mediaObject.url + '" class="img-fluid" />');
889
797
  // Run the callback for onAction
890
798
  if (this.options.onAction) {
@@ -893,7 +801,7 @@
893
801
  };
894
802
  MediaService.prototype.attach = function (mediaObject, e) {
895
803
  // once file is uploaded to given directory, send media id to the given attach endpoint.
896
- Alerts.log("[MediaService.attach] Attaching media object id " + mediaObject.id + " - " + mediaObject.filename + " to url: " + this.options.url);
804
+ Alerts.log("[MediaService.attach] Attaching media object id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, " to url: ").concat(this.options.url));
897
805
  $.post(this.options.url, { mediaId: mediaObject.id }, function (response) {
898
806
  Response.process(response, 5000);
899
807
  MediaService.refresh(response.media, this.options.refresh);
@@ -906,12 +814,12 @@
906
814
  MediaService.prototype.galleryClick = function (mediaObject, e) {
907
815
  // once file is uploaded to given directory, send media id to the given attach endpoint.
908
816
  if (!this.isMediaSelected(mediaObject)) {
909
- Alerts.log("[MediaService.galleryClick] Adding to selected media objects - id " + mediaObject.id + " - " + mediaObject.filename + ".");
817
+ Alerts.log("[MediaService.galleryClick] Adding to selected media objects - id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, "."));
910
818
  this.selectedMedia.push(mediaObject);
911
819
  $(e.currentTarget).parents('.media-item').addClass('active');
912
820
  }
913
821
  else {
914
- Alerts.log("[MediaService.galleryClick] Removing media from selection - id " + mediaObject.id + " - " + mediaObject.filename + ".}");
822
+ Alerts.log("[MediaService.galleryClick] Removing media from selection - id ".concat(mediaObject.id, " - ").concat(mediaObject.filename, ".}"));
915
823
  this.selectedMedia = this.selectedMedia.filter(function (obj) {
916
824
  return obj.id !== mediaObject.id;
917
825
  });
@@ -922,7 +830,7 @@
922
830
  e.preventDefault();
923
831
  e.stopPropagation();
924
832
  // once file is uploaded to given directory, send media id to the given attach endpoint.
925
- Alerts.log("[MediaService.galleryAdd] Adding " + this.selectedMedia.length + " selected media objects to url: " + this.options.url);
833
+ Alerts.log("[MediaService.galleryAdd] Adding ".concat(this.selectedMedia.length, " selected media objects to url: ").concat(this.options.url));
926
834
  var mediaIds = this.selectedMedia.map(function (v) {
927
835
  return v.id;
928
836
  });
@@ -1048,6 +956,311 @@
1048
956
  return MediaModal;
1049
957
  }());
1050
958
 
959
+ var Editors = /** @class */ (function () {
960
+ function Editors(options) {
961
+ this.options = {
962
+ linkClasses: [
963
+ { title: 'None', value: '' },
964
+ { title: 'Button link', value: 'btn btn-default' },
965
+ { title: 'Theme coloured button link', value: 'btn btn-primary' },
966
+ { title: 'Popup image/video', value: 'colorbox-iframe' },
967
+ { title: 'Button popup link', value: 'btn btn-default colorbox-iframe' },
968
+ { title: 'Theme coloured button popup link', value: 'btn btn-primary colorbox-iframe' },
969
+ { title: 'Large link', value: 'font-lg' },
970
+ { title: 'Large button link', value: 'btn btn-default btn-lg' },
971
+ { title: 'Large theme coloured button link', value: 'btn btn-primary btn-lg' },
972
+ { title: 'Large popup image/video', value: 'font-lg colorbox-iframe' },
973
+ { title: 'Large Button popup link', value: 'btn btn-default btn-lg colorbox-iframe' },
974
+ { title: 'Theme coloured button popup link', value: 'btn btn-primary btn-lg colorbox-iframe' }
975
+ ],
976
+ imageClasses: [
977
+ { title: 'None', value: '' },
978
+ { title: 'Full Width', value: 'user-image full' },
979
+ { title: 'Left Aligned', value: 'user-image left' },
980
+ { title: 'Centered', value: 'user-image center' },
981
+ { title: 'Right Aligned', value: 'user-image right' },
982
+ { title: 'Inline with text, top aligned', value: 'user-image inline top' },
983
+ { title: 'Inline with text, middle aligned', value: 'user-image inline' },
984
+ { title: 'Inline with text, bottom aligned', value: 'user-image inline bottom' },
985
+ { title: 'Pulled Left', value: 'user-image pull-left' },
986
+ { title: 'Pulled Right', value: 'user-image pull-right' },
987
+ ]
988
+ };
989
+ this.options = __assign(__assign({}, this.options), options);
990
+ }
991
+ Editors.prototype.richTextEditors = function () {
992
+ tinymce__default["default"].init({
993
+ selector: '.tinymce-full',
994
+ height: 150,
995
+ menubar: false,
996
+ plugins: [
997
+ 'advlist autolink lists link image charmap print preview anchor media',
998
+ 'searchreplace visualblocks code fullscreen',
999
+ 'insertdatetime media contextmenu paste code textcolor'
1000
+ ],
1001
+ toolbar: "fullscreen | styleselect forecolor backcolor | hoodimage link media image | bold italic | alignleft aligncenter alignright | bullist numlist | table | undo redo",
1002
+ link_class_list: this.options.linkClasses,
1003
+ image_class_list: this.options.imageClasses,
1004
+ setup: this.setupCommands.bind(this),
1005
+ image_dimensions: false,
1006
+ content_css: [
1007
+ '/dist/css/editor.css'
1008
+ ],
1009
+ });
1010
+ tinymce__default["default"].init({
1011
+ selector: '.tinymce-simple',
1012
+ height: 150,
1013
+ plugins: [
1014
+ 'advlist autolink lists link image charmap print preview anchor media',
1015
+ 'searchreplace visualblocks code fullscreen',
1016
+ 'insertdatetime media contextmenu paste code'
1017
+ ],
1018
+ menubar: false,
1019
+ toolbar: 'fullscreen | bold italic | bullist numlist | undo redo | link',
1020
+ link_class_list: this.options.linkClasses,
1021
+ image_class_list: this.options.imageClasses,
1022
+ setup: this.setupCommands.bind(this),
1023
+ image_dimensions: false
1024
+ });
1025
+ tinymce__default["default"].init({
1026
+ selector: '.tinymce-full-content',
1027
+ height: 500,
1028
+ menubar: false,
1029
+ plugins: [
1030
+ 'advlist autolink lists link image charmap print preview anchor media',
1031
+ 'searchreplace visualblocks code fullscreen',
1032
+ 'insertdatetime media contextmenu paste code textcolor'
1033
+ ],
1034
+ toolbar: "fullscreen | styleselect forecolor backcolor | hoodimage link media image | bold italic | alignleft aligncenter alignright | bullist numlist | table | undo redo",
1035
+ link_class_list: this.options.linkClasses,
1036
+ image_class_list: this.options.imageClasses,
1037
+ setup: this.setupCommands.bind(this),
1038
+ image_dimensions: false
1039
+ });
1040
+ tinymce__default["default"].init({
1041
+ selector: '.tinymce-simple-content',
1042
+ height: 500,
1043
+ plugins: [
1044
+ 'advlist autolink lists link image charmap print preview anchor media',
1045
+ 'searchreplace visualblocks code fullscreen',
1046
+ 'insertdatetime media contextmenu paste code'
1047
+ ],
1048
+ menubar: false,
1049
+ toolbar: 'fullscreen | bold italic | bullist numlist | undo redo | link',
1050
+ link_class_list: this.options.linkClasses,
1051
+ image_class_list: this.options.imageClasses,
1052
+ image_dimensions: false
1053
+ });
1054
+ };
1055
+ Editors.prototype.setupCommands = function (editor) {
1056
+ this.currentEditor = $('#' + editor.id);
1057
+ if (this.currentEditor.data('hoodMediaList')) {
1058
+ editor.addButton('hoodimage', {
1059
+ text: 'Insert image...',
1060
+ icon: false,
1061
+ onclick: function (e) {
1062
+ this.mediaModal = new ModalController({
1063
+ onComplete: function (sender) {
1064
+ this.list = document.getElementById('media-list');
1065
+ this.service = new MediaService(this.list, {
1066
+ action: 'insert',
1067
+ url: this.currentEditor.data('hoodMediaList'),
1068
+ targetEditor: editor,
1069
+ size: this.currentEditor.data('hoodMediaSize'),
1070
+ beforeAction: function (sender, mediaObject) {
1071
+ }.bind(this),
1072
+ onAction: function (sender, mediaObject) {
1073
+ this.mediaModal.close();
1074
+ }.bind(this),
1075
+ onListLoad: function (sender) {
1076
+ },
1077
+ onListRender: function (data) {
1078
+ return data;
1079
+ },
1080
+ onListComplete: function (data) {
1081
+ },
1082
+ onError: function (jqXHR, textStatus, errorThrown) {
1083
+ },
1084
+ });
1085
+ }.bind(this)
1086
+ });
1087
+ this.mediaModal.show(this.currentEditor.data('hoodMediaList'), e.currentTarget);
1088
+ }.bind(this)
1089
+ });
1090
+ }
1091
+ };
1092
+ return Editors;
1093
+ }());
1094
+
1095
+ var Handlers = /** @class */ (function () {
1096
+ function Handlers() {
1097
+ }
1098
+ /**
1099
+ * Initialise all default Hood CMS handlers.
1100
+ */
1101
+ Handlers.prototype.initDefaultHandlers = function () {
1102
+ this.checkboxToCsvInput();
1103
+ this.iconSelector();
1104
+ this.initSelectValues();
1105
+ this.scrollHandlers();
1106
+ this.selectText();
1107
+ this.setValueOnClick();
1108
+ this.submitOnChange();
1109
+ };
1110
+ /**
1111
+ * Sets values of any selects that have the value set in data-selected, useful for
1112
+ */
1113
+ Handlers.prototype.initSelectValues = function (tag) {
1114
+ if (tag === void 0) { tag = 'body'; }
1115
+ $(tag).find('select[data-selected]').each(this.initSelectValuesHandler);
1116
+ };
1117
+ Handlers.prototype.initSelectValuesHandler = function (index, element) {
1118
+ var sel = $(this).data('selected');
1119
+ if (sel !== 'undefined' && sel !== '') {
1120
+ var selected = String(sel);
1121
+ $(this).val(selected);
1122
+ }
1123
+ };
1124
+ /**
1125
+ * Sets up any Hood Icon selector fields, requires the correct HTML setup.
1126
+ */
1127
+ Handlers.prototype.iconSelector = function (tag) {
1128
+ if (tag === void 0) { tag = 'body'; }
1129
+ $(tag).find('[data-hood-icon]').each(this.iconSelectorHandler);
1130
+ };
1131
+ Handlers.prototype.iconSelectorHandler = function (index, element) {
1132
+ var $tag = $(this);
1133
+ var input = $tag.find('input[data-hood-icon-input]');
1134
+ var display = $tag.find('[data-hood-icon-display]');
1135
+ var collapse = $tag.find('.collapse');
1136
+ $tag.find('[data-hood-icon-key][data-hood-icon-value]').on('click', function () {
1137
+ $tag.find('[data-hood-icon-key][data-hood-icon-value]').removeClass('active');
1138
+ $(this).addClass('active');
1139
+ var key = $(this).data('hoodIconKey');
1140
+ var value = $(this).data('hoodIconValue');
1141
+ $(this);
1142
+ display.html(value);
1143
+ input.val(key);
1144
+ if (collapse) {
1145
+ collapse.removeClass('show');
1146
+ }
1147
+ });
1148
+ };
1149
+ /**
1150
+ * Submits the form when input is changed, mark inputs with .submit-on-change class.
1151
+ */
1152
+ Handlers.prototype.selectText = function (tag) {
1153
+ if (tag === void 0) { tag = 'body'; }
1154
+ $(tag).on('click', '.select-text', this.selectTextHandler);
1155
+ };
1156
+ Handlers.prototype.selectTextHandler = function () {
1157
+ var $this = $(this);
1158
+ $this.select();
1159
+ // Work around Chrome's little problem
1160
+ $this.mouseup(function () {
1161
+ // Prevent further mouseup intervention
1162
+ $this.unbind("mouseup");
1163
+ return false;
1164
+ });
1165
+ };
1166
+ /**
1167
+ * Attaches handlers for default scrolling functions, scroll to top, scroll to target (with header.header offset calculated)
1168
+ * and scroll to target direct (with no calculated offset).
1169
+ */
1170
+ Handlers.prototype.scrollHandlers = function (tag) {
1171
+ if (tag === void 0) { tag = 'body'; }
1172
+ $(tag).on('click', '.scroll-top, .scroll-to-top', this.scrollTop);
1173
+ $(tag).on('click', '.scroll-target, .scroll-to-target', this.scrollTarget);
1174
+ $(tag).on('click', '.scroll-target-direct, .scroll-to-target-direct', this.scrollTargetDirect);
1175
+ };
1176
+ Handlers.prototype.scrollTop = function (e) {
1177
+ if (e)
1178
+ e.preventDefault();
1179
+ $('html, body').animate({ scrollTop: 0 }, 800);
1180
+ return false;
1181
+ };
1182
+ Handlers.prototype.scrollTarget = function (e) {
1183
+ if (e)
1184
+ e.preventDefault();
1185
+ var url = $(this).attr('href').split('#')[0];
1186
+ if (url !== window.location.pathname && url !== "") {
1187
+ return;
1188
+ }
1189
+ var target = this.hash;
1190
+ var $target = $(target);
1191
+ var $header = $('header.header');
1192
+ var headerOffset = 0;
1193
+ if ($header) {
1194
+ headerOffset = $header.height();
1195
+ }
1196
+ if ($(this).data('offset'))
1197
+ $('html, body').stop().animate({
1198
+ 'scrollTop': $target.offset().top - $(this).data('offset')
1199
+ }, 900, 'swing');
1200
+ else
1201
+ $('html, body').stop().animate({
1202
+ 'scrollTop': $target.offset().top - headerOffset
1203
+ }, 900, 'swing');
1204
+ };
1205
+ Handlers.prototype.scrollTargetDirect = function () {
1206
+ var scrollTop = $('body').scrollTop();
1207
+ var top = $($(this).attr('href')).offset().top;
1208
+ $('html, body').animate({
1209
+ scrollTop: top
1210
+ }, Math.abs(top - scrollTop));
1211
+ return false;
1212
+ };
1213
+ /**
1214
+ * Compiles any selected checkboxes with matching data-hood-csv-input tags,
1215
+ * then saves the CSV list of the values to the input given in the tag.
1216
+ */
1217
+ Handlers.prototype.checkboxToCsvInput = function (tag) {
1218
+ if (tag === void 0) { tag = 'body'; }
1219
+ $(tag).on('change', 'input[type=checkbox][data-hood-csv-input]', this.checkboxToCsvInputHandler);
1220
+ };
1221
+ Handlers.prototype.checkboxToCsvInputHandler = function (e) {
1222
+ if (e)
1223
+ e.preventDefault();
1224
+ // when i change - create an array, with any other checked of the same data-input checkboxes. and add to the data-input referenced tag.
1225
+ var items = new Array();
1226
+ $('input[data-hood-csv-input="' + $(this).data('hoodCsvInput') + '"]').each(function () {
1227
+ if ($(this).is(":checked"))
1228
+ items.push($(this).val());
1229
+ });
1230
+ var id = '#' + $(this).data('input');
1231
+ var vals = JSON.stringify(items);
1232
+ $(id).val(vals);
1233
+ };
1234
+ /**
1235
+ * Submits the form when input is changed, mark inputs with .submit-on-change class.
1236
+ */
1237
+ Handlers.prototype.submitOnChange = function (tag) {
1238
+ if (tag === void 0) { tag = 'body'; }
1239
+ $(tag).on('change', '.submit-on-change', this.submitOnChangeHandler);
1240
+ };
1241
+ Handlers.prototype.submitOnChangeHandler = function (e) {
1242
+ if (e)
1243
+ e.preventDefault();
1244
+ $(this).parents('form').submit();
1245
+ };
1246
+ /**
1247
+ * Sets the value of the input [data-target] when clicked to the value in [data-value]
1248
+ */
1249
+ Handlers.prototype.setValueOnClick = function (tag) {
1250
+ if (tag === void 0) { tag = 'body'; }
1251
+ $(tag).on('click', '.click-select[data-target][data-value]', this.setValueOnClickHandler);
1252
+ };
1253
+ Handlers.prototype.setValueOnClickHandler = function () {
1254
+ var $this = $(this);
1255
+ var targetId = '#' + $this.data('target');
1256
+ $(targetId).val($this.data('value'));
1257
+ $(targetId).trigger('change');
1258
+ $('.click-select.clean[data-target="' + $this.data('target') + '"]').each(function () { $(this).removeClass('active'); });
1259
+ $('.click-select.clean[data-target="' + $this.data('target') + '"][data-value="' + $this.data('value') + '"]').each(function () { $(this).addClass('active'); });
1260
+ };
1261
+ return Handlers;
1262
+ }());
1263
+
1051
1264
  var Uploader = /** @class */ (function () {
1052
1265
  function Uploader() {
1053
1266
  if ($('.image-uploader').length || $('.gallery-uploader').length) {
@@ -1188,6 +1401,8 @@
1188
1401
  this.alerts = new Alerts();
1189
1402
  this.uploader = new Uploader();
1190
1403
  this.handlers = new Handlers();
1404
+ this.editors = new Editors();
1405
+ this.colorPickers = new ColorPickers();
1191
1406
  this.mediaModal = new MediaModal();
1192
1407
  // Global Handlers
1193
1408
  this.setupLoaders();
@@ -1271,7 +1486,7 @@
1271
1486
  // size: new google.maps.Size(30, 41),
1272
1487
  // scaledSize: new google.maps.Size(30, 41)
1273
1488
  //});
1274
- marker.info = "<div class=\"card border-0\" style=\"max-width:300px\">\n <div style=\"background-image:url(" + location.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>" + location.Address1 + ", " + location.Postcode + "</strong>\n </p>\n <p>" + location.Description + "</p>\n <a href=\"" + location.MarkerUrl + "\" class=\"btn btn-block btn-primary\">Find out more...</a>\n </div>\n</div>";
1489
+ marker.info = "<div class=\"card border-0\" style=\"max-width:300px\">\n <div style=\"background-image:url(".concat(location.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(location.Address1, ", ").concat(location.Postcode, "</strong>\n </p>\n <p>").concat(location.Description, "</p>\n <a href=\"").concat(location.MarkerUrl, "\" class=\"btn btn-block btn-primary\">Find out more...</a>\n </div>\n</div>");
1275
1490
  google.maps.event.addListener(marker, 'click', function () {
1276
1491
  if (infowindow) {
1277
1492
  infowindow.close();
@@ -1287,176 +1502,6 @@
1287
1502
  return PropertyController;
1288
1503
  }());
1289
1504
 
1290
- $.fn.exists = function () {
1291
- return $(this).length;
1292
- };
1293
- $.fn.restrictToSlug = function (restrictPattern) {
1294
- if (restrictPattern === void 0) { restrictPattern = /[^0-9a-zA-Z]*/g; }
1295
- var targets = $(this);
1296
- // The characters inside this pattern are accepted
1297
- // and everything else will be 'cleaned'
1298
- // For example 'ABCdEfGhI5' become 'ABCEGI5'
1299
- var restrictHandler = function () {
1300
- var val = $(this).val();
1301
- var newVal = val.replace(restrictPattern, '');
1302
- // This condition is to prevent selection and keyboard navigation issues
1303
- if (val !== newVal) {
1304
- $(this).val(newVal);
1305
- }
1306
- };
1307
- targets.on('keyup', restrictHandler);
1308
- targets.on('paste', restrictHandler);
1309
- targets.on('change', restrictHandler);
1310
- };
1311
- $.fn.restrictToPageSlug = function (restrictPattern) {
1312
- if (restrictPattern === void 0) { restrictPattern = /[^0-9a-zA-Z-//]*/g; }
1313
- var targets = $(this);
1314
- // The characters inside this pattern are accepted
1315
- // and everything else will be 'cleaned'
1316
- var restrictHandler = function () {
1317
- var val = $(this).val();
1318
- var newVal = val.replace(restrictPattern, '');
1319
- if ((newVal.match(new RegExp("/", "g")) || []).length > 4) {
1320
- var pos = newVal.lastIndexOf('/');
1321
- newVal = newVal.substring(0, pos) + newVal.substring(pos + 1);
1322
- Alerts.warning("You can only have up to 4 '/' characters in a url slug.");
1323
- }
1324
- // This condition is to prevent selection and keyboard navigation issues
1325
- if (val !== newVal) {
1326
- $(this).val(newVal);
1327
- }
1328
- };
1329
- targets.on('keyup', restrictHandler);
1330
- targets.on('paste', restrictHandler);
1331
- targets.on('change', restrictHandler);
1332
- };
1333
- $.fn.restrictToMetaSlug = function (restrictPattern) {
1334
- if (restrictPattern === void 0) { restrictPattern = /[^0-9a-zA-Z.]*/g; }
1335
- var targets = $(this);
1336
- // The characters inside this pattern are accepted
1337
- // and everything else will be 'cleaned'
1338
- var restrictHandler = function () {
1339
- var val = $(this).val();
1340
- var newVal = val.replace(restrictPattern, '');
1341
- if ((newVal.match(new RegExp(".", "g")) || []).length > 1) {
1342
- var pos = newVal.lastIndexOf('.');
1343
- newVal = newVal.substring(0, pos) + newVal.substring(pos + 1);
1344
- Alerts.warning("You can only have up to 1 '.' characters in a meta slug.");
1345
- }
1346
- // This condition is to prevent selection and keyboard navigation issues
1347
- if (val !== newVal) {
1348
- $(this).val(newVal);
1349
- }
1350
- };
1351
- targets.on('keyup', restrictHandler);
1352
- targets.on('paste', restrictHandler);
1353
- targets.on('change', restrictHandler);
1354
- };
1355
- $.fn.characterCounter = function () {
1356
- var targets = $(this);
1357
- var characterCounterHandler = function () {
1358
- var counter = $(this).data('counter');
1359
- var max = Number($(this).attr('maxlength'));
1360
- var len = $(this).val().length;
1361
- $(counter).text(max - len);
1362
- var cls = "text-success";
1363
- if (max - len < max / 10)
1364
- cls = "text-danger";
1365
- $(counter).parent().removeClass('text-success').removeClass('text-danger').addClass(cls);
1366
- };
1367
- targets.on('keyup', characterCounterHandler);
1368
- targets.on('paste', characterCounterHandler);
1369
- targets.on('change', characterCounterHandler);
1370
- };
1371
- $.fn.warningAlert = function () {
1372
- var targets = $(this);
1373
- var warningAlertHandler = function (e) {
1374
- e.preventDefault();
1375
- var warningAlertCallback = function (result) {
1376
- if (result.isConfirmed) {
1377
- var url = $(e.currentTarget).attr('href');
1378
- window.location.href = url;
1379
- }
1380
- };
1381
- Alerts.confirm({
1382
- title: $(e.currentTarget).data('title'),
1383
- html: $(e.currentTarget).data('warning'),
1384
- footer: $(e.currentTarget).data('footer'),
1385
- icon: 'warning'
1386
- }, warningAlertCallback);
1387
- return false;
1388
- };
1389
- targets.on('click', warningAlertHandler);
1390
- };
1391
-
1392
- Number.prototype.formatCurrency = function (currency) {
1393
- return currency + " " + this.toFixed(2).replace(/./g, function (c, i, a) {
1394
- return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
1395
- });
1396
- };
1397
- Number.prototype.formatKilobytes = function () {
1398
- var n = this / 1024;
1399
- return n.toFixed(0).replace(/./g, function (c, i, a) {
1400
- return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
1401
- }) + "Kb";
1402
- };
1403
- Number.prototype.formatMegabytes = function () {
1404
- var n = this / 1024;
1405
- n = n / 1024;
1406
- return n.toFixed(0).replace(/./g, function (c, i, a) {
1407
- return i > 0 && c !== "." && (a.length - i) % 3 === 0 ? "," + c : c;
1408
- }) + "Mb";
1409
- };
1410
-
1411
- String.prototype.htmlEncode = function () {
1412
- //create a in-memory div, set it's inner text(which jQuery automatically encodes)
1413
- //then grab the encoded contents back out. The div never exists on the page.
1414
- return $('<div/>').text(this).html();
1415
- };
1416
- String.prototype.htmlDecode = function () {
1417
- return $('<div/>').html(this).text();
1418
- };
1419
- String.prototype.contains = function (it) {
1420
- return this.indexOf(it) !== -1;
1421
- };
1422
- String.prototype.pick = function (min, max) {
1423
- var n, chars = '';
1424
- if (typeof max === 'undefined') {
1425
- n = min;
1426
- }
1427
- else {
1428
- n = min + Math.floor(Math.random() * (max - min));
1429
- }
1430
- for (var i = 0; i < n; i++) {
1431
- chars += this.charAt(Math.floor(Math.random() * this.length));
1432
- }
1433
- return chars;
1434
- };
1435
- // Credit to @Christoph: http://stackoverflow.com/a/962890/464744
1436
- String.prototype.shuffle = function () {
1437
- var array = this.split('');
1438
- var tmp, current, top = array.length;
1439
- if (top)
1440
- while (--top) {
1441
- current = Math.floor(Math.random() * (top + 1));
1442
- tmp = array[current];
1443
- array[current] = array[top];
1444
- array[top] = tmp;
1445
- }
1446
- return array.join('');
1447
- };
1448
- String.prototype.toSeoUrl = function () {
1449
- var output = this.replace(/[^a-zA-Z0-9]/g, ' ').replace(/\s+/g, "-").toLowerCase();
1450
- /* remove first dash */
1451
- if (output.charAt(0) === '-')
1452
- output = output.substring(1);
1453
- /* remove last dash */
1454
- var last = output.length - 1;
1455
- if (output.charAt(last) === '-')
1456
- output = output.substring(0, last);
1457
- return output;
1458
- };
1459
-
1460
1505
  /// <reference types="google.maps" />
1461
1506
  var App = /** @class */ (function (_super) {
1462
1507
  __extends(App, _super);
@@ -1524,11 +1569,10 @@
1524
1569
  }(HoodApi));
1525
1570
  window.hood = new App();
1526
1571
 
1527
- exports.Alerts = Alerts;
1528
1572
  exports.App = App;
1529
1573
 
1530
1574
  Object.defineProperty(exports, '__esModule', { value: true });
1531
1575
 
1532
- })));
1533
- if (typeof this !== 'undefined' && this.hood){ this.hoodCMS = this.Hood = this.hoodCMS = this.HoodCMS = this.hood}
1576
+ }));
1577
+ if (typeof this !== 'undefined' && this.hood){ this.hoodCMS = this.Hood = this.hoodCMS = this.HoodCMS = this.hood }
1534
1578
  //# sourceMappingURL=app.js.map