first commit

This commit is contained in:
aschwarz
2023-03-14 14:47:50 +01:00
commit 062b2dfae8
4752 changed files with 505842 additions and 0 deletions

44
jquery/number/README.md Normal file
View File

@ -0,0 +1,44 @@
#wan-spinner, a jQuery Spinner
----------
> ![demo](http://7xl1b4.com1.z0.glb.clouddn.com/wan-spinner.png)
### [demo](http://blog.0xfc.cn/2015/08/09/spinner/) ###
> demo/test.html
**prepare to use**
> - include jQuery
> - include bulid/wan-spinner.css
> - include build/wan-sinner.js
> - in your html:
> ```html
><div class="wan-spinner">
> <a href="javascript:void(0)" class="minus">-</a>
> <input type="text" value="1">
> <a href="javascript:void(0)" class="plus">+</a>
></div>
>```
**how to use**
> `$(".wan-spinner").WanSpinner(options);`
**options**
> maxValue: Number, default 999. Set the Max Value of the input.
>
> minValue: Number, default -999. Set the Min Value of the input.
>
> step: Number, default 1. Set the Step Value of the input when click plus and minus button.
>
> start: Number, default 1. Set the Init Value of the input.
>
> inputWidth: Number default 24. Set the Input Width.
>
> plusClick: function. A trigger when Plus Button is clicked.
>
> minusClick: function. A trigger when Minus Button is clicked.
>
> valueChanged: function. A trigger when Input Value is changed.

View File

@ -0,0 +1,35 @@
/*********** spinner start *************/
.wan-spinner {
border: 1px solid #dddddd;
display: inline-block;
}
.wan-spinner .minus,
.wan-spinner .plus,
.wan-spinner input {
height: 15px;
float: left;
line-height: 1em;
padding: 5px;
text-align: center;
}
.wan-spinner input {
border: none;
border-left: 1px solid #dddddd;
border-right: 1px solid #dddddd;
margin: 0;
width: 40px;
}
.wan-spinner .minus,
.wan-spinner .plus {
color: #333333;
cursor: pointer;
text-decoration: none;
width: 15px;
}
/*********** spinner end *************/

113
jquery/number/build/wan-spinner.js vendored Normal file
View File

@ -0,0 +1,113 @@
;
(function($, window, document, undefined) {
'use strict';
var output = function(msg) {
window.console && console.log(msg);
};
var WanSpinner = function(element, options) {
this.defaults = {
maxValue: 999,
minValue: -999,
step: 1,
start: 1,
inputWidth: 40,
plusClick: function(element, val) {
return true;
},
minusClick: function(element, val) {
return true;
},
exceptionFun: function(element, exp) {
return true;
},
valueChanged: function(element, val) {
return true;
}
};
this.options = $.extend({}, this.defaults, options);
this.options.stepLength = ((+this.options.step).toString().split('.')[1] || '').length;
this.options.stepFloat = parseInt(1 * Math.pow(10, this.options.stepLength) / this.options.step) || 1;
this.element = $(element);
this.options.exceptionFunEnable = (typeof(this.options.exceptionFun) === 'function');
this.options.plusClickEnable = (typeof(this.options.plusClick) === 'function');
this.options.minusClickEnable = (typeof(this.options.minusClick) === 'function');
this.options.valueChangedEnable = (typeof(this.options.valueChanged) === 'function');
this.element.each(function(index, dt) {
var input = $(dt).children('input');
var initValue = input.val() || this.options.start;
input.val(initValue);
});
this.element.children('input').css('width', this.options.inputWidth);
this.EXCEPTION = {
TOO_LARGE: 1,
NORMAL: 0,
TOO_SMALL: -1
};
};
WanSpinner.prototype.bind = function() {
var self = this;
$(self.element).delegate('.minus', 'click', function() {
var val;
var input = $(this).siblings('input');
if (self.options.stepFloat > 1) {
val = (+input.val() || 0) * self.options.stepFloat - self.options.step * self.options.stepFloat;
val = Math.round(val) / self.options.stepFloat;
} else {
val = (+input.val() || 0) - self.options.step;
}
val = val.toFixed(self.options.stepLength);
if (val < self.options.minValue) {
self.options.exceptionFunEnable && self.options.exceptionFun($(this).parent(), self.EXCEPTION.TOO_SMALL);
} else {
input.val(val);
self.options.minusClickEnable && self.options.minusClick($(this).parent(), val);
self.options.valueChangedEnable && self.options.valueChanged($(this).parent(), val);
}
return false;
}).delegate('.plus', 'click', function() {
var val;
var input = $(this).siblings('input');
if (self.options.stepFloat > 1) {
val = (+input.val() || 0) * self.options.stepFloat + self.options.step * self.options.stepFloat;
val = Math.round(val) / self.options.stepFloat;
} else {
val = (+input.val() || 0) + self.options.step;
}
val = val.toFixed(self.options.stepLength);
if (val > self.options.maxValue) {
self.options.exceptionFunEnable && self.options.exceptionFun($(this).parent(), self.EXCEPTION.TOO_LARGE);
} else {
input.val(val);
self.options.plusClickEnable && self.options.plusClick($(this).parent(), val);
self.options.valueChangedEnable && self.options.valueChanged($(this).parent(), val);
}
return false;
}).delegate('input', 'change', function() {
var val = +$(this).val() || 0;
if (val > self.options.maxValue) {
val = self.options.maxValue;
self.options.exceptionFunEnable && self.options.exceptionFun($(this).parent(), self.EXCEPTION.TOO_LARGE);
} else if (val < self.options.minValue) {
val = self.options.minValue;
self.options.exceptionFunEnable && self.options.exceptionFun($(this).parent(), self.EXCEPTION.TOO_SMALL);
}
$(this).val(val);
self.options.valueChangedEnable && self.options.valueChanged($(this).parent(), val);
});
}
$.fn.WanSpinner = function(options) {
var wanSpinner = new WanSpinner(this, options);
wanSpinner.bind();
return this;
};
})(jQuery, window, document);

View File

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>jQuery Wan Spinner Plugin Demos</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="../build/wan-spinner.css">
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
<style>
body { background-color:#ECF0F1; font-family:'Roboto Condensed';}
.container { margin:150px auto; text-align:center; max-width:640px;}
h1 { margin-bottom:50px;}
</style>
</head>
<body>
<div id="jquery-script-menu">
<div class="jquery-script-center">
<ul>
<li><a href="http://www.jqueryscript.net/form/Minimal-Number-Picker-Plugin-For-jQuery-Wan-Spinner.html">Download This Plugin</a></li>
<li><a href="http://www.jqueryscript.net/">Back To jQueryScript.Net</a></li>
</ul>
<div class="jquery-script-ads"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2783044520727903";
/* jQuery_demo */
google_ad_slot = "2780937993";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<div class="jquery-script-clear"></div>
</div>
</div>
<div class="container">
<h1>jQuery Wan Spinner Plugin Demos</h1>
<div class="wan-spinner wan-spinner-1">
<a href="javascript:void(0)" class="minus">-</a>
<input type="text" value="1">
<a href="javascript:void(0)" class="plus">+</a>
</div><br>
<br/>
<div class="wan-spinner wan-spinner-2">
<a href="javascript:void(0)" class="minus">-</a>
<input type="text" value="1">
<a href="javascript:void(0)" class="plus">+</a>
</div><br>
<br>
<div class="wan-spinner wan-spinner-3">
<a href="javascript:void(0)" class="minus">-</a>
<input type="text" value="1">
<a href="javascript:void(0)" class="plus">+</a>
</div>
<script src="../../jquery-1.12.4.js"></script>
<script type="text/javascript" src="../build/wan-spinner.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
maxValue: 10,
minValue: -5,
step: 0.1,
inputWidth: 100,
start: -2,
plusClick: function(val) {
console.log(val);
},
minusClick: function(val) {
console.log(val);
},
exceptionFun: function(val) {
console.log("excep: " + val);
},
valueChanged: function(val) {
console.log('change: ' + val);
}
}
$(".wan-spinner-1").WanSpinner(options);
$(".wan-spinner-2").WanSpinner().css("border-color", "#2C3E50");
$(".wan-spinner-3").WanSpinner({inputWidth: 100}).css("border-color", "#C0392B");
});
</script>
</div>
</body>
</html>

5
jquery/number/numbertor/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
#################
## PhpStorm
#################
.idea

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2014 Qodio
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.

View File

@ -0,0 +1,79 @@
Numbertor
=======
Numbertor is a jQuery-based addon for input boxes, giving them a number sanitizer.
[You can see a demo here](http://opensource.qodio.com/numbertor).
Usage
-----
###### include in head:
```html
<script src="jquery-1.11.0.min.js"></script>
<script src="fm.numbertor.jquery.js"></script>
```
###### to activate replacement:
```javascript
$('#inputBox').numbertor();
```
If you don't wan't to meddle with scripting, there is an alternative to activate replacement, by using inline markup.
```html
<input type="text" class="numbertor" data-numbertor-allow-empty="true">
```
###### if you want to change settings:
```javascript
$('#inputBox').numbertor({
decimals: 'auto', // number of decimals to use
decimalSeperator: ',', // the decimal seperator to be used
thousandSeperator: '.', // the thousand seperator to be used
allowEmpty: false // if false, then value will be set to 0 when empty
});
```
jQuery methods
--------------
Method | Description
------------------ | -----------
destroy | This method is used to remove the instance of the plugin from the input box.
###### Method usage
```javascript
$('#inputBox').numbertor('destroy');
```
Browser compatibility
---------------------
* IE 8+
* Chrome 3+
* Firefox 3.6+
* Safari 5+
* Opera 10.5+
Copyright and license
---------------------
The MIT License (MIT)
Copyright (c) 2014 Qodio
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.

View File

@ -0,0 +1,167 @@
/*
Numbertor jQuery Plugin
Numbertor is a jQuery-based addon for input boxes, giving them a number sanitizer.
version 1.1, Dec 11th, 2015
by Ingi P. Jacobsen
The MIT License (MIT)
Copyright (c) 2014 Qodio
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.
*/
(function($) {
$.numbertor = function (element, options) {
var defaults = {
decimals: 'auto',
decimalSeperator: ',',
thousandSeperator: '.',
allowEmpty: false
};
var plugin = this;
var $element = $(element);
plugin.settings = {};
// INITIALIZE PLUGIN
plugin.init = function () {
plugin.settings = $.extend({}, defaults, options);
$element.addClass('numbertor');
$element.bind('blur', sanitize);
$element.bind('mouseup', unsanitize);
$element.bind('mouseup', select);
sanitize();
};
plugin.refresh = function () {
sanitize();
};
var sanitize = function () {
$element.val(sanitizeNumber($element.val(), plugin.settings.decimals, plugin.settings.decimalSeperator, plugin.settings.thousandSeperator));
};
var unsanitize = function () {
$element.val(unsanitizeNumber($element.val(), plugin.settings.decimals, plugin.settings.decimalSeperator, plugin.settings.thousandSeperator));
};
var select = function () {
$element.select();
};
var sanitizeNumber = function (number, decimals, decimalSeperator, thousandSeperator) {
decimals = decimals === undefined ? 'auto' : decimals;
decimalSeperator = decimalSeperator === undefined ? ',' : decimalSeperator;
thousandSeperator = thousandSeperator === undefined ? '.' : thousandSeperator;
if (number !== '') {
number = number.toString();
number = number.replace(/[^0-9,\.]/g,'').replace(thousandSeperator, '').replace(decimalSeperator, '.');
number = number_format(number, decimals, decimalSeperator, thousandSeperator);
} else if (!plugin.settings.allowEmpty) {
number = 0;
number = number_format(number, decimals, decimalSeperator, thousandSeperator);
}
return number;
};
var unsanitizeNumber = function (number, decimals, decimalSeperator, thousandSeperator) {
decimals = decimals === undefined ? 'auto' : decimals;
decimalSeperator = decimalSeperator === undefined ? ',' : decimalSeperator;
thousandSeperator = thousandSeperator === undefined ? '.' : thousandSeperator;
if (number !== '') {
number = parseFloat(number.toString().replace(/\s/g, '').replace(thousandSeperator, '').replace(decimalSeperator, '.')).toString().replace('.', decimalSeperator);
}
return number;
};
var number_format = function (number, decimals, dec_point, thousands_sep) {
number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
var n = !isFinite(+number) ? 0 : +number,
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
s = '',
toFixedFix = function (n, prec) {
var k = Math.pow(10, prec);
return '' + Math.round(n * k) / k;
};
// Fix for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || '';
s[1] += new Array(prec - s[1].length + 1).join('0');
}
return s.join(dec);
};
// REMOVE PLUGIN AND REVERT INPUT ELEMENT TO ORIGINAL STATE
plugin.destroy = function () {
$element.removeClass('numbertor');
$.removeData(element, 'numbertor');
$element.unbind('blur', sanitize);
$element.unbind('mouseup', select);
$element.unbind('mouseup', unsanitize);
$element.show();
};
// Initialize plugin
plugin.init();
};
$.fn.numbertor = function(options) {
options = options !== undefined ? options : {};
return this.each(function () {
if (typeof(options) === 'object') {
if (undefined === $(this).data('numbertor')) {
var plugin = new $.numbertor(this, options);
$(this).data('numbertor', plugin);
}
} else if ($(this).data('numbertor')[options]) {
$(this).data('numbertor')[options].apply(this, Array.prototype.slice.call(arguments, 1));
} else {
$.error('Method ' + options + ' does not exist in $.numbertor');
}
});
};
}(jQuery));
$(function () {
$('.numbertor').each(function () {
var $this = $(this);
var options = {};
$.each($this.data(), function (key, value) {
if (key.substring(0, 9) == 'numbertor') {
var value_temp = value.toString().replace(/'/g, '"');
value_temp = $.parseJSON(value_temp);
if (typeof value_temp == 'object') {
value = value_temp;
}
options[key.substring(9, 10).toLowerCase() + key.substring(10)] = value;
}
});
$this.numbertor(options);
});
});

View File

@ -0,0 +1,111 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.css" rel="stylesheet" type="text/css">
<title>jQuery Numbertor: Input Format Plugin Demos</title>
<style>
body {
font-family: 'Roboto';
background-color:#f7f7f7;
margin: 0;
padding: 0;
}
.container { margin:150px auto;}
label {
font-weight: bold;
padding-top: 5px;
display: block;
}
input {
padding: 5px;
font-size: 20px;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script src="fm.numbertor.jquery.js"></script>
<script>
$(function () {
$('#inputNumbertor1').numbertor();
$('#inputNumbertor2').numbertor({
decimals: 2
});
$('#inputNumbertor3').numbertor({
decimals: 2,
decimalSeperator: '.',
thousandSeperator: ','
});
$('#inputNumbertor4').numbertor({
allowEmpty: false
});
$('#inputNumbertor5').numbertor({
allowEmpty: true
});
});
</script>
</head>
<body>
<div id="jquery-script-menu">
<div class="jquery-script-center">
<ul>
<li><a href="https://www.jqueryscript.net/form/Number-Input-Format-Plugin-jQuery-Numbertor.html">Download This Plugin</a></li>
<li><a href="https://www.jqueryscript.net/">Back To jQueryScript.Net</a></li>
</ul>
<div class="jquery-script-ads"><script type="text/javascript"><!--
google_ad_client = "ca-pub-2783044520727903";
/* jQuery_demo */
google_ad_slot = "2780937993";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<div class="jquery-script-clear"></div>
</div>
</div>
<div id="wrapper" class="container">
<h1>jQuery Numbertor: Input Format Plugin Demos</h1>
<label for="inputNumbertor1">default</label>
<input id="inputNumbertor1" value="1234,567" class="form-control"><br>
<br>
<label for="inputNumbertor2">decimals: 2</label>
<input id="inputNumbertor2" value="1234,567" class="form-control"><br>
<br>
<label for="inputNumbertor3">decimalSeperator: '.' and thousandSeperator: ',' (english standard) <i>Notice that the input must adhere to the standard as well</i></label>
<input id="inputNumbertor3" value="1234.567" class="form-control">
<br>
<label for="inputNumbertor4">allowEmpty: false</label>
<input id="inputNumbertor4" value="" class="form-control">
<br>
<label for="inputNumbertor5">allowEmpty: true</label>
<input id="inputNumbertor5" value="" class="form-control">
<br>
<label for="inputNumbertor6">allowEmpty: true</label>
<pre>&lt;input class=&quot;numbertor&quot; id=&quot;inputNumbertor6&quot; value=&quot;1234,567&quot; data-numbertor-allow-empty=&quot;true&quot;&gt;</pre>
<input class="numbertor form-control" id="inputNumbertor6" value="1234,567" data-numbertor-allow-empty="true">
</div>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36251023-1']);
_gaq.push(['_setDomainName', 'jqueryscript.net']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>