jquery-slugify-1.2.3/000077500000000000000000000000001263645756600145405ustar00rootroot00000000000000jquery-slugify-1.2.3/.gitignore000066400000000000000000000000671263645756600165330ustar00rootroot00000000000000node_modules/ nbproject/ .idea bower_components .local jquery-slugify-1.2.3/.jshintrc000066400000000000000000000003431263645756600163650ustar00rootroot00000000000000{ "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 } jquery-slugify-1.2.3/.travis.yml000066400000000000000000000001221263645756600166440ustar00rootroot00000000000000language: node_js node_js: - "0.10" before_script: - npm install -g grunt-cli jquery-slugify-1.2.3/CONTRIBUTING.md000066400000000000000000000032121263645756600167670ustar00rootroot00000000000000# 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. jquery-slugify-1.2.3/Gruntfile.js000066400000000000000000000051771263645756600170470ustar00rootroot00000000000000'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']); }; jquery-slugify-1.2.3/LICENSE-MIT000066400000000000000000000020461263645756600161760ustar00rootroot00000000000000Copyright (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. jquery-slugify-1.2.3/README.md000066400000000000000000000021541263645756600160210ustar00rootroot00000000000000[![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 ``` jquery-slugify-1.2.3/bower.json000066400000000000000000000011421263645756600165470ustar00rootroot00000000000000{ "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" ] } jquery-slugify-1.2.3/dist/000077500000000000000000000000001263645756600155035ustar00rootroot00000000000000jquery-slugify-1.2.3/dist/slugify.js000066400000000000000000000037341263645756600175320ustar00rootroot00000000000000/*! 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));jquery-slugify-1.2.3/package.json000066400000000000000000000016741263645756600170360ustar00rootroot00000000000000{ "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@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" } } jquery-slugify-1.2.3/src/000077500000000000000000000000001263645756600153275ustar00rootroot00000000000000jquery-slugify-1.2.3/src/.jshintrc000066400000000000000000000005471263645756600171620ustar00rootroot00000000000000{ "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 } } jquery-slugify-1.2.3/src/slugify.js000066400000000000000000000040071263645756600173500ustar00rootroot00000000000000/* * 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));jquery-slugify-1.2.3/test/000077500000000000000000000000001263645756600155175ustar00rootroot00000000000000jquery-slugify-1.2.3/test/.jshintrc000066400000000000000000000007251263645756600173500ustar00rootroot00000000000000{ "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" ] }jquery-slugify-1.2.3/test/slugify.html000066400000000000000000000023441263645756600200720ustar00rootroot00000000000000 Slugify Test Suite
jquery-slugify-1.2.3/test/slugify_test.js000066400000000000000000000141451263645756600206030ustar00rootroot00000000000000(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));