Skip to content

Commit 65249f1

Browse files
committed
Using updated jquery.slug script
1 parent 9753119 commit 65249f1

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

assets/js/vendor/jquery.slug.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
//
22
// jQuery Slug Generation Plugin by Perry Trinier ([email protected])
33
// Modified November 2015 by Micheal Mand for AsgardCMS ([email protected])
4+
// Modified November 2015 by Simon Funk for AsgardCMS ([email protected])
45
// Licensed under the GPL: http://www.gnu.org/copyleft/gpl.html
56

67
jQuery.fn.slug = function (options) {
78
var settings = {
89
slug: 'slug', // Class used for slug destination input and span. The span is created on $(document).ready()
9-
hide: false, // Boolean - By default the slug input field is shown, set to false to hide the input field and show the span.
1010
override: false
1111
};
1212

1313
$this = jQuery(this);
1414

15+
var slugContainer = $this.closest('.box-body').find('[data-slug="target"]');
16+
1517
if (options) {
1618
jQuery.extend(settings, options);
1719
} else {
@@ -20,23 +22,13 @@ jQuery.fn.slug = function (options) {
2022
}
2123
}
2224

23-
jQuery(document).ready(function () {
24-
if (settings.hide) {
25-
$this.closest('input.' + settings.slug).after("<span class=" + settings.slug + "></span>");
26-
$this.closest('input.' + settings.slug).hide();
27-
}
28-
});
29-
3025
makeSlug = function (event) {
3126
var $theUnSlug = jQuery(event.target),
32-
$slugParent = $theUnSlug.closest('.form-group').next(),
3327
slugContent = $theUnSlug.val(),
3428
slugContentHyphens = slugContent.replace(/\s+/g, '-'),
3529
slugNoAccents = normalize(slugContentHyphens),
3630
finishedSlug = slugNoAccents.replace(/[^a-zA-Z0-9\-]/g, '');
37-
38-
$slugParent.find('input.' + settings.slug).val(finishedSlug.toLowerCase());
39-
$slugParent.find('span.' + settings.slug).text(finishedSlug.toLowerCase());
31+
slugContainer.val(finishedSlug.toLowerCase());
4032
};
4133

4234
normalize = function(string) {

0 commit comments

Comments
 (0)