Codebase list jquery-slugify.js / bdd0054
Updated version 1.2.5~dfsg1 from 'upstream/1.2.5_dfsg1' with Debian dir c72cd689de218abb5ebac9a474e9c8cd2ab6ba3f aviau 6 years ago
7 changed file(s) with 160 addition(s) and 114 deletion(s). Raw diff Collapse all Expand all
00 'use strict';
11
22 module.exports = function(grunt) {
3 // Project configuration.
4 grunt.initConfig({
5 // Metadata.
6 pkg: grunt.file.readJSON('package.json'),
37
4 // Project configuration.
5 grunt.initConfig({
6 // Metadata.
7 pkg: grunt.file.readJSON('package.json'),
8 banner:
9 '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
10 '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
11 '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
12 '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
13 ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
14 // Task configuration.
15 clean: {
16 files: ['dist']
17 },
18 concat: {
19 options: {
20 banner: '<%= banner %>',
21 stripBanners: true
22 },
23 dist: {
24 src: ['src/<%= pkg.filename %>.js'],
25 dest: 'dist/<%= pkg.filename %>.js'
26 }
27 },
28 uglify: {
29 options: {
30 banner: '<%= banner %>'
31 },
32 dist: {
33 src: '<%= concat.dist.dest %>',
34 dest: 'dist/<%= pkg.filename %>.min.js'
35 }
36 },
37 qunit: {
38 all: {
39 options: {
40 urls: [
41 '1.7.2',
42 '1.8.3',
43 '1.9.1',
44 '1.10.2',
45 '1.11.2',
46 '2.0.3',
47 '2.1.3',
48 '3.0.0',
49 '3.1.0',
50 '3.2.1'
51 ].map(function(version) {
52 return (
53 'http://localhost:<%= connect.server.options.port %>/test/slugify.html?jquery=' +
54 version
55 );
56 })
57 }
58 }
59 },
60 jshint: {
61 gruntfile: {
62 options: {
63 jshintrc: '.jshintrc'
64 },
65 src: 'Gruntfile.js'
66 },
67 src: {
68 options: {
69 jshintrc: 'src/.jshintrc'
70 },
71 src: ['src/**/*.js']
72 },
73 test: {
74 options: {
75 jshintrc: 'test/.jshintrc'
76 },
77 src: ['test/**/*.js']
78 }
79 },
80 watch: {
81 gruntfile: {
82 files: '<%= jshint.gruntfile.src %>',
83 tasks: ['jshint:gruntfile']
84 },
85 src: {
86 files: '<%= jshint.src.src %>',
87 tasks: ['jshint:src', 'qunit']
88 },
89 test: {
90 files: '<%= jshint.test.src %>',
91 tasks: ['jshint:test', 'qunit']
92 }
93 },
94 connect: {
95 server: {
96 options: {
97 port: 4321,
98 hostname: 'localhost'
99 }
100 }
101 }
102 });
8103
9 banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
10 '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
11 '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
12 '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
13 ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
14 // Task configuration.
15 clean: {
16 files: ['dist']
17 },
18 concat: {
19 options: {
20 banner: '<%= banner %>',
21 stripBanners: true
22 },
23 dist: {
24 src: ['src/<%= pkg.filename %>.js'],
25 dest: 'dist/<%= pkg.filename %>.js'
26 }
27 },
28 uglify: {
29 options: {
30 banner: '<%= banner %>'
31 },
32 dist: {
33 src: '<%= concat.dist.dest %>',
34 dest: 'dist/<%= pkg.filename %>.min.js'
35 }
36 },
37 qunit: {
38 all: {
39 options: {
40 urls: ['1.7.2','1.8.3','1.9.1','1.10.2','1.11.2','2.0.3', '2.1.3'].map(function(version) {
41 return 'http://localhost:<%= connect.server.options.port %>/test/slugify.html?jquery=' + version;
42 })
43 }
44 }
45 },
46 jshint: {
47 gruntfile: {
48 options: {
49 jshintrc: '.jshintrc'
50 },
51 src: 'Gruntfile.js'
52 },
53 src: {
54 options: {
55 jshintrc: 'src/.jshintrc'
56 },
57 src: ['src/**/*.js']
58 },
59 test: {
60 options: {
61 jshintrc: 'test/.jshintrc'
62 },
63 src: ['test/**/*.js']
64 }
65 },
66 watch: {
67 gruntfile: {
68 files: '<%= jshint.gruntfile.src %>',
69 tasks: ['jshint:gruntfile']
70 },
71 src: {
72 files: '<%= jshint.src.src %>',
73 tasks: ['jshint:src', 'qunit']
74 },
75 test: {
76 files: '<%= jshint.test.src %>',
77 tasks: ['jshint:test', 'qunit']
78 }
79 },
80 connect: {
81 server: {
82 options: {
83 port: 4321,
84 hostname: 'localhost'
85 }
86 }
87 }
88 });
104 // These plugins provide necessary tasks.
105 grunt.loadNpmTasks('grunt-contrib-clean');
106 grunt.loadNpmTasks('grunt-contrib-concat');
107 grunt.loadNpmTasks('grunt-contrib-uglify');
108 grunt.loadNpmTasks('grunt-contrib-qunit');
109 grunt.loadNpmTasks('grunt-contrib-jshint');
110 grunt.loadNpmTasks('grunt-contrib-watch');
111 grunt.loadNpmTasks('grunt-contrib-connect');
89112
90 // These plugins provide necessary tasks.
91 grunt.loadNpmTasks('grunt-contrib-clean');
92 grunt.loadNpmTasks('grunt-contrib-concat');
93 grunt.loadNpmTasks('grunt-contrib-uglify');
94 grunt.loadNpmTasks('grunt-contrib-qunit');
95 grunt.loadNpmTasks('grunt-contrib-jshint');
96 grunt.loadNpmTasks('grunt-contrib-watch');
97 grunt.loadNpmTasks('grunt-contrib-connect');
98
99 // Default task.
100 grunt.registerTask('default', ['connect', 'jshint', 'qunit', 'clean', 'concat', 'uglify']);
101 // Test task
102 grunt.registerTask('test', ['connect', 'jshint', 'qunit']);
113 // Default task.
114 grunt.registerTask('default', [
115 'connect',
116 'jshint',
117 'qunit',
118 'clean',
119 'concat',
120 'uglify'
121 ]);
122 // Test task
123 grunt.registerTask('test', ['connect', 'jshint', 'qunit']);
103124 };
0 Copyright (c) 2013-2016 Florian Reiss
0 Copyright (c) 2013-2017 Florian Reiss
11
22 Permission is hereby granted, free of charge, to any person
33 obtaining a copy of this software and associated documentation
3232 jQuery(function($) {
3333 $.slugify("Ätschi Bätschi"); // "aetschi-baetschi"
3434 $('#slug-target').slugify('#slug-source'); // Type as you slug
35
36 $("#slug-target").slugify("#slug-source", {
37 separator: '_' // If you want to change separator from hyphen (-) to underscore (_).
38 });
3539 });
3640 </script>
3741 ```
0 /*! jquery-slugify - v1.2.4 - 2016-06-15
1 * Copyright (c) 2016 madflow; Licensed */
2 ;(function($) {
3
0 /*! jquery-slugify - v1.2.5 - 2017-10-06
1 * Copyright (c) 2017 madflow; Licensed */
2 (function($) {
43 $.fn.slugify = function(source, options) {
5
64 return this.each(function() {
75 var $target = $(this),
86 $source = $(source);
1614 });
1715
1816 $source.on('keyup change', function() {
17 // If the target is empty - it cannot be locked
18 if ($target.val() === '' || $target.val() === undefined) {
19 $target.data('locked', false);
20 }
21
1922 if (true === $target.data('locked')) {
2023 return;
2124 }
3033
3134 // Static method.
3235 $.slugify = function(sourceString, options) {
33
3436 // Override default options with passed-in options.
3537 options = $.extend({}, $.slugify.options, options);
3638
6163 return window.getSlug(input, opts);
6264 }
6365 };
64
65 }(jQuery));
66 })(jQuery);
11 "name": "jquery-slugify",
22 "filename": "slugify",
33 "description": "Just another another (another) url slug plugin for jQuery",
4 "version": "1.2.4",
4 "version": "1.2.5",
55 "main": "dist/slugify.min.js",
66 "author": {
77 "name": "madflow",
00 /*
11 * https://github.com/madflow/jquery-slugify
22 *
3 * Copyright (c) 2015 Florian Reiss
3 * Copyright (c) 2015-2017 Florian Reiss
44 * Licensed under the MIT license.
55 */
66
7 ;(function($) {
8
7 (function($) {
98 $.fn.slugify = function(source, options) {
10
119 return this.each(function() {
1210 var $target = $(this),
1311 $source = $(source);
2119 });
2220
2321 $source.on('keyup change', function() {
22 // If the target is empty - it cannot be locked
23 if ($target.val() === '' || $target.val() === undefined) {
24 $target.data('locked', false);
25 }
26
2427 if (true === $target.data('locked')) {
2528 return;
2629 }
3538
3639 // Static method.
3740 $.slugify = function(sourceString, options) {
38
3941 // Override default options with passed-in options.
4042 options = $.extend({}, $.slugify.options, options);
4143
6668 return window.getSlug(input, opts);
6769 }
6870 };
69
70 }(jQuery));
71 })(jQuery);
158158 'German specific lang option overrides html attribute');
159159 });
160160
161 // https://github.com/madflow/jquery-slugify/issues/15
162 test('test locked target should be released', function() {
163
164 $('body').prepend('<input type="text" id="slug-source-locked">');
165 $('body').prepend('<input type="text" id="slug-target-locked">');
166 $('#slug-target-locked').slugify('#slug-source-locked');
167 $('#slug-source-locked').val('Hello good Sir! ').trigger('change');
168 equal($('#slug-target-locked').val(), 'hello-good-sir', "Correct slug in target field change event");
169
170 $('#slug-target-locked').val('changed').trigger('change');
171 $('#slug-source-locked').val('');
172 $('#slug-target-locked').val('');
173
174 $('#slug-source-locked').val('Hello good Sir! ').trigger('change');
175 equal($('#slug-target-locked').val(), 'hello-good-sir', "Correct slug in target field change event");
176
177
178 });
179
161180 QUnit.testDone(function() {
162181 $('#slug-target').val('');
163182 $('#slug-source').val('');