mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-05 04:46:03 +01:00
Implemented slugify.js for better folder naming #107
This commit is contained in:
@@ -154,11 +154,14 @@ $(function(){
|
||||
|
||||
$('input[name="title"]').on('input', function(e){
|
||||
if (!$('input[name="folder"]').data('user-custom-folder')) {
|
||||
folder = $(this).val().toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
|
||||
folder = $.slugify($(this).val());
|
||||
$('input[name="folder"]').val(folder);
|
||||
}
|
||||
});
|
||||
|
||||
$('#slug-target').slugify('#slug-source');
|
||||
|
||||
|
||||
$('input[name="folder"]').on('input', function(e){
|
||||
value = $(this).val().toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
|
||||
$(this).val(value);
|
||||
|
||||
3
themes/grav/js/slugify.min.js
vendored
Normal file
3
themes/grav/js/slugify.min.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/*! jquery-slugify - v1.2.1 - 2015-08-02
|
||||
* Copyright (c) 2015 madflow; Licensed */
|
||||
!function(a){a.fn.slugify=function(b,c){return this.each(function(){var d=a(this),e=a(b);d.on("keyup change",function(){""!==d.val()&&void 0!==d.val()?d.data("locked",!0):d.data("locked",!1)}),e.on("keyup change",function(){!0!==d.data("locked")&&(d.is("input")||d.is("textarea")?d.val(a.slugify(e.val(),c)):d.text(a.slugify(e.val(),c)))})})},a.slugify=function(b,c){return c=a.extend({},a.slugify.options,c),c.lang=c.lang||a("html").prop("lang"),"function"==typeof c.preSlug&&(b=c.preSlug(b)),b=c.slugFunc(b,c),"function"==typeof c.postSlug&&(b=c.postSlug(b)),b},a.slugify.options={preSlug:null,postSlug:null,slugFunc:function(a,b){return window.getSlug(a,b)}}}(jQuery);
|
||||
7
themes/grav/js/speakingurl.min.js
vendored
Normal file
7
themes/grav/js/speakingurl.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -34,6 +34,8 @@
|
||||
|
||||
{% block javascripts %}
|
||||
{% do assets.addJs(theme_url~'/js/pages-all.js') %}
|
||||
{% do assets.addJs(theme_url~'/js/speakingurl.min.js') %}
|
||||
{% do assets.addJs(theme_url~'/js/slugify.min.js') %}
|
||||
{% if mode == 'edit' %}
|
||||
{% do assets.addJs(theme_url~'/js/codemirror-compressed.js') %}
|
||||
{% do assets.addJs(theme_url~'/js/mdeditor.js') %}
|
||||
|
||||
Reference in New Issue
Block a user