[Pkg-javascript-commits] [jquery-slugify.js] 01/02: Imported Upstream version 1.2.3~dfsg1

Alexandre Viau aviau at moszumanska.debian.org
Tue Dec 29 23:30:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

aviau pushed a commit to branch master
in repository jquery-slugify.js.

commit 5abd4b400ef352dedc5b87d833ef546c6972167f
Author: aviau <alexandre at alexandreviau.net>
Date:   Tue Dec 29 18:19:05 2015 -0500

    Imported Upstream version 1.2.3~dfsg1
---
 .gitignore           |   5 ++
 .jshintrc            |  15 +++++
 .travis.yml          |   5 ++
 CONTRIBUTING.md      |  35 +++++++++++
 Gruntfile.js         | 104 ++++++++++++++++++++++++++++++++
 LICENSE-MIT          |  22 +++++++
 README.md            |  38 ++++++++++++
 bower.json           |  31 ++++++++++
 dist/slugify.js      |  66 ++++++++++++++++++++
 package.json         |  41 +++++++++++++
 src/.jshintrc        |  20 ++++++
 src/slugify.js       |  71 ++++++++++++++++++++++
 test/.jshintrc       |  32 ++++++++++
 test/slugify.html    |  31 ++++++++++
 test/slugify_test.js | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++
 15 files changed, 683 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..28be688
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+node_modules/
+nbproject/
+.idea
+bower_components
+.local
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..ea0135e
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,15 @@
+{
+  "curly": true,
+  "eqeqeq": true,
+  "immed": true,
+  "jquery": true,
+  "latedef": true,
+  "newcap": true,
+  "noarg": true,
+  "sub": true,
+  "undef": true,
+  "unused": true,
+  "boss": true,
+  "eqnull": true,
+  "node": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..6ef04eb
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+  - "0.10"
+before_script:
+  - npm install -g grunt-cli
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..4551be6
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,35 @@
+# Contributing
+
+## Important notes
+
+Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!
+
+### Code style
+
+Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.**
+
+### PhantomJS
+
+While Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.
+
+## Modifying the code
+
+First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
+
+Test that Grunt's CLI is installed by running `grunt --version`.  If the command isn't found, run `npm install -g grunt-cli`.  For more information about installing Grunt, see the [getting started guide](http://gruntjs.com/getting-started).
+
+1. Fork and clone the repo.
+1. Run `npm install` to install all dependencies (including Grunt).
+1. Run `grunt` to grunt this project.
+
+Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.
+
+## Submitting pull requests
+
+1. Create a new branch, please don't work in your `master` branch directly.
+1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
+1. Fix stuff.
+1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
+1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
+1. Update the documentation to reflect any changes.
+1. Push to your fork and submit a pull request.
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..a1940fe
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,104 @@
+'use strict';
+
+module.exports = function(grunt) {
+
+  // Project configuration.
+  grunt.initConfig({
+    // Metadata.
+    pkg: grunt.file.readJSON('package.json'),
+
+    banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
+      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
+      '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
+      '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
+      ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
+    // Task configuration.
+    clean: {
+      files: ['dist']
+    },
+    concat: {
+      options: {
+        banner: '<%= banner %>',
+        stripBanners: true
+      },
+      dist: {
+        src: ['src/<%= pkg.filename %>.js'],
+        dest: 'dist/<%= pkg.filename %>.js'
+      }
+    },
+    uglify: {
+      options: {
+        banner: '<%= banner %>'
+      },
+      dist: {
+        src: '<%= concat.dist.dest %>',
+        dest: 'dist/<%= pkg.filename %>.min.js'
+      }
+    },
+    qunit: {
+      all: {
+        options: {
+          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) {
+            return 'http://localhost:<%= connect.server.options.port %>/test/slugify.html?jquery=' + version;
+          })
+        }
+      }
+    },
+    jshint: {
+      gruntfile: {
+        options: {
+          jshintrc: '.jshintrc'
+        },
+        src: 'Gruntfile.js'
+      },
+      src: {
+        options: {
+          jshintrc: 'src/.jshintrc'
+        },
+        src: ['src/**/*.js']
+      },
+      test: {
+        options: {
+          jshintrc: 'test/.jshintrc'
+        },
+        src: ['test/**/*.js']
+      }
+    },
+    watch: {
+      gruntfile: {
+        files: '<%= jshint.gruntfile.src %>',
+        tasks: ['jshint:gruntfile']
+      },
+      src: {
+        files: '<%= jshint.src.src %>',
+        tasks: ['jshint:src', 'qunit']
+      },
+      test: {
+        files: '<%= jshint.test.src %>',
+        tasks: ['jshint:test', 'qunit']
+      }
+    },
+    connect: {
+      server: {
+        options: {
+          port: 4321,
+          hostname: 'localhost'
+        }
+      }
+    }
+  });
+
+  // These plugins provide necessary tasks.
+  grunt.loadNpmTasks('grunt-contrib-clean');
+  grunt.loadNpmTasks('grunt-contrib-concat');
+  grunt.loadNpmTasks('grunt-contrib-uglify');
+  grunt.loadNpmTasks('grunt-contrib-qunit');
+  grunt.loadNpmTasks('grunt-contrib-jshint');
+  grunt.loadNpmTasks('grunt-contrib-watch');
+  grunt.loadNpmTasks('grunt-contrib-connect');
+
+  // Default task.
+  grunt.registerTask('default', ['connect', 'jshint', 'qunit', 'clean', 'concat', 'uglify']);
+  // Test task
+  grunt.registerTask('test', ['connect', 'jshint', 'qunit']);
+};
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..96d805f
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) 2013-2016 Florian Reiss
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9a1ae9b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,38 @@
+[![Build Status](https://travis-ci.org/madflow/jquery-slugify.png?branch=master)](https://travis-ci.org/madflow/jquery-slugify)
+
+# jQuery Slugify
+
+Just another another (another) url slug creation plugin for jQuery.
+
+## Getting Started
+
+You can install the plugin using Bower:
+
+    bower install jquery-slugify
+
+You can download the [production version][min] or the [development version][max].
+
+[min]: https://raw.github.com/madflow/jquery-slugify/master/dist/slugify.min.js
+[max]: https://raw.github.com/madflow/jquery-slugify/master/dist/slugify.js
+
+The plugin depends on [speakingurl][speakingurl].
+
+[speakingurl]: https://github.com/pid/speakingurl
+
+In your web page:
+
+```html
+<script src="jquery.js"></script>
+<script src="speakingurl.min.js"></script>
+<script src="slugify.min.js"></script>
+
+<input type ="text" value="" id="slug-source" /> <!-- The text to be slugged -->
+<input type ="text" value="" id="slug-target" /> <!-- The processed text as slug -->
+
+<script>
+jQuery(function($) {
+  $.slugify("Ätschi Bätschi"); // "aetschi-baetschi"
+  $('#slug-target').slugify('#slug-source'); // Type as you slug
+});
+</script>
+```
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..970e95c
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,31 @@
+{
+  "name": "jquery-slugify",
+  "version": "1.2.3",
+  "homepage": "https://github.com/madflow/jquery-slugify",
+  "authors": [
+    "madflow"
+  ],
+  "description": "Just another another (another) url slug creation plugin for jQuery",
+  "main": "dist/slugify.js",
+  "keywords": [
+    "slugify",
+    "slugs",
+    "strings"
+  ],
+  "dependencies": {
+    "jquery": ">=1.7",
+    "speakingurl": "~7.0.0"
+  },
+  "license": "MIT",
+  "ignore": [
+    "**/.*",
+    "node_modules",
+    "bower_components",
+    "test",
+    "libs",
+    "Gruntfile.js",
+    "package.json",
+    "CONTRIBUTING.md",
+    "slugify.jquery.json"
+  ]
+}
diff --git a/dist/slugify.js b/dist/slugify.js
new file mode 100644
index 0000000..6965fae
--- /dev/null
+++ b/dist/slugify.js
@@ -0,0 +1,66 @@
+/*! jquery-slugify - v1.2.3 - 2015-12-23
+* Copyright (c) 2015 madflow; Licensed  */
+;(function($) {
+
+    $.fn.slugify = function(source, options) {
+
+        return this.each(function() {
+            var $target = $(this),
+                $source = $(source);
+
+            $target.on('keyup change', function() {
+                if ($target.val() !== '' && $target.val() !== undefined) {
+                    $target.data('locked', true);
+                } else {
+                    $target.data('locked', false);
+                }
+            });
+
+            $source.on('keyup change', function() {
+                if (true === $target.data('locked')) {
+                    return;
+                }
+                if ($target.is('input') || $target.is('textarea')) {
+                    $target.val($.slugify($source.val(), options));
+                } else {
+                    $target.text($.slugify($source.val(), options));
+                }
+            });
+        });
+    };
+
+    // Static method.
+    $.slugify = function(sourceString, options) {
+
+        // Override default options with passed-in options.
+        options = $.extend({}, $.slugify.options, options);
+
+        // Guess language specifics from html.lang attribute
+        // when options.lang is not defined
+        options.lang = options.lang || $('html').prop('lang');
+
+        // Apply preSlug function - if exists
+        if (typeof options.preSlug === 'function') {
+            sourceString = options.preSlug(sourceString);
+        }
+
+        sourceString = options.slugFunc(sourceString, options);
+
+        // Apply postSlug function - if exists
+        if (typeof options.postSlug === 'function') {
+            sourceString = options.postSlug(sourceString);
+        }
+
+        return sourceString;
+    };
+
+    // Default plugin options
+    $.slugify.options = {
+        preSlug: null,
+        postSlug: null,
+        slugFunc: function(input, opts) {
+            return window.getSlug(input, opts);
+        }
+    };
+
+}(jQuery));
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..03ae64d
--- /dev/null
+++ b/package.json
@@ -0,0 +1,41 @@
+{
+  "name": "jquery-slugify",
+  "filename": "slugify",
+  "description": "Just another another (another) url slug plugin for jQuery",
+  "version": "1.2.3",
+  "main": "dist/slugify.min.js",
+  "author": {
+    "name": "madflow",
+    "url": "https://github.com/madflow/jquery-slugify"
+  },
+  "scripts": {
+    "test": "grunt test"
+  },
+  "keywords": [
+    "javascript",
+    "jquery",
+    "slugs",
+    "slug",
+    "strings",
+    "jquery-plugin"
+  ],
+  "license": "MIT",
+  "repository": {
+    "type": "git",
+    "url": "git at github.com:madflow/jquery-slugify.git"
+  },
+  "devDependencies": {
+    "connect": "~2.27.1",
+    "grunt": "~0.4.5",
+    "grunt-contrib-clean": "~0.6.0",
+    "grunt-contrib-concat": "~0.5.1",
+    "grunt-contrib-connect": "~0.11.1",
+    "grunt-contrib-jshint": "~0.11.0",
+    "grunt-contrib-qunit": "~0.7.0",
+    "grunt-contrib-uglify": "~0.9.1",
+    "grunt-contrib-watch": "~0.6.1"
+  },
+  "dependencies": {
+    "speakingurl": "^7.0.0"
+  }
+}
diff --git a/src/.jshintrc b/src/.jshintrc
new file mode 100644
index 0000000..8eafb24
--- /dev/null
+++ b/src/.jshintrc
@@ -0,0 +1,20 @@
+{
+    "curly": true,
+    "eqeqeq": true,
+    "immed": true,
+    "latedef": true,
+    "newcap": true,
+    "noarg": true,
+    "sub": true,
+    "undef": true,
+    "unused": true,
+    "boss": true,
+    "eqnull": true,
+    "browser": true,
+    "predef": ["jQuery"],
+    "globals": {
+        "module": true,
+        "require": true,
+        "console": true
+    }
+}
diff --git a/src/slugify.js b/src/slugify.js
new file mode 100644
index 0000000..fd2eb76
--- /dev/null
+++ b/src/slugify.js
@@ -0,0 +1,71 @@
+/*
+ * https://github.com/madflow/jquery-slugify
+ *
+ * Copyright (c) 2015 Florian Reiss
+ * Licensed under the MIT license.
+ */
+
+;(function($) {
+
+    $.fn.slugify = function(source, options) {
+
+        return this.each(function() {
+            var $target = $(this),
+                $source = $(source);
+
+            $target.on('keyup change', function() {
+                if ($target.val() !== '' && $target.val() !== undefined) {
+                    $target.data('locked', true);
+                } else {
+                    $target.data('locked', false);
+                }
+            });
+
+            $source.on('keyup change', function() {
+                if (true === $target.data('locked')) {
+                    return;
+                }
+                if ($target.is('input') || $target.is('textarea')) {
+                    $target.val($.slugify($source.val(), options));
+                } else {
+                    $target.text($.slugify($source.val(), options));
+                }
+            });
+        });
+    };
+
+    // Static method.
+    $.slugify = function(sourceString, options) {
+
+        // Override default options with passed-in options.
+        options = $.extend({}, $.slugify.options, options);
+
+        // Guess language specifics from html.lang attribute
+        // when options.lang is not defined
+        options.lang = options.lang || $('html').prop('lang');
+
+        // Apply preSlug function - if exists
+        if (typeof options.preSlug === 'function') {
+            sourceString = options.preSlug(sourceString);
+        }
+
+        sourceString = options.slugFunc(sourceString, options);
+
+        // Apply postSlug function - if exists
+        if (typeof options.postSlug === 'function') {
+            sourceString = options.postSlug(sourceString);
+        }
+
+        return sourceString;
+    };
+
+    // Default plugin options
+    $.slugify.options = {
+        preSlug: null,
+        postSlug: null,
+        slugFunc: function(input, opts) {
+            return window.getSlug(input, opts);
+        }
+    };
+
+}(jQuery));
\ No newline at end of file
diff --git a/test/.jshintrc b/test/.jshintrc
new file mode 100644
index 0000000..2de0248
--- /dev/null
+++ b/test/.jshintrc
@@ -0,0 +1,32 @@
+{
+  "curly": true,
+  "eqeqeq": true,
+  "immed": true,
+  "latedef": true,
+  "newcap": true,
+  "noarg": true,
+  "sub": true,
+  "undef": true,
+  "unused": true,
+  "boss": true,
+  "eqnull": true,
+  "browser": true,
+  "predef": [
+    "jQuery",
+    "QUnit",
+    "module",
+    "test",
+    "asyncTest",
+    "expect",
+    "start",
+    "stop",
+    "ok",
+    "equal",
+    "notEqual",
+    "deepEqual",
+    "notDeepEqual",
+    "strictEqual",
+    "notStrictEqual",
+    "throws"
+  ]
+}
\ No newline at end of file
diff --git a/test/slugify.html b/test/slugify.html
new file mode 100644
index 0000000..651c807
--- /dev/null
+++ b/test/slugify.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Slugify Test Suite</title>
+        <!-- Load local jQuery. This can be overridden with a ?jquery=___ param. -->
+        <script src="../libs/jquery-loader.js"></script>
+        <!-- Load local QUnit. -->
+        <link rel="stylesheet" href="../libs/qunit/qunit.css" media="screen">
+        <script src="../libs/qunit/qunit.js"></script>
+        <!-- Load local lib and tests. -->
+        <script src="../node_modules/speakingurl/speakingurl.min.js"></script>
+        <script src="../src/slugify.js"></script>
+        <script src="slugify_test.js"></script>
+        <!-- Removing access to jQuery and $. But it'll still be available as _$, if
+             you REALLY want to mess around with jQuery in the console. REMEMBER WE
+             ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY. -->
+        <script>window._$ = jQuery.noConflict(true);</script>
+    </head>
+    <body>
+        <div>
+            <input type ="text" value="" id="slug-source"/>
+        </div>
+        <div>
+            <input type ="text" value="" id="slug-target"/>
+        </div>
+        <div>
+            <span id="slug-target-span"></span>
+        </div>
+    </body>
+</html>
diff --git a/test/slugify_test.js b/test/slugify_test.js
new file mode 100644
index 0000000..62e2a2d
--- /dev/null
+++ b/test/slugify_test.js
@@ -0,0 +1,167 @@
+(function($) {
+    /*
+     ======== A Handy Little QUnit Reference ========
+     http://api.qunitjs.com/
+
+     Test methods:
+     module(name, {[setup][ ,teardown]})
+     test(name, callback)
+     expect(numberOfAssertions)
+     stop(increment)
+     start(decrement)
+     Test assertions:
+     ok(value, [message])
+     equal(actual, expected, [message])
+     notEqual(actual, expected, [message])
+     deepEqual(actual, expected, [message])
+     notDeepEqual(actual, expected, [message])
+     strictEqual(actual, expected, [message])
+     notStrictEqual(actual, expected, [message])
+     throws(block, [expected], [message])
+     */
+
+    module('jQuery#slugify', {
+        setup: function() {
+
+        }
+    });
+
+    test("chainable", function() {
+        ok($("body").slugify().addClass("testing"), "can be chained");
+        equal($("body").hasClass("testing"), true, "class was added correctly from chaining");
+    });
+
+    test('test the static slugify method', function() {
+        expect(3);
+        strictEqual($.slugify('Hello    good      Sir!   '), 'hello-good-sir', 'Simple Slug');
+        strictEqual($.slugify('Ätschi Bätschi'), 'aetschi-baetschi', 'German Slug');
+        strictEqual($.slugify('äãàáâẽèéëêìíïîöõòóôüùúûñçß'), 'aeaaaaeeeeeiiiioeooooueuuuncss', 'Special Slug');
+    });
+
+    test('test the static slugify method with options', function() {
+        expect(2);
+        var options = {
+            'separator': '_'
+        };
+        strictEqual($.slugify('!Hello    good      Sir!   ', options), 'hello_good_sir', 'Custom options');
+
+        options = {
+            'separator': '+'
+        };
+        strictEqual($.slugify('!Hello!    good      !Sir!   ', options), 'hello+good+sir', 'Custom options 2');
+    });
+
+    test('test the DOM function on change', function() {
+        expect(1);
+        $('#slug-target').slugify('#slug-source');
+        $('#slug-source').val('Hello    good      Sir!   ').trigger('change');
+        equal($('#slug-target').val(), 'hello-good-sir', "Correct slug in target field change event");
+    });
+
+    test('test the DOM function on keyup', function() {
+        expect(1);
+        $('#slug-target').slugify('#slug-source');
+        $('#slug-source').val('Hello    good      Sir!   ').trigger('keyup');
+        equal($('#slug-target').val(), 'hello-good-sir', "Correct slug in target field with keyup event");
+    });
+
+    test('invalid event triggers nothing', function() {
+        expect(1);
+        $('#slug-target').slugify('#slug-source');
+        $('#slug-source').val('A').trigger('click');
+        equal($('#slug-target').val(), '', "Invalid event (click)");
+    });
+
+    test('when a the slug field is edited - the data attributed "locked should be added"', function() {
+        expect(2);
+        $('#slug-target').slugify('#slug-source');
+        $('#slug-source').val('a').trigger('keyup');
+        equal($('#slug-target').val(), 'a', "Slug added correctly");
+        $('#slug-target').val('ab').trigger('change');
+        ok($('#slug-target').data('locked'), '"locked" is in data object');
+    });
+
+    test('the slug field is a span', function() {
+        expect(2);
+        $('#slug-target-span').slugify('#slug-source');
+        $('#slug-source').val('Hello Span!').trigger('keyup');
+        equal($('#slug-target-span').text(), 'hello-span', "Slug added to span correctly");
+        $('#slug-source').val('Hello Spanner!').trigger('change');
+        equal($('#slug-target-span').text(), 'hello-spanner', "Slug added to span correctly again");
+    });
+
+    test('test russian Ъ', function() {
+        expect(1);
+        var options = {
+            'separator': '-'
+        };
+        strictEqual($.slugify('объезд', options), 'obezd', 'test russian Ъ');
+    });
+
+    test('test dollar sign', function() {
+        expect(1);
+        var options = {
+            'separator': '_'
+        };
+        strictEqual($.slugify('Micro$soft please go suck an egg', options), 'microusdsoft_please_go_suck_an_egg', 'test $ sign');
+    });
+
+    test('test consecutive invalid and whitespace chars', function() {
+        expect(5);
+        var options = {
+            'separator': '-'
+        };
+        strictEqual($.slugify('  a  ', options), 'a', 'Whitespace chars trimmed');
+        strictEqual($.slugify('a   a  a', options), 'a-a-a', 'Consecutive whitespacechars deleted');
+        strictEqual($.slugify('=a=a=', options), 'a-a', 'Trailing invalid characters deleted');
+        strictEqual($.slugify('===a=====a==', options), 'a-a', 'Consecutive invalid characters deleted');
+        strictEqual($.slugify('===a== ===a==', options), 'a-a', 'Consecutive invalid characters deleted - whitespace reserved');
+    });
+
+    test('test the preSlug postSlug callbacks', function() {
+
+        expect(2);
+
+        strictEqual($.slugify('a', {
+            postSlug: function(sourceString) {
+                return sourceString.toUpperCase();
+            }
+        }), 'A', 'Uppercase postSlug');
+
+        strictEqual($.slugify('a', {
+            postSlug: function(sourceString) {
+                return sourceString + 'rsch';
+            }
+        }), 'arsch', 'Naughty word appendend preSlug');
+    });
+
+    test('test the static lang feature', function() {
+
+        expect(3);
+        strictEqual($.slugify('mäh', {'lang':'hu'}), 'mah',
+            'Hungarian specific lang option');
+        strictEqual($.slugify('mäh', {'lang':'de'}), 'maeh',
+            'German specific lang option');
+        strictEqual($.slugify('mäh'), 'maeh',
+            'Default lang option');
+    });
+
+    test('test the lang feature with HTML lang attribute', function() {
+        expect(3);
+        $('html').prop('lang', 'hu');
+        strictEqual($.slugify('mäh'), 'mah',
+            'Hungarian specific lang with lang attribute');
+        $('html').prop('lang', 'de');
+        strictEqual($.slugify('mäh'), 'maeh',
+            'German specific lang option');
+        $('html').prop('lang', 'hu');
+        strictEqual($.slugify('mäh', {'lang':'de'}), 'maeh',
+            'German specific lang option overrides html attribute');
+    });
+
+    QUnit.testDone(function() {
+        $('#slug-target').val('');
+        $('#slug-source').val('');
+    });
+
+}(jQuery));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/jquery-slugify.js.git



More information about the Pkg-javascript-commits mailing list