From bcef83a45c25901a6bfe8c87c72d382cdb43d090 Mon Sep 17 00:00:00 2001 From: vsn4ik Date: Mon, 24 Feb 2020 21:03:15 +0300 Subject: [PATCH] Bump v1.0.0 --- .gitignore | 1 + CONTRIBUTING.md | 4 +- README.md | 44 +-- dist/css/bootstrap-spinner.min.css.map | 1 - dist/js/jquery.spinner.js | 253 ------------------ docs/dist/css/bootstrap-spinner.css | 60 ----- docs/dist/css/bootstrap-spinner.min.css | 2 - docs/dist/css/bootstrap-spinner.min.css.map | 1 - .../dist/input-spinner.css | 0 .../jquery.spinner.js => input-spinner.js} | 4 +- .../dist/input-spinner.min.css | 2 +- docs/dist/input-spinner.min.css.map | 1 + .../dist/input-spinner.min.js | 0 docs/dist/js/jquery.spinner.min.js | 1 - docs/example.html | 18 +- docs/index.html | 55 ++-- js/tests/index.html | 19 -- package.json | 33 ++- js/jquery.spinner.js => src/input-spinner.js | 4 +- .../input-spinner.less | 0 tests/index.html | 19 ++ {js/tests => tests}/karma.conf.js | 6 +- {js/tests => tests}/unit/unit.js | 0 23 files changed, 105 insertions(+), 423 deletions(-) delete mode 100644 dist/css/bootstrap-spinner.min.css.map delete mode 100644 dist/js/jquery.spinner.js delete mode 100644 docs/dist/css/bootstrap-spinner.css delete mode 100644 docs/dist/css/bootstrap-spinner.min.css delete mode 100644 docs/dist/css/bootstrap-spinner.min.css.map rename dist/css/bootstrap-spinner.css => docs/dist/input-spinner.css (100%) rename docs/dist/{js/jquery.spinner.js => input-spinner.js} (99%) rename dist/css/bootstrap-spinner.min.css => docs/dist/input-spinner.min.css (97%) create mode 100644 docs/dist/input-spinner.min.css.map rename dist/js/jquery.spinner.min.js => docs/dist/input-spinner.min.js (100%) delete mode 100644 docs/dist/js/jquery.spinner.min.js delete mode 100644 js/tests/index.html rename js/jquery.spinner.js => src/input-spinner.js (99%) rename less/bootstrap-spinner.less => src/input-spinner.less (100%) create mode 100644 tests/index.html rename {js/tests => tests}/karma.conf.js (90%) rename {js/tests => tests}/unit/unit.js (100%) diff --git a/.gitignore b/.gitignore index a39e992..18a531b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules/ +/dist/ /*-dist.zip diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8d5a225..2c488ab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # 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 `less` and `js` subdirectories! +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.** @@ -20,6 +20,6 @@ First, ensure that you have the latest [Node.js](https://nodejs.org) and [npm](h 1. Add failing tests for the change you want to make. Run `npm run test` to see the tests fail. 1. Fix stuff. 1. Run `npm run test` to see if the tests pass. Repeat steps 2-4 until done. -1. Open `js/tests/index.html` unit test file(s) in actual browser to ensure tests pass everywhere. +1. Open `tests/index.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/README.md b/README.md index d3235a6..61bcd39 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# [jQuery Spinner](https://vsn4ik.github.io/jquery.spinner/) +# [Input Spinner](https://vsn4ik.github.io/input-spinner/) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) -[![Build Status](https://github.com/vsn4ik/jquery.spinner/workflows/Test/badge.svg)](https://github.com/vsn4ik/jquery.spinner/actions?workflow=Test) -[![devDependency Status](https://david-dm.org/vsn4ik/jquery.spinner/dev-status.svg)](https://david-dm.org/vsn4ik/jquery.spinner?type=dev) +[![Build Status](https://github.com/vsn4ik/input-spinner/workflows/Test/badge.svg)](https://github.com/vsn4ik/input-spinner/actions?workflow=Test) +[![devDependency Status](https://david-dm.org/vsn4ik/input-spinner/dev-status.svg)](https://david-dm.org/vsn4ik/input-spinner?type=dev) -A Number-Spinner based-on jQuery, Support Keyboard operations and continuous changing. +A Number-Spinner, Support keyboard operations and continuous changing. ## Basic usage, it's very simple ```html - +
@@ -27,16 +27,16 @@ In your web page: ```html - +
@@ -89,10 +89,10 @@ Usage: ## Examples -### Work with Bootstrap 3 and Font Awesome 4 +### Work with Bootstrap and Font Awesome ```html - +
@@ -125,7 +125,7 @@ Usage:
@@ -134,7 +134,7 @@ Usage: #### pass step options as a function ```javascript // To skip 0 -$("#spinner").spinner({ +$('#spinner').spinner({ step: function(dir) { // 'this' references to the spinner object if ((this.oldValue === 1 && dir === 'down') || (this.oldValue === -1 && dir === 'up')) { @@ -145,7 +145,7 @@ $("#spinner").spinner({ }); // or use API syntax -$("#spinner").spinner('step', function(dir) { +$('#spinner').spinner('step', function(dir) { // your logic here }); ``` @@ -158,6 +158,6 @@ Copyright xixilive, 2013–2015 Licensed under [the MIT License][license]. -[license]: https://github.com/vsn4ik/jquery.spinner/blob/master/LICENSE -[development]: https://raw.githubusercontent.com/vsn4ik/jquery.spinner/master/dist/js/jquery.spinner.min.js -[production]: https://raw.githubusercontent.com/vsn4ik/jquery.spinner/master/dist/js/jquery.spinner.js +[license]: https://github.com/vsn4ik/input-spinner/blob/master/LICENSE +[development]: https://raw.githubusercontent.com/vsn4ik/input-spinner/master/dist/input-spinner.min.js +[production]: https://raw.githubusercontent.com/vsn4ik/input-spinner/master/dist/input-spinner.js diff --git a/dist/css/bootstrap-spinner.min.css.map b/dist/css/bootstrap-spinner.min.css.map deleted file mode 100644 index 4083f47..0000000 --- a/dist/css/bootstrap-spinner.min.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["dist/css/bootstrap-spinner.css"],"names":[],"mappings":"AACA,mDADA,iDAEE,OAAQ,KACR,MAAO,KACP,SAAU,OACV,QAAS,MACT,WAAY,OACZ,MAAO,KAGT,yDADA,uDAEE,MAAO,KAGT,wDADA,sDAEE,WAAY,KACZ,eAAgB,OAGlB,8DADA,4DAEE,UAAW,KACX,IAAK,KAGP,oDADA,kDAEE,gBAAiB,KAGnB,yDADA,uDAEE,WAAY,IACZ,OAAQ,KACR,QAAS,EAGX,kEADA,gEAEE,OAAQ,IAGV,uEADA,qEAEE,WAAY,MAGd,6EADA,2EAEE,UAAW,IACX,IAAK,KAGP,kEADA,gEAEE,OAAQ,KACR,MAAO,KAGT,uEADA,qEAEE,WAAY,MAGd,6EADA,2EAEE,UAAW,KACX,IAAK","sourcesContent":[".spinner.input-group .input-group-addon .spin-up,\n.spinner.input-group .input-group-addon .spin-down {\n height: 10px;\n width: 10px;\n overflow: hidden;\n display: block;\n text-align: center;\n color: #999;\n}\n.spinner.input-group .input-group-addon .spin-up:hover,\n.spinner.input-group .input-group-addon .spin-down:hover {\n color: #555;\n}\n.spinner.input-group .input-group-addon .spin-up .fas,\n.spinner.input-group .input-group-addon .spin-down .fas {\n margin-top: -6px;\n vertical-align: middle;\n}\n.spinner.input-group .input-group-addon .spin-up .glyphicon,\n.spinner.input-group .input-group-addon .spin-down .glyphicon {\n font-size: 10px;\n top: -2px;\n}\n.spinner.input-group .input-group-addon a.spin-up,\n.spinner.input-group .input-group-addon a.spin-down {\n text-decoration: none;\n}\n.spinner.input-group .input-group-addon button.spin-up,\n.spinner.input-group .input-group-addon button.spin-down {\n background: none;\n border: none;\n padding: 0;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down {\n height: 8px;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up .fas,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down .fas {\n margin-top: -10px;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up .glyphicon,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down .glyphicon {\n font-size: 8px;\n top: -5px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down {\n height: 12px;\n width: 12px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up .fas,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down .fas {\n margin-top: -16px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up .glyphicon,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down .glyphicon {\n font-size: 12px;\n top: -6px;\n}\n"]} \ No newline at end of file diff --git a/dist/js/jquery.spinner.js b/dist/js/jquery.spinner.js deleted file mode 100644 index 4efd312..0000000 --- a/dist/js/jquery.spinner.js +++ /dev/null @@ -1,253 +0,0 @@ -/* - * jquery.spinner - * https://github.com/vsn4ik/jquery.spinner - * Copyright Vasilii A., 2015–2018 - * Copyright xixilive, 2013–2015 - * Licensed under the MIT license - */ - -'use strict'; - -(function(factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module - define(['jquery'], factory); - } else if (typeof exports === 'object') { - // Node/CommonJS - module.exports = factory(require('jquery')); - } else { - // Browser globals - factory(jQuery); - } -})(function($) { - var Spinner; - var Spinning = function($element, options) { - this.$el = $element; - this.options = $.extend({}, Spinning.rules.defaults, Spinning.rules[options.rule] || {}, options); - this.min = Number(this.options.min) || 0; - this.max = Number(this.options.max) || 0; - this.spinningTimer = null; - - this.$el.on({ - 'focus.spinner': $.proxy(function(e) { - e.preventDefault(); - $(document).trigger('mouseup.spinner'); - this.oldValue = this.value(); - }, this), - 'change.spinner': $.proxy(function(e) { - e.preventDefault(); - this.value(this.$el.val()); - }, this), - 'keydown.spinner': $.proxy(function(e) { - var dir = { - 38: 'up', - 40: 'down' - }[e.which]; - - if (dir) { - e.preventDefault(); - this.spin(dir); - } - }, this) - }); - - //init input value - this.oldValue = this.value(); - this.value(this.$el.val()); - return this; - }; - - Spinning.rules = { - defaults: { min: null, max: null, step: 1, precision: 0 }, - currency: { min: 0.00, max: null, step: 0.01, precision: 2 }, - quantity: { min: 1, max: 999, step: 1, precision: 0 }, - percent: { min: 1, max: 100, step: 1, precision: 0 }, - month: { min: 1, max: 12, step: 1, precision: 0 }, - day: { min: 1, max: 31, step: 1, precision: 0 }, - hour: { min: 0, max: 23, step: 1, precision: 0 }, - minute: { min: 1, max: 59, step: 1, precision: 0 }, - second: { min: 1, max: 59, step: 1, precision: 0 } - }; - - Spinning.prototype = { - spin: function(dir) { - if (this.$el.prop('disabled')) { - return; - } - - this.oldValue = this.value(); - var step = $.isFunction(this.options.step) ? this.options.step.call(this, dir) : this.options.step; - var multipler = dir === 'up' ? 1 : -1; - - this.value(this.oldValue + Number(step) * multipler); - }, - - value: function(v) { - if (v === null || v === undefined) { - return this.numeric(this.$el.val()); - } - v = this.numeric(v); - - var valid = this.validate(v); - if (valid !== 0) { - v = (valid === -1) ? this.min : this.max; - } - this.$el.val(v.toFixed(this.options.precision)); - - if (this.oldValue !== this.value()) { - // changing.spinner - this.$el.trigger('changing.spinner', [this.value(), this.oldValue]); - - // lazy changed.spinner - clearTimeout(this.spinningTimer); - this.spinningTimer = setTimeout($.proxy(function() { - this.$el.trigger('changed.spinner', [this.value(), this.oldValue]); - }, this), Spinner.delay); - } - }, - - numeric: function(v) { - v = this.options.precision > 0 ? parseFloat(v, 10) : parseInt(v, 10); - - // If the variable is a number - if (isFinite(v)) { - return v; - } - - return v || this.options.min || 0; - }, - - validate: function(val) { - if (this.options.min !== null && val < this.min) { - return -1; - } - - if (this.options.max !== null && val > this.max) { - return 1; - } - - return 0; - } - }; - - Spinner = function(element, options) { - this.$el = $(element); - this.$spinning = this.$el.find('[data-spin="spinner"]'); - - if (this.$spinning.length === 0) { - this.$spinning = this.$el.find('input[type="text"]'); - } - - options = $.extend({}, options, this.$spinning.data()); - - this.spinning = new Spinning(this.$spinning, options); - - this.$el - .on('click.spinner', '[data-spin="up"], [data-spin="down"]', $.proxy(this, 'spin')) - .on('mousedown.spinner', '[data-spin="up"], [data-spin="down"]', $.proxy(this, 'spin')); - - $(document).on('mouseup.spinner', $.proxy(function() { - clearTimeout(this.spinTimeout); - clearInterval(this.spinInterval); - }, this)); - - if (options.delay) { - this.delay(options.delay); - } - - if (options.changed) { - this.changed(options.changed); - } - - if (options.changing) { - this.changing(options.changing); - } - }; - - Spinner.delay = 500; - - Spinner.prototype = { - constructor: Spinner, - - spin: function(e) { - var dir = $(e.currentTarget).data('spin'); - - switch (e.type) { - case 'click': - e.preventDefault(); - this.spinning.spin(dir); - break; - case 'mousedown': - if (e.which === 1) { - this.spinTimeout = setTimeout($.proxy(this, 'beginSpin', dir), 300); - } - break; - } - }, - - delay: function(ms) { - var delay = Number(ms); - - if (delay >= 0) { - this.constructor.delay = delay + 100; - } - }, - - value: function() { - return this.spinning.value(); - }, - - changed: function(fn) { - this.bindHandler('changed.spinner', fn); - }, - - changing: function(fn) { - this.bindHandler('changing.spinner', fn); - }, - - bindHandler: function(t, fn) { - if ($.isFunction(fn)) { - this.$spinning.on(t, fn); - } else { - this.$spinning.off(t); - } - }, - - beginSpin: function(dir) { - this.spinInterval = setInterval($.proxy(this.spinning, 'spin', dir), 100); - } - }; - - var old = $.fn.spinner; - - $.fn.spinner = function(options, value) { - return this.each(function() { - var data = $.data(this, 'spinner'); - - if (!data) { - data = new Spinner(this, options); - - $.data(this, 'spinner', data); - } - if (options === 'delay' || options === 'changed' || options === 'changing') { - data[options](value); - } else if (options === 'step' && value) { - data.spinning.step = value; - } else if (options === 'spin' && value) { - data.spinning.spin(value); - } - }); - }; - - $.fn.spinner.Constructor = Spinner; - $.fn.spinner.noConflict = function() { - $.fn.spinner = old; - return this; - }; - - $(function() { - $('[data-trigger="spinner"]').spinner(); - }); - - return $.fn.spinner; -}); diff --git a/docs/dist/css/bootstrap-spinner.css b/docs/dist/css/bootstrap-spinner.css deleted file mode 100644 index 24059d1..0000000 --- a/docs/dist/css/bootstrap-spinner.css +++ /dev/null @@ -1,60 +0,0 @@ -.spinner.input-group .input-group-addon .spin-up, -.spinner.input-group .input-group-addon .spin-down { - height: 10px; - width: 10px; - overflow: hidden; - display: block; - text-align: center; - color: #999; -} -.spinner.input-group .input-group-addon .spin-up:hover, -.spinner.input-group .input-group-addon .spin-down:hover { - color: #555; -} -.spinner.input-group .input-group-addon .spin-up .fas, -.spinner.input-group .input-group-addon .spin-down .fas { - margin-top: -6px; - vertical-align: middle; -} -.spinner.input-group .input-group-addon .spin-up .glyphicon, -.spinner.input-group .input-group-addon .spin-down .glyphicon { - font-size: 10px; - top: -2px; -} -.spinner.input-group .input-group-addon a.spin-up, -.spinner.input-group .input-group-addon a.spin-down { - text-decoration: none; -} -.spinner.input-group .input-group-addon button.spin-up, -.spinner.input-group .input-group-addon button.spin-down { - background: none; - border: none; - padding: 0; -} -.spinner.input-group.input-group-sm .input-group-addon .spin-up, -.spinner.input-group.input-group-sm .input-group-addon .spin-down { - height: 8px; -} -.spinner.input-group.input-group-sm .input-group-addon .spin-up .fas, -.spinner.input-group.input-group-sm .input-group-addon .spin-down .fas { - margin-top: -10px; -} -.spinner.input-group.input-group-sm .input-group-addon .spin-up .glyphicon, -.spinner.input-group.input-group-sm .input-group-addon .spin-down .glyphicon { - font-size: 8px; - top: -5px; -} -.spinner.input-group.input-group-lg .input-group-addon .spin-up, -.spinner.input-group.input-group-lg .input-group-addon .spin-down { - height: 12px; - width: 12px; -} -.spinner.input-group.input-group-lg .input-group-addon .spin-up .fas, -.spinner.input-group.input-group-lg .input-group-addon .spin-down .fas { - margin-top: -16px; -} -.spinner.input-group.input-group-lg .input-group-addon .spin-up .glyphicon, -.spinner.input-group.input-group-lg .input-group-addon .spin-down .glyphicon { - font-size: 12px; - top: -6px; -} diff --git a/docs/dist/css/bootstrap-spinner.min.css b/docs/dist/css/bootstrap-spinner.min.css deleted file mode 100644 index b58a0c1..0000000 --- a/docs/dist/css/bootstrap-spinner.min.css +++ /dev/null @@ -1,2 +0,0 @@ -.spinner.input-group .input-group-addon .spin-down,.spinner.input-group .input-group-addon .spin-up{height:10px;width:10px;overflow:hidden;display:block;text-align:center;color:#999}.spinner.input-group .input-group-addon .spin-down:hover,.spinner.input-group .input-group-addon .spin-up:hover{color:#555}.spinner.input-group .input-group-addon .spin-down .fas,.spinner.input-group .input-group-addon .spin-up .fas{margin-top:-6px;vertical-align:middle}.spinner.input-group .input-group-addon .spin-down .glyphicon,.spinner.input-group .input-group-addon .spin-up .glyphicon{font-size:10px;top:-2px}.spinner.input-group .input-group-addon a.spin-down,.spinner.input-group .input-group-addon a.spin-up{text-decoration:none}.spinner.input-group .input-group-addon button.spin-down,.spinner.input-group .input-group-addon button.spin-up{background:0 0;border:none;padding:0}.spinner.input-group.input-group-sm .input-group-addon .spin-down,.spinner.input-group.input-group-sm .input-group-addon .spin-up{height:8px}.spinner.input-group.input-group-sm .input-group-addon .spin-down .fas,.spinner.input-group.input-group-sm .input-group-addon .spin-up .fas{margin-top:-10px}.spinner.input-group.input-group-sm .input-group-addon .spin-down .glyphicon,.spinner.input-group.input-group-sm .input-group-addon .spin-up .glyphicon{font-size:8px;top:-5px}.spinner.input-group.input-group-lg .input-group-addon .spin-down,.spinner.input-group.input-group-lg .input-group-addon .spin-up{height:12px;width:12px}.spinner.input-group.input-group-lg .input-group-addon .spin-down .fas,.spinner.input-group.input-group-lg .input-group-addon .spin-up .fas{margin-top:-16px}.spinner.input-group.input-group-lg .input-group-addon .spin-down .glyphicon,.spinner.input-group.input-group-lg .input-group-addon .spin-up .glyphicon{font-size:12px;top:-6px} -/*# sourceMappingURL=bootstrap-spinner.min.css.map */ \ No newline at end of file diff --git a/docs/dist/css/bootstrap-spinner.min.css.map b/docs/dist/css/bootstrap-spinner.min.css.map deleted file mode 100644 index 4083f47..0000000 --- a/docs/dist/css/bootstrap-spinner.min.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["dist/css/bootstrap-spinner.css"],"names":[],"mappings":"AACA,mDADA,iDAEE,OAAQ,KACR,MAAO,KACP,SAAU,OACV,QAAS,MACT,WAAY,OACZ,MAAO,KAGT,yDADA,uDAEE,MAAO,KAGT,wDADA,sDAEE,WAAY,KACZ,eAAgB,OAGlB,8DADA,4DAEE,UAAW,KACX,IAAK,KAGP,oDADA,kDAEE,gBAAiB,KAGnB,yDADA,uDAEE,WAAY,IACZ,OAAQ,KACR,QAAS,EAGX,kEADA,gEAEE,OAAQ,IAGV,uEADA,qEAEE,WAAY,MAGd,6EADA,2EAEE,UAAW,IACX,IAAK,KAGP,kEADA,gEAEE,OAAQ,KACR,MAAO,KAGT,uEADA,qEAEE,WAAY,MAGd,6EADA,2EAEE,UAAW,KACX,IAAK","sourcesContent":[".spinner.input-group .input-group-addon .spin-up,\n.spinner.input-group .input-group-addon .spin-down {\n height: 10px;\n width: 10px;\n overflow: hidden;\n display: block;\n text-align: center;\n color: #999;\n}\n.spinner.input-group .input-group-addon .spin-up:hover,\n.spinner.input-group .input-group-addon .spin-down:hover {\n color: #555;\n}\n.spinner.input-group .input-group-addon .spin-up .fas,\n.spinner.input-group .input-group-addon .spin-down .fas {\n margin-top: -6px;\n vertical-align: middle;\n}\n.spinner.input-group .input-group-addon .spin-up .glyphicon,\n.spinner.input-group .input-group-addon .spin-down .glyphicon {\n font-size: 10px;\n top: -2px;\n}\n.spinner.input-group .input-group-addon a.spin-up,\n.spinner.input-group .input-group-addon a.spin-down {\n text-decoration: none;\n}\n.spinner.input-group .input-group-addon button.spin-up,\n.spinner.input-group .input-group-addon button.spin-down {\n background: none;\n border: none;\n padding: 0;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down {\n height: 8px;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up .fas,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down .fas {\n margin-top: -10px;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up .glyphicon,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down .glyphicon {\n font-size: 8px;\n top: -5px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down {\n height: 12px;\n width: 12px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up .fas,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down .fas {\n margin-top: -16px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up .glyphicon,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down .glyphicon {\n font-size: 12px;\n top: -6px;\n}\n"]} \ No newline at end of file diff --git a/dist/css/bootstrap-spinner.css b/docs/dist/input-spinner.css similarity index 100% rename from dist/css/bootstrap-spinner.css rename to docs/dist/input-spinner.css diff --git a/docs/dist/js/jquery.spinner.js b/docs/dist/input-spinner.js similarity index 99% rename from docs/dist/js/jquery.spinner.js rename to docs/dist/input-spinner.js index 4efd312..e6f5dc8 100644 --- a/docs/dist/js/jquery.spinner.js +++ b/docs/dist/input-spinner.js @@ -1,6 +1,6 @@ /* - * jquery.spinner - * https://github.com/vsn4ik/jquery.spinner + * input-spinner + * https://github.com/vsn4ik/input-spinner * Copyright Vasilii A., 2015–2018 * Copyright xixilive, 2013–2015 * Licensed under the MIT license diff --git a/dist/css/bootstrap-spinner.min.css b/docs/dist/input-spinner.min.css similarity index 97% rename from dist/css/bootstrap-spinner.min.css rename to docs/dist/input-spinner.min.css index b58a0c1..8a8ba04 100644 --- a/dist/css/bootstrap-spinner.min.css +++ b/docs/dist/input-spinner.min.css @@ -1,2 +1,2 @@ .spinner.input-group .input-group-addon .spin-down,.spinner.input-group .input-group-addon .spin-up{height:10px;width:10px;overflow:hidden;display:block;text-align:center;color:#999}.spinner.input-group .input-group-addon .spin-down:hover,.spinner.input-group .input-group-addon .spin-up:hover{color:#555}.spinner.input-group .input-group-addon .spin-down .fas,.spinner.input-group .input-group-addon .spin-up .fas{margin-top:-6px;vertical-align:middle}.spinner.input-group .input-group-addon .spin-down .glyphicon,.spinner.input-group .input-group-addon .spin-up .glyphicon{font-size:10px;top:-2px}.spinner.input-group .input-group-addon a.spin-down,.spinner.input-group .input-group-addon a.spin-up{text-decoration:none}.spinner.input-group .input-group-addon button.spin-down,.spinner.input-group .input-group-addon button.spin-up{background:0 0;border:none;padding:0}.spinner.input-group.input-group-sm .input-group-addon .spin-down,.spinner.input-group.input-group-sm .input-group-addon .spin-up{height:8px}.spinner.input-group.input-group-sm .input-group-addon .spin-down .fas,.spinner.input-group.input-group-sm .input-group-addon .spin-up .fas{margin-top:-10px}.spinner.input-group.input-group-sm .input-group-addon .spin-down .glyphicon,.spinner.input-group.input-group-sm .input-group-addon .spin-up .glyphicon{font-size:8px;top:-5px}.spinner.input-group.input-group-lg .input-group-addon .spin-down,.spinner.input-group.input-group-lg .input-group-addon .spin-up{height:12px;width:12px}.spinner.input-group.input-group-lg .input-group-addon .spin-down .fas,.spinner.input-group.input-group-lg .input-group-addon .spin-up .fas{margin-top:-16px}.spinner.input-group.input-group-lg .input-group-addon .spin-down .glyphicon,.spinner.input-group.input-group-lg .input-group-addon .spin-up .glyphicon{font-size:12px;top:-6px} -/*# sourceMappingURL=bootstrap-spinner.min.css.map */ \ No newline at end of file +/*# sourceMappingURL=input-spinner.min.css.map */ \ No newline at end of file diff --git a/docs/dist/input-spinner.min.css.map b/docs/dist/input-spinner.min.css.map new file mode 100644 index 0000000..339f692 --- /dev/null +++ b/docs/dist/input-spinner.min.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["dist/input-spinner.css"],"names":[],"mappings":"AACA,mDADA,iDAEE,OAAQ,KACR,MAAO,KACP,SAAU,OACV,QAAS,MACT,WAAY,OACZ,MAAO,KAGT,yDADA,uDAEE,MAAO,KAGT,wDADA,sDAEE,WAAY,KACZ,eAAgB,OAGlB,8DADA,4DAEE,UAAW,KACX,IAAK,KAGP,oDADA,kDAEE,gBAAiB,KAGnB,yDADA,uDAEE,WAAY,IACZ,OAAQ,KACR,QAAS,EAGX,kEADA,gEAEE,OAAQ,IAGV,uEADA,qEAEE,WAAY,MAGd,6EADA,2EAEE,UAAW,IACX,IAAK,KAGP,kEADA,gEAEE,OAAQ,KACR,MAAO,KAGT,uEADA,qEAEE,WAAY,MAGd,6EADA,2EAEE,UAAW,KACX,IAAK","sourcesContent":[".spinner.input-group .input-group-addon .spin-up,\n.spinner.input-group .input-group-addon .spin-down {\n height: 10px;\n width: 10px;\n overflow: hidden;\n display: block;\n text-align: center;\n color: #999;\n}\n.spinner.input-group .input-group-addon .spin-up:hover,\n.spinner.input-group .input-group-addon .spin-down:hover {\n color: #555;\n}\n.spinner.input-group .input-group-addon .spin-up .fas,\n.spinner.input-group .input-group-addon .spin-down .fas {\n margin-top: -6px;\n vertical-align: middle;\n}\n.spinner.input-group .input-group-addon .spin-up .glyphicon,\n.spinner.input-group .input-group-addon .spin-down .glyphicon {\n font-size: 10px;\n top: -2px;\n}\n.spinner.input-group .input-group-addon a.spin-up,\n.spinner.input-group .input-group-addon a.spin-down {\n text-decoration: none;\n}\n.spinner.input-group .input-group-addon button.spin-up,\n.spinner.input-group .input-group-addon button.spin-down {\n background: none;\n border: none;\n padding: 0;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down {\n height: 8px;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up .fas,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down .fas {\n margin-top: -10px;\n}\n.spinner.input-group.input-group-sm .input-group-addon .spin-up .glyphicon,\n.spinner.input-group.input-group-sm .input-group-addon .spin-down .glyphicon {\n font-size: 8px;\n top: -5px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down {\n height: 12px;\n width: 12px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up .fas,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down .fas {\n margin-top: -16px;\n}\n.spinner.input-group.input-group-lg .input-group-addon .spin-up .glyphicon,\n.spinner.input-group.input-group-lg .input-group-addon .spin-down .glyphicon {\n font-size: 12px;\n top: -6px;\n}\n"]} \ No newline at end of file diff --git a/dist/js/jquery.spinner.min.js b/docs/dist/input-spinner.min.js similarity index 100% rename from dist/js/jquery.spinner.min.js rename to docs/dist/input-spinner.min.js diff --git a/docs/dist/js/jquery.spinner.min.js b/docs/dist/js/jquery.spinner.min.js deleted file mode 100644 index 18c8266..0000000 --- a/docs/dist/js/jquery.spinner.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";!function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):"object"==typeof exports?module.exports=factory(require("jquery")):factory(jQuery)}((function($){var Spinner,Spinning=function($element,options){return this.$el=$element,this.options=$.extend({},Spinning.rules.defaults,Spinning.rules[options.rule]||{},options),this.min=Number(this.options.min)||0,this.max=Number(this.options.max)||0,this.spinningTimer=null,this.$el.on({"focus.spinner":$.proxy((function(e){e.preventDefault(),$(document).trigger("mouseup.spinner"),this.oldValue=this.value()}),this),"change.spinner":$.proxy((function(e){e.preventDefault(),this.value(this.$el.val())}),this),"keydown.spinner":$.proxy((function(e){var dir={38:"up",40:"down"}[e.which];dir&&(e.preventDefault(),this.spin(dir))}),this)}),this.oldValue=this.value(),this.value(this.$el.val()),this};Spinning.rules={defaults:{min:null,max:null,step:1,precision:0},currency:{min:0,max:null,step:.01,precision:2},quantity:{min:1,max:999,step:1,precision:0},percent:{min:1,max:100,step:1,precision:0},month:{min:1,max:12,step:1,precision:0},day:{min:1,max:31,step:1,precision:0},hour:{min:0,max:23,step:1,precision:0},minute:{min:1,max:59,step:1,precision:0},second:{min:1,max:59,step:1,precision:0}},Spinning.prototype={spin:function(dir){if(!this.$el.prop("disabled")){this.oldValue=this.value();var step=$.isFunction(this.options.step)?this.options.step.call(this,dir):this.options.step,multipler="up"===dir?1:-1;this.value(this.oldValue+Number(step)*multipler)}},value:function(v){if(null==v)return this.numeric(this.$el.val());v=this.numeric(v);var valid=this.validate(v);0!==valid&&(v=-1===valid?this.min:this.max),this.$el.val(v.toFixed(this.options.precision)),this.oldValue!==this.value()&&(this.$el.trigger("changing.spinner",[this.value(),this.oldValue]),clearTimeout(this.spinningTimer),this.spinningTimer=setTimeout($.proxy((function(){this.$el.trigger("changed.spinner",[this.value(),this.oldValue])}),this),Spinner.delay))},numeric:function(v){return v=this.options.precision>0?parseFloat(v,10):parseInt(v,10),isFinite(v)?v:v||this.options.min||0},validate:function(val){return null!==this.options.min&&valthis.max?1:0}},(Spinner=function(element,options){this.$el=$(element),this.$spinning=this.$el.find('[data-spin="spinner"]'),0===this.$spinning.length&&(this.$spinning=this.$el.find('input[type="text"]')),options=$.extend({},options,this.$spinning.data()),this.spinning=new Spinning(this.$spinning,options),this.$el.on("click.spinner",'[data-spin="up"], [data-spin="down"]',$.proxy(this,"spin")).on("mousedown.spinner",'[data-spin="up"], [data-spin="down"]',$.proxy(this,"spin")),$(document).on("mouseup.spinner",$.proxy((function(){clearTimeout(this.spinTimeout),clearInterval(this.spinInterval)}),this)),options.delay&&this.delay(options.delay),options.changed&&this.changed(options.changed),options.changing&&this.changing(options.changing)}).delay=500,Spinner.prototype={constructor:Spinner,spin:function(e){var dir=$(e.currentTarget).data("spin");switch(e.type){case"click":e.preventDefault(),this.spinning.spin(dir);break;case"mousedown":1===e.which&&(this.spinTimeout=setTimeout($.proxy(this,"beginSpin",dir),300))}},delay:function(ms){var delay=Number(ms);delay>=0&&(this.constructor.delay=delay+100)},value:function(){return this.spinning.value()},changed:function(fn){this.bindHandler("changed.spinner",fn)},changing:function(fn){this.bindHandler("changing.spinner",fn)},bindHandler:function(t,fn){$.isFunction(fn)?this.$spinning.on(t,fn):this.$spinning.off(t)},beginSpin:function(dir){this.spinInterval=setInterval($.proxy(this.spinning,"spin",dir),100)}};var old=$.fn.spinner;return $.fn.spinner=function(options,value){return this.each((function(){var data=$.data(this,"spinner");data||(data=new Spinner(this,options),$.data(this,"spinner",data)),"delay"===options||"changed"===options||"changing"===options?data[options](value):"step"===options&&value?data.spinning.step=value:"spin"===options&&value&&data.spinning.spin(value)}))},$.fn.spinner.Constructor=Spinner,$.fn.spinner.noConflict=function(){return $.fn.spinner=old,this},$((function(){$('[data-trigger="spinner"]').spinner()})),$.fn.spinner})); \ No newline at end of file diff --git a/docs/example.html b/docs/example.html index c4c5f0e..82dc37f 100644 --- a/docs/example.html +++ b/docs/example.html @@ -6,24 +6,24 @@ Example - - + + - +
-

Examples for jQuery spinner

+

Examples

  • Arrow-up for increment
  • Arrow-down for decrement
  • diff --git a/docs/index.html b/docs/index.html index d1254a5..e19d18e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3,54 +3,53 @@ - jQuery.spinner + Input Spinner - - - + + + - - - + + +
    -

    jQuery.spinner

    -

    A Number-Spinner based-on jQuery, Support Keyboard operations and continuous changing.

    +

    Input Spinner

    +

    A Number-Spinner, Support keyboard operations and continuous changing.

    -  Download +  Download

    -  View On GitHub +  View On GitHub
    -

    Examples of jQuery.spinner

    +

    Examples

    • Arrow-up for increment
    • Arrow-down for decrement
    • diff --git a/js/tests/index.html b/js/tests/index.html deleted file mode 100644 index 3e99b69..0000000 --- a/js/tests/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - A number-spinner based-on jQuery Test Suite - - -
      -
      - - diff --git a/package.json b/package.json index 4ce06aa..78d3243 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "private": true, - "name": "jquery.spinner", - "version": "0.2.1", - "description": "A Number-Spinner based-on jQuery, Support Keyboard operations and continuous changing", + "name": "input-spinner", + "version": "1.0.0", + "description": "A Number-Spinner, Support keyboard operations and continuous changing", "keywords": [ "spinner", "number-steps", "number-spinner", "continuous" ], - "homepage": "https://vsn4ik.github.io/jquery.spinner/", + "homepage": "https://vsn4ik.github.io/input-spinner/", "author": { "name": "xixilive", "email": "xixilive@gmail.com", @@ -21,33 +21,32 @@ "url": "https://github.com/vsn4ik" } ], - "repository": "vsn4ik/jquery.spinner", + "repository": "vsn4ik/input-spinner", "license": "MIT", "files": [ "dist", - "js/*.js", - "less" + "src" ], - "main": "dist/js/jquery.spinner.js", + "main": "dist/input-spinner.js", "scripts": { - "test": "npm run css; npm run js; karma start js/tests/karma.conf.js", + "test": "npm run css; npm run js; karma start tests/karma.conf.js", "css": "npm run css-compile; npm run css-minify", - "css-compile": "lessc less/bootstrap-spinner.less dist/css/bootstrap-spinner.css", - "css-minify": "cleancss --level 1 --source-map --source-map-inline-sources --output dist/css/bootstrap-spinner.min.css dist/css/bootstrap-spinner.css", + "css-compile": "lessc src/$npm_package_name.less dist/$npm_package_name.css", + "css-minify": "cleancss --level 1 --source-map --source-map-inline-sources --output dist/$npm_package_name.min.css dist/$npm_package_name.css", "js": "npm run js-compile; npm run js-minify", - "js-compile": "mkdir -p dist/js; cp -rf js/*.js dist/js/", - "js-minify": "terser --compress --output dist/js/$npm_package_name.min.js dist/js/$npm_package_name.js", - "release-zip": "cd dist/ && zip -r9 $npm_package_name-$npm_package_version-dist.zip * && mv $npm_package_name-$npm_package_version-dist.zip .." + "js-compile": "mkdir dist; cp -rf src/*.js dist/", + "js-minify": "terser --compress --output dist/$npm_package_name.min.js dist/$npm_package_name.js", + "release-zip": "rm -rf $npm_package_name-$npm_package_version-dist && cp -r dist/ $npm_package_name-$npm_package_version-dist && zip -r9 $npm_package_name-$npm_package_version-dist.zip $npm_package_name-$npm_package_version-dist && rm -rf $npm_package_name-$npm_package_version-dist" }, "devDependencies": { - "puppeteer": "2.0.0", + "puppeteer": "2.1.1", "karma": "4.4.1", "karma-chrome-launcher": "3.1.0", "karma-qunit": "4.0.0", "karma-sinon": "1.0.5", "clean-css-cli": "4.3.0", - "terser": "4.4.2", - "less": "3.10.3", + "terser": "4.6.4", + "less": "3.11.1", "jquery": "3.4.1", "qunit": "2.9.3" } diff --git a/js/jquery.spinner.js b/src/input-spinner.js similarity index 99% rename from js/jquery.spinner.js rename to src/input-spinner.js index 4efd312..e6f5dc8 100644 --- a/js/jquery.spinner.js +++ b/src/input-spinner.js @@ -1,6 +1,6 @@ /* - * jquery.spinner - * https://github.com/vsn4ik/jquery.spinner + * input-spinner + * https://github.com/vsn4ik/input-spinner * Copyright Vasilii A., 2015–2018 * Copyright xixilive, 2013–2015 * Licensed under the MIT license diff --git a/less/bootstrap-spinner.less b/src/input-spinner.less similarity index 100% rename from less/bootstrap-spinner.less rename to src/input-spinner.less diff --git a/tests/index.html b/tests/index.html new file mode 100644 index 0000000..367c773 --- /dev/null +++ b/tests/index.html @@ -0,0 +1,19 @@ + + + + + + + + + + + + + Test Suite + + +
      +
      + + diff --git a/js/tests/karma.conf.js b/tests/karma.conf.js similarity index 90% rename from js/tests/karma.conf.js rename to tests/karma.conf.js index 22bd00b..3eb0fd6 100644 --- a/js/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -17,7 +17,7 @@ const conf = { // ] // } // }, - basePath: '../..', + basePath: '..', colors: true, frameworks: [ 'qunit' @@ -28,8 +28,8 @@ const conf = { ], files: [ 'node_modules/jquery/dist/jquery.slim.js', - 'js/jquery.spinner.js', - 'js/tests/unit/unit.js' + 'src/input-spinner.js', + 'tests/unit/unit.js' ], autoWatch: false, singleRun: true, diff --git a/js/tests/unit/unit.js b/tests/unit/unit.js similarity index 100% rename from js/tests/unit/unit.js rename to tests/unit/unit.js