Javascript helpers

Hush also provides some js helpers for frontend.

Classes

  • sluggable input with this class will print slugified version of its value to field selector, which should be specified in data-slugify-target attribute.
  • codemirror will transform textarea to code editing area.
  • wysiwyg will transform textarea to WYSIWYG editor.
  • delete-item should be attached to <a> element and when it will be clicked, show user warning window and after confirming will send delete request to url, specified in href.
  • in-modal should be attached to <a> element and when it will be clicked, ajax will try to get modal from the url given in href and show it to the user.
  • submitable - serve for sending form data without page reloading, also it process a validation errors.

JS functions

All js functions are stored in global functions class.
Commonly used functions:

  • functions.initialize() will init most of plugins in case, if you draw it after document's ready jquery event.
  • functions.initializeDeleter() will init delete buttons in case, if you draw it after document's ready jquery event.
  • functions.initializeInModal() will init in-modal buttons in case, if you draw it after document's ready jquery event.
  • functions.initializeSubmitter() will init submitable forms in case, if you draw it after document's ready jquery event.
  • functions.openDynamicModal(link) will open a modal from the given link.
  • functions.request(type, url, data, success, error) will send ajax request and process request as described in Page actions return formats section.
  • functions.notify(text, type, position) will show small notification, more about supported types and positions you can find in noty.js docs.