jquery-datatables 1.10.17 → 1.10.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +26 -9
  4. data/app/assets/javascripts/datatables/dataTables.bootstrap4.js +2 -2
  5. data/app/assets/javascripts/datatables/dataTables.dataTables.js +37 -0
  6. data/app/assets/javascripts/datatables/dataTables.semanticui.js +7 -3
  7. data/app/assets/javascripts/datatables/jquery.dataTables.js +3 -3
  8. data/app/assets/javascripts/datatables/plugins/api/average.js +0 -1
  9. data/app/assets/javascripts/datatables/plugins/api/sum.js +9 -10
  10. data/app/assets/javascripts/datatables/plugins/pagination/input.js +203 -203
  11. data/app/assets/javascripts/datatables/plugins/search/{alphabetSearch.js → dataTables.alphabetSearch.js} +81 -50
  12. data/app/assets/javascripts/datatables/plugins/sorting/currency.js +36 -0
  13. data/app/assets/javascripts/datatables/plugins/sorting/date-uk.js +42 -0
  14. data/app/assets/javascripts/datatables/plugins/sorting/file-size.js +2 -1
  15. data/app/assets/javascripts/datatables/plugins/sorting/formatted-numbers.js +40 -0
  16. data/app/assets/javascripts/datatables/plugins/sorting/ip-address.js +74 -73
  17. data/app/assets/javascripts/datatables/plugins/sorting/num-html.js +38 -0
  18. data/app/assets/javascripts/datatables/plugins/sorting/numeric-comma.js +37 -0
  19. data/app/assets/javascripts/datatables/plugins/type-detection/currency.js +40 -0
  20. data/app/assets/javascripts/datatables/plugins/type-detection/date-uk.js +19 -0
  21. data/app/assets/javascripts/datatables/plugins/type-detection/file-size.js +20 -0
  22. data/app/assets/javascripts/datatables/plugins/type-detection/formatted-num.js +28 -0
  23. data/app/assets/javascripts/datatables/plugins/type-detection/ip-address.js +18 -0
  24. data/app/assets/javascripts/datatables/plugins/type-detection/num-html.js +56 -0
  25. data/app/assets/javascripts/datatables/plugins/type-detection/numeric-comma.js +40 -0
  26. data/app/assets/stylesheets/datatables/dataTables.bootstrap4.scss +1 -1
  27. data/app/assets/stylesheets/datatables/dataTables.semanticui.scss +1 -1
  28. data/app/assets/stylesheets/datatables/plugins/search/dataTables.alphabetSearch.bootstrap.css +53 -0
  29. data/app/assets/stylesheets/datatables/plugins/search/dataTables.alphabetSearch.css +83 -0
  30. data/jquery-datatables.gemspec +3 -5
  31. data/lib/generators/jquery/datatables/templates/javascripts/initializer.js.tt +11 -0
  32. data/lib/generators/jquery/datatables/templates/views/index.html.erb +1 -1
  33. data/lib/generators/jquery/datatables/templates/views/index.html.haml +12 -0
  34. data/lib/jquery-datatables/version.rb +1 -1
  35. metadata +19 -18
  36. data/app/assets/stylesheets/datatables/plugins/search/alphabetSearch.css +0 -43
@@ -0,0 +1,38 @@
1
+ /**
2
+ * This sorting plug-in allows for HTML tags with numeric data. With the 'html'
3
+ * type it will strip the HTML and then sorts by strings, with this type it
4
+ * strips the HTML and then sorts by numbers. Note also that this sorting
5
+ * plug-in has an equivalent type detection plug-in which can make integration
6
+ * easier.
7
+ *
8
+ * DataTables 1.10+ has HTML numeric data type detection and sorting abilities
9
+ * built-in. As such this plug-in is marked as deprecated, but might be useful
10
+ * when working with old versions of DataTables.
11
+ *
12
+ * @name Numbers with HTML
13
+ * @summary Sort data which is a mix of HTML and numeric data.
14
+ * @deprecated
15
+ * @author [Allan Jardine](http://sprymedia.co.uk)
16
+ *
17
+ * @example
18
+ * $('#example').dataTable( {
19
+ * columnDefs: [
20
+ * { type: 'num-html', targets: 0 }
21
+ * ]
22
+ * } );
23
+ */
24
+
25
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
26
+ "num-html-pre": function ( a ) {
27
+ var x = String(a).replace( /<[\s\S]*?>/g, "" );
28
+ return parseFloat( x );
29
+ },
30
+
31
+ "num-html-asc": function ( a, b ) {
32
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
33
+ },
34
+
35
+ "num-html-desc": function ( a, b ) {
36
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
37
+ }
38
+ } );
@@ -0,0 +1,37 @@
1
+ /**
2
+ * It is not uncommon for non-English speaking countries to use a comma for a
3
+ * decimal place. This sorting plug-in shows how that can be taken account of in
4
+ * sorting by adding the type `numeric-comma` to DataTables. A type detection
5
+ * plug-in for this sorting method is provided below.
6
+ *
7
+ * Please note that the 'Formatted numbers' type detection and sorting plug-ins
8
+ * offer greater flexibility that this plug-in and should be used in preference
9
+ * to this method.
10
+ *
11
+ * @name Commas for decimal place
12
+ * @summary Sort numbers correctly which use a comma as the decimal place.
13
+ * @deprecated
14
+ * @author [Allan Jardine](http://sprymedia.co.uk)
15
+ *
16
+ * @example
17
+ * $('#example').dataTable( {
18
+ * columnDefs: [
19
+ * { type: 'numeric-comma', targets: 0 }
20
+ * ]
21
+ * } );
22
+ */
23
+
24
+ jQuery.extend( jQuery.fn.dataTableExt.oSort, {
25
+ "numeric-comma-pre": function ( a ) {
26
+ var x = (a == "-") ? 0 : a.replace( /,/, "." );
27
+ return parseFloat( x );
28
+ },
29
+
30
+ "numeric-comma-asc": function ( a, b ) {
31
+ return ((a < b) ? -1 : ((a > b) ? 1 : 0));
32
+ },
33
+
34
+ "numeric-comma-desc": function ( a, b ) {
35
+ return ((a < b) ? 1 : ((a > b) ? -1 : 0));
36
+ }
37
+ } );
@@ -0,0 +1,40 @@
1
+ /**
2
+ * This plug-in will add automatic detection for currency columns to
3
+ * DataTables. Note that only $, £ and € symbols are detected with this code,
4
+ * but it is trivial to add more or change the current ones. This is best used
5
+ * in conjunction with the currency sorting plug-in.
6
+ *
7
+ * DataTables 1.10+ has currency sorting abilities built-in and will be
8
+ * automatically detected. As such this plug-in is marked as deprecated, but
9
+ * might be useful when working with old versions of DataTables.
10
+ *
11
+ * @name Currency
12
+ * @summary Detect data of numeric type with a leading currency symbol.
13
+ * @deprecated
14
+ * @author [Allan Jardine](http://sprymedia.co.uk), Nuno Gomes
15
+ */
16
+
17
+ (function(){
18
+
19
+ // Change this list to the valid characters you want
20
+ var validChars = "$£€c" + "0123456789" + ".-,'";
21
+
22
+ // Init the regex just once for speed - it is "closure locked"
23
+ var
24
+ str = jQuery.fn.dataTableExt.oApi._fnEscapeRegex( validChars ),
25
+ re = new RegExp('[^'+str+']');
26
+
27
+
28
+ jQuery.fn.dataTableExt.aTypes.unshift(
29
+ function ( data )
30
+ {
31
+ if ( typeof data !== 'string' || re.test(data) ) {
32
+ return null;
33
+ }
34
+
35
+ return 'currency';
36
+ }
37
+ );
38
+
39
+ }());
40
+
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Automatically detect British (`dd/mm/yyyy`) date types. Goes with the UK
3
+ * date sorting plug-in.
4
+ *
5
+ * @name Date (`dd/mm/yyyy`)
6
+ * @summary Detect data which is in the date format `dd/mm/yyyy`
7
+ * @author Andy McMaster
8
+ */
9
+
10
+ jQuery.fn.dataTableExt.aTypes.unshift(
11
+ function ( sData )
12
+ {
13
+ if (sData !== null && sData.match(/^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/(19|20|21)\d\d$/))
14
+ {
15
+ return 'date-uk';
16
+ }
17
+ return null;
18
+ }
19
+ );
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Detect file size type columns automatically. Commonly used for computer
3
+ * file sizes, this can allow sorting to take the order of magnitude indicated
4
+ * by the label (GB etc) into account.
5
+ *
6
+ * @name File size
7
+ * @summary Detect abbreviated file size data (8MB, 4KB, 3B, etc)
8
+ * @author Allan Jardine - datatables.net
9
+ */
10
+
11
+ jQuery.fn.dataTable.ext.type.detect.unshift( function ( data ) {
12
+ if ( typeof data !== 'string' ) {
13
+ return null;
14
+ }
15
+
16
+ var matches = data.match( /^(\d+(?:\.\d+)?)\s*([a-z]+)/i );
17
+ var units = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
18
+ var is_file_size = ( matches && jQuery.inArray(matches[2].toLowerCase(), units) !== -1 );
19
+ return is_file_size ? 'file-size' : null;
20
+ } );
@@ -0,0 +1,28 @@
1
+ /**
2
+ * This plug-in will strip out non-numeric formatting characters such that a
3
+ * formatted number (for example 1,000,000) can be detected automatically and
4
+ * sorted numerically. Note that characters a-z are not automatically removed,
5
+ * otherwise there is a risk of detecting columns as numeric which should not
6
+ * be.
7
+ *
8
+ * DataTables 1.10+ has formatted number type detection and sorting abilities
9
+ * built-in. As such this plug-in is marked as deprecated, but might be useful
10
+ * when working with old versions of DataTables.
11
+ *
12
+ * @name Formatted numbers
13
+ * @summary formatted_numbers
14
+ * @deprecated
15
+ * @author [Allan Jardine](http://sprymedia.co.uk)
16
+ */
17
+
18
+ jQuery.fn.dataTableExt.aTypes.unshift(
19
+ function ( sData )
20
+ {
21
+ var deformatted = sData.replace(/[^\d\-\.\/a-zA-Z]/g,'');
22
+ var isNumeric = !isNaN( deformatted - parseFloat( deformatted ) );
23
+
24
+ return isNumeric || deformatted === "-" ?
25
+ 'formatted-num' :
26
+ null;
27
+ }
28
+ );
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Automatically detect IP addresses in dot notation. Goes perfectly with the
3
+ * IP address sorting function.
4
+ *
5
+ * @name IP address detection
6
+ * @summary Detect data which is in IP address notation
7
+ * @author Brad Wasson
8
+ */
9
+
10
+ jQuery.fn.dataTableExt.aTypes.unshift(
11
+ function ( sData )
12
+ {
13
+ if (/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(sData)) {
14
+ return 'ip-address';
15
+ }
16
+ return null;
17
+ }
18
+ );
@@ -0,0 +1,56 @@
1
+ /**
2
+ * This type-detection plug-in will look at an HTML string from a data cell,
3
+ * strip the HTML tags and then check to see if the remaining data is numeric.
4
+ * If it is, then the data can be sorted numerically with the Numbers with HTML
5
+ * sorting plug-in.
6
+ *
7
+ * DataTables 1.10+ has numeric HTML data type and sorting abilities built-in.
8
+ * As such this plug-in is marked as deprecated, but might be useful when
9
+ * working with old versions of DataTables.
10
+ *
11
+ * @name Numbers with HTML
12
+ * @summary Detect data which is a mix of HTML and numeric data.
13
+ * @deprecated
14
+ * @author [Allan Jardine](http://sprymedia.co.uk)
15
+ */
16
+
17
+ jQuery.fn.dataTableExt.aTypes.unshift( function ( sData )
18
+ {
19
+ sData = typeof sData.replace == 'function' ?
20
+ sData.replace( /<[\s\S]*?>/g, "" ) : sData;
21
+ sData = $.trim(sData);
22
+
23
+ var sValidFirstChars = "0123456789-";
24
+ var sValidChars = "0123456789.";
25
+ var Char;
26
+ var bDecimal = false;
27
+
28
+ /* Check for a valid first char (no period and allow negatives) */
29
+ Char = sData.charAt(0);
30
+ if (sValidFirstChars.indexOf(Char) == -1)
31
+ {
32
+ return null;
33
+ }
34
+
35
+ /* Check all the other characters are valid */
36
+ for ( var i=1 ; i<sData.length ; i++ )
37
+ {
38
+ Char = sData.charAt(i);
39
+ if (sValidChars.indexOf(Char) == -1)
40
+ {
41
+ return null;
42
+ }
43
+
44
+ /* Only allowed one decimal place... */
45
+ if ( Char == "." )
46
+ {
47
+ if ( bDecimal )
48
+ {
49
+ return null;
50
+ }
51
+ bDecimal = true;
52
+ }
53
+ }
54
+
55
+ return 'num-html';
56
+ } );
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Automatically detect numbers which use a comma in the place of a decimal
3
+ * point to allow them to be sorted numerically.
4
+ *
5
+ * Please note that the 'Formatted numbers' type detection and sorting plug-ins
6
+ * offer greater flexibility that this plug-in and should be used in preference
7
+ * to this method.
8
+ *
9
+ * @name Commas for decimal place
10
+ * @summary Detect numeric data which uses a comma as the decimal place.
11
+ * @deprecated
12
+ * @author [Allan Jardine](http://sprymedia.co.uk)
13
+ */
14
+
15
+ jQuery.fn.dataTableExt.aTypes.unshift(
16
+ function ( sData )
17
+ {
18
+ var sValidChars = "0123456789,.";
19
+ var Char;
20
+ var bDecimal = false;
21
+ var iStart=0;
22
+
23
+ /* Negative sign is valid - shift the number check start point */
24
+ if ( sData.charAt(0) === '-' ) {
25
+ iStart = 1;
26
+ }
27
+
28
+ /* Check the numeric part */
29
+ for ( var i=iStart ; i<sData.length ; i++ )
30
+ {
31
+ Char = sData.charAt(i);
32
+ if (sValidChars.indexOf(Char) == -1)
33
+ {
34
+ return null;
35
+ }
36
+ }
37
+
38
+ return 'numeric-comma';
39
+ }
40
+ );
@@ -39,7 +39,7 @@ div.dataTables_wrapper {
39
39
  }
40
40
 
41
41
  select {
42
- width: 75px;
42
+ width: auto;
43
43
  display: inline-block;
44
44
  }
45
45
  }
@@ -76,7 +76,7 @@ div.dataTables_wrapper {
76
76
  }
77
77
 
78
78
  div.dataTables_filter {
79
- input {
79
+ span.input {
80
80
  margin-left: 0.5em;
81
81
  }
82
82
  }
@@ -0,0 +1,53 @@
1
+ div.alphabet {
2
+ clear:both;
3
+ position:relative;
4
+ margin:0.5em 0;
5
+ }
6
+
7
+ @media screen and (max-width:767px){
8
+ div.alphabet {
9
+ text-align:center;
10
+ }
11
+ }
12
+
13
+ div.alphabet ul.pagination {
14
+ margin:0;
15
+ }
16
+
17
+ div.alphabet ul.pagination > li {
18
+ display:inline-block;
19
+ }
20
+
21
+ div.alphabet a span {
22
+ opacity:1;
23
+ }
24
+
25
+ div.alphabet a.empty span {
26
+ opacity:0.3;
27
+ }
28
+
29
+ div.alphabet a.empty.active span {
30
+ opacity:1;
31
+ }
32
+
33
+ div.alphabet .alphabet-info-display {
34
+ vertical-align:top;
35
+ margin-right:0.5em;
36
+ }
37
+
38
+ div.alphabet div.alphabet-info {
39
+ position:absolute;
40
+ background-color:#111;
41
+ border-radius:3px;
42
+ color:#FFF;
43
+ margin-top:0.2em;
44
+ padding:0.2em 0.4em;
45
+ text-align:center;
46
+ opacity:0;
47
+ transition:opacity .4s ease-in-out;
48
+ z-index:9999;
49
+ }
50
+
51
+ tr.alphabet-group, tr.alphabet-group:hover {
52
+ background-color:rgba(0,0,0,0.15) !important;
53
+ }
@@ -0,0 +1,83 @@
1
+ div.alphabet {
2
+ clear:both;
3
+ position:relative;
4
+ margin:0.5em 0;
5
+ }
6
+
7
+ @media screen and (max-width:640px){
8
+ div.alphabet {
9
+ text-align:center;
10
+ }
11
+ }
12
+
13
+ div.alphabet ul {
14
+ display:inline-block;
15
+ margin:0;
16
+ padding:0;
17
+ list-style:none;
18
+ }
19
+
20
+ div.alphabet li {
21
+ display:inline-block;
22
+ }
23
+
24
+ div.alphabet a {
25
+ display:inline-block;
26
+ cursor:pointer;
27
+ text-align:center;
28
+ text-decoration:none;
29
+ box-sizing:content-box;
30
+ padding:0.2em 0.1em;
31
+ min-width:1.3em;
32
+ color:#333 !important;
33
+ border:1px solid transparent;
34
+ border-radius:2px;
35
+ }
36
+
37
+ div.alphabet a:hover {
38
+ color:#FFF !important;
39
+ border:1px solid #111;
40
+ background-color:#585858;
41
+ background:linear-gradient(to bottom, #585858 0%, #111 100%);
42
+ }
43
+
44
+ div.alphabet a:active {
45
+ outline:none;
46
+ background-color:#2b2b2b;
47
+ background:linear-gradient(to bottom, #2b2b2b 0%, #0c0c0c 100%);
48
+ box-shadow:inset 0 0 3px #111;
49
+ }
50
+
51
+ div.alphabet a.empty {
52
+ color:#888 !important;
53
+ }
54
+
55
+ div.alphabet a.active,
56
+ div.alphabet a.active.empty {
57
+ color:#333 !important;
58
+ border:1px solid #979797;
59
+ background-color:#FFF;
60
+ background:linear-gradient(to bottom, #fff 0%, #dcdcdc 100%)
61
+ }
62
+
63
+ div.alphabet .alphabet-info-display {
64
+ margin-right:0.5em;
65
+ }
66
+
67
+ div.alphabet div.alphabet-info {
68
+ position:absolute;
69
+ border:1px solid #111;
70
+ background-color:#585858;
71
+ background:linear-gradient(to bottom, #585858 0%, #111 100%);
72
+ border-radius:2px;
73
+ color:#FFF;
74
+ margin-top:0.2em;
75
+ padding:0.2em 0.4em;
76
+ text-align:center;
77
+ opacity:0;
78
+ z-index:9999;
79
+ }
80
+
81
+ tr.alphabet-group, tr.alphabet-group:hover {
82
+ background-color:rgba(0,0,0,0.15) !important;
83
+ }