diff --git a/modules/ContactForm/Resources/views/admin/form/basicInfo.blade.php b/modules/ContactForm/Resources/views/admin/form/basicInfo.blade.php index 24f053da..35c51297 100644 --- a/modules/ContactForm/Resources/views/admin/form/basicInfo.blade.php +++ b/modules/ContactForm/Resources/views/admin/form/basicInfo.blade.php @@ -3,15 +3,15 @@ -
+
+
+ +
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index ed996b79..927b86b2 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -1,6 +1,40 @@ // initialize Foundation $ (document).foundation (); +/** + * Makes slug from input string + * + * @param text + * @param trimSpaces + * + * @returns {string} + */ +function slugify(text, trimSpaces) { + text = text.toString ().toLowerCase (); + + if (trimSpaces) + text = text.trim (); + + return text.replace (/ /g, '-') + .replace (/[àáâãäå]/g, "a") + .replace (/[čç]/g, "c") + .replace (/[ěèéêë]/g, "e") + .replace (/[ùúûüů]/g, "u") + .replace (/[ìíîï]/g, "i") + .replace (/[ňńñ]/g, "n") + .replace (/[òóôõö]/g, "o") + .replace (/[ýÿ]/g, "y") + .replace (/œ/g, "oe") + .replace (/ď/g, "d") + .replace (/ř/g, "r") + .replace (/š/g, "s") + .replace (/ž/g, "z") + .replace (/ť/g, "t") + .replace (/æ/g, "ae") + .replace (/[^a-z0-9\-]+/g, '') + .replace (/\-\-+/g, '-'); +} + // bind some custom methods $ (document).ready (function () { $ ('.confirm').click (function () { @@ -11,8 +45,24 @@ $ (document).ready (function () { confirmMessage = 'Really?'; } - var confirmation = confirm (confirmMessage); + return confirm (confirmMessage); + }); - return confirmation; + $('#lockUrl').change(function () { + $ ('.slug-source').keyup (); + }); + + $ ('.slug-target').keyup (function () { + $ (this).val (slugify ($ (this).val (), false)); + $('#lockUrl').prop('checked', true); + }); + + $ ('.slug-source').keyup (function () { + var source = $ (this); + var target = $ ('.slug-target'); + var locked = $ ('#lockUrl'); + + if (!locked.is (':checked')) + target.val (slugify (source.val (), true)); }); }); \ No newline at end of file diff --git a/resources/lang/en/admin/contents.php b/resources/lang/en/admin/contents.php index 6cc861ca..63f6f422 100644 --- a/resources/lang/en/admin/contents.php +++ b/resources/lang/en/admin/contents.php @@ -42,6 +42,6 @@ return [ 'noHomepage' => 'You have not set up your homepage yet, or your current homepage is draft! Try to select another one.', 'homepageProtected' => 'Your homepage is displayed only for logged in users. This may or may not be an error.', 'parentPage' => 'Parent page', - 'alreadyHomepage' => 'Homepage' - + 'alreadyHomepage' => 'Homepage', + 'lockUrl' => 'Keep URL' ]; \ No newline at end of file diff --git a/resources/views/admin/content/formParts/basicInformation.blade.php b/resources/views/admin/content/formParts/basicInformation.blade.php index a47236aa..be762aa0 100644 --- a/resources/views/admin/content/formParts/basicInformation.blade.php +++ b/resources/views/admin/content/formParts/basicInformation.blade.php @@ -3,15 +3,15 @@
-
+
+
+ +