jsxgrid 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +2329 -0
  3. package/dist/fields/jsgrid.field.XDateTimeField.min.js +6 -0
  4. package/dist/fields/jsgrid.field.XRowSelectField.min.js +6 -0
  5. package/dist/fields/jsgrid.field.Xcheckbox.min.js +6 -0
  6. package/dist/fields/jsgrid.field.XimgField.min.js +6 -0
  7. package/dist/fields/jsgrid.field.Xjsoneditor.min.js +6 -0
  8. package/dist/fields/jsgrid.field.Xselect.min.js +6 -0
  9. package/dist/fields/jsgrid.field.Xtextarea.min.js +6 -0
  10. package/dist/fields/lib/jsGridSummaryPlugin.min.js +6 -0
  11. package/dist/fields/lib/jsgrid.popup.basic.min.js +6 -0
  12. package/dist/i18n/jsgrid-Ko.js +46 -0
  13. package/dist/i18n/jsgrid-cs.js +46 -0
  14. package/dist/i18n/jsgrid-de.js +46 -0
  15. package/dist/i18n/jsgrid-el.js +46 -0
  16. package/dist/i18n/jsgrid-es.js +46 -0
  17. package/dist/i18n/jsgrid-fa.js +46 -0
  18. package/dist/i18n/jsgrid-fr.js +47 -0
  19. package/dist/i18n/jsgrid-he.js +46 -0
  20. package/dist/i18n/jsgrid-it.js +47 -0
  21. package/dist/i18n/jsgrid-ja.js +46 -0
  22. package/dist/i18n/jsgrid-ka.js +46 -0
  23. package/dist/i18n/jsgrid-lt.js +47 -0
  24. package/dist/i18n/jsgrid-pl.js +62 -0
  25. package/dist/i18n/jsgrid-pt-br.js +46 -0
  26. package/dist/i18n/jsgrid-pt.js +46 -0
  27. package/dist/i18n/jsgrid-ru.js +47 -0
  28. package/dist/i18n/jsgrid-tr.js +47 -0
  29. package/dist/i18n/jsgrid-zh-cn.js +46 -0
  30. package/dist/i18n/jsgrid-zh-tw.js +46 -0
  31. package/dist/icons-2x.png +0 -0
  32. package/dist/icons.png +0 -0
  33. package/dist/jsxgrid-fields.js +606 -0
  34. package/dist/jsxgrid-fields.min.js +6 -0
  35. package/dist/jsxgrid-theme.css +258 -0
  36. package/dist/jsxgrid-theme.min.css +1 -0
  37. package/dist/jsxgrid-xfields.js +979 -0
  38. package/dist/jsxgrid-xfields.min.js +6 -0
  39. package/dist/jsxgrid.css +126 -0
  40. package/dist/jsxgrid.js +2137 -0
  41. package/dist/jsxgrid.min.css +1 -0
  42. package/dist/jsxgrid.min.js +6 -0
  43. package/package.json +57 -0
  44. package/src/fields/jsgrid.field.XDateTimeField.js +122 -0
  45. package/src/fields/jsgrid.field.XRowSelectField.js +62 -0
  46. package/src/fields/jsgrid.field.Xcheckbox.js +108 -0
  47. package/src/fields/jsgrid.field.XimgField.js +99 -0
  48. package/src/fields/jsgrid.field.Xjsoneditor.js +165 -0
  49. package/src/fields/jsgrid.field.Xselect.js +176 -0
  50. package/src/fields/jsgrid.field.Xtextarea.js +97 -0
  51. package/src/fields/jsgrid.field.checkbox.js +97 -0
  52. package/src/fields/jsgrid.field.control.js +224 -0
  53. package/src/fields/jsgrid.field.number.js +41 -0
  54. package/src/fields/jsgrid.field.select.js +130 -0
  55. package/src/fields/jsgrid.field.text.js +69 -0
  56. package/src/fields/jsgrid.field.textarea.js +34 -0
  57. package/src/i18n/Ko.js +46 -0
  58. package/src/i18n/cs.js +46 -0
  59. package/src/i18n/de.js +46 -0
  60. package/src/i18n/el.js +46 -0
  61. package/src/i18n/es.js +46 -0
  62. package/src/i18n/fa.js +46 -0
  63. package/src/i18n/fr.js +47 -0
  64. package/src/i18n/he.js +46 -0
  65. package/src/i18n/it.js +47 -0
  66. package/src/i18n/ja.js +46 -0
  67. package/src/i18n/ka.js +46 -0
  68. package/src/i18n/lt.js +47 -0
  69. package/src/i18n/pl.js +62 -0
  70. package/src/i18n/pt-br.js +46 -0
  71. package/src/i18n/pt.js +46 -0
  72. package/src/i18n/ru.js +47 -0
  73. package/src/i18n/tr.js +47 -0
  74. package/src/i18n/zh-cn.js +46 -0
  75. package/src/i18n/zh-tw.js +46 -0
  76. package/src/jsgrid.core.js +1655 -0
  77. package/src/jsgrid.field.js +74 -0
  78. package/src/jsgrid.load-indicator.js +82 -0
  79. package/src/jsgrid.load-strategies.js +131 -0
  80. package/src/jsgrid.sort-strategies.js +49 -0
  81. package/src/jsgrid.validation.js +135 -0
  82. package/src/lib/jsGridSummaryPlugin.js +37 -0
  83. package/src/lib/jsgrid.popup.basic.js +107 -0
@@ -0,0 +1,165 @@
1
+ (function(jsGrid, $, undefined) {
2
+
3
+ // Standalone: does not extend jsGrid.TextAreaField, only jsGrid.Field.
4
+
5
+ var Field = jsGrid.Field;
6
+
7
+ var Xjsoneditor = function (config) {
8
+ Field.call(this, config);
9
+ };
10
+
11
+ Xjsoneditor.prototype = new Field({
12
+ autosearch: true,
13
+ readOnly: false,
14
+ templates: [],
15
+ closeText: 'Save',
16
+ editText: "Editor",
17
+ defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
18
+
19
+ filterTemplate: function () {
20
+ if (!this.filtering)
21
+ return "";
22
+
23
+ var grid = this._grid,
24
+ $result = this.filterControl = this._createTextBox();
25
+
26
+ if (this.autosearch) {
27
+ $result.on("keypress", function (e) {
28
+ if (e.which === 13) {
29
+ grid.search();
30
+ e.preventDefault();
31
+ }
32
+ });
33
+ }
34
+
35
+ if (this.defaultSelected !== null) {
36
+ $result.val(this.defaultSelected);
37
+ this.defaultSelected = null;
38
+ }
39
+
40
+ return $result;
41
+ },
42
+
43
+ filterValue: function () {
44
+ return this.filterControl.val();
45
+ },
46
+
47
+ insertValue: function () {
48
+ return this.insertControl.val();
49
+ },
50
+
51
+ editValue: function () {
52
+ return this.editControl.val();
53
+ },
54
+
55
+ _createTextBox: function () {
56
+ return $("<input>").attr("type", "text")
57
+ .prop("readonly", !!this.readOnly);
58
+ },
59
+
60
+ _doModal: function (formContent, options, resultControl) {
61
+ return jsGrid.popup(formContent, options);
62
+ },
63
+
64
+ _createJsonEditor: function (json, mode) {
65
+ if (typeof JSONEditor === 'undefined') {
66
+ throw new Error("Xjsoneditor requires the 'jsoneditor' package to be loaded on the page.");
67
+ }
68
+
69
+ json = json || {};
70
+ if (typeof json !== 'object') {
71
+ json = JSON.parse(json);
72
+ }
73
+
74
+ var container = $('<div style="height: 500px;">');
75
+ $('body').append(container);
76
+ container = container[0];
77
+ var options = {
78
+ templates: this.templates,
79
+ modes: ['code', 'text', 'tree'], // allowed modes
80
+ onError: function (err) {
81
+ alert(err.toString());
82
+ },
83
+ mode: mode || 'view'
84
+ };
85
+
86
+ return new JSONEditor(container, options, json);
87
+ },
88
+
89
+ itemTemplate: function (value, item) {
90
+ var f = this;
91
+
92
+ return $("<button>" + f.editText + "</button>").click(function () {
93
+ var editor = f._createJsonEditor(value);
94
+ f._doModal(editor.container, {
95
+ onClose: function () {
96
+ $(editor.container).remove();
97
+ editor.destroy();
98
+ }
99
+ });
100
+ return false;
101
+ });
102
+ },
103
+ insertTemplate: function () {
104
+ if (!this.inserting)
105
+ return "";
106
+
107
+ var f = this;
108
+
109
+ return this.insertControl = $("<textarea>").click(function () {
110
+ var editor = f._createJsonEditor({}, 'tree');
111
+ var ta = $(this);
112
+
113
+ f._doModal(editor.container, {
114
+ closeText: f.closeText,
115
+ onClose: function () {
116
+
117
+ var json = editor.get();
118
+ if (!$.isEmptyObject(json)) {
119
+ ta.val(JSON.stringify(json));
120
+ } else {
121
+ ta.val({});
122
+ }
123
+ editor.destroy();
124
+
125
+ }
126
+ });
127
+ return false;
128
+ });
129
+
130
+ },
131
+ editTemplate: function (value) {
132
+ if (!this.editing)
133
+ return this.itemTemplate.apply(this, arguments);
134
+
135
+
136
+ var f = this;
137
+
138
+ return this.editControl = $("<textarea>").val(value).click(function () {
139
+ var ta = $(this);
140
+ var editor = f._createJsonEditor(ta.val(), 'tree');
141
+
142
+
143
+ f._doModal(editor.container, {
144
+ closeText: f.closeText,
145
+ onClose: function () {
146
+
147
+ var json = editor.get();
148
+ if (!$.isEmptyObject(json)) {
149
+ ta.val(JSON.stringify(json));
150
+ } else {
151
+ ta.val({});
152
+ }
153
+ editor.destroy();
154
+
155
+ }
156
+ });
157
+ return false;
158
+ });
159
+ }
160
+
161
+ });
162
+
163
+ jsGrid.fields.Xjsoneditor = Xjsoneditor;
164
+
165
+ }(jsGrid, jQuery));
@@ -0,0 +1,176 @@
1
+ (function(jsGrid, $, undefined) {
2
+
3
+ // Standalone: does not extend jsGrid.SelectField, only jsGrid.Field.
4
+
5
+ var Field = jsGrid.Field;
6
+ var NUMBER_VALUE_TYPE = "number";
7
+
8
+ var Xselect = function (config) {
9
+ this.items = [];
10
+ this.selectedIndex = -1;
11
+ this.valueField = "";
12
+ this.textField = "";
13
+
14
+ if (config.valueField && config.items && config.items.length) {
15
+ var firstItemValue = config.items[0][config.valueField];
16
+ this.valueType = (typeof firstItemValue) === NUMBER_VALUE_TYPE ? NUMBER_VALUE_TYPE : "string";
17
+ }
18
+
19
+ this.sorter = this.valueType;
20
+
21
+ Field.call(this, config);
22
+ };
23
+
24
+ Xselect.prototype = new Field({
25
+ align: "center",
26
+ autosearch: true,
27
+ valueType: NUMBER_VALUE_TYPE,
28
+ pseudoElement: null,//pseudoElement that will be unsifted to start of select data in filters
29
+ select2: null,
30
+ defaultSelected: null,
31
+
32
+ itemTemplate: function (value) {
33
+ var items = this.items,
34
+ valueField = this.valueField,
35
+ textField = this.textField,
36
+ resultItem;
37
+
38
+ if (valueField) {
39
+ if (typeof(value) === "object") {
40
+ resultItem = value;
41
+ } else {
42
+ resultItem = $.grep(items, function (item) {
43
+ return item[valueField] === value;
44
+ })[0] || {};
45
+ }
46
+ } else {
47
+ resultItem = items[value];
48
+ }
49
+
50
+ var result = (textField ? resultItem[textField] : resultItem);
51
+
52
+ return (result === undefined || result === null) ? "" : result;
53
+ },
54
+
55
+ insertTemplate: function () {
56
+ if (!this.inserting)
57
+ return "";
58
+
59
+ return this.insertControl = this._createSelect();
60
+ },
61
+
62
+ editTemplate: function (value) {
63
+ if (!this.editing)
64
+ return this.itemTemplate.apply(this, arguments);
65
+
66
+ var $result = this.editControl = this._createSelect();
67
+ var editValue = value;
68
+ if (typeof(value) === "object") {
69
+ editValue = value[this.valueField];
70
+ }
71
+ (editValue !== undefined) && $result.val(editValue);
72
+ return $result;
73
+ },
74
+
75
+ insertValue: function () {
76
+ var val = this.insertControl.val();
77
+ return this.valueType === NUMBER_VALUE_TYPE ? parseInt(val || 0, 10) : val;
78
+ },
79
+
80
+ editValue: function () {
81
+ var val = this.editControl.val();
82
+ return this.valueType === NUMBER_VALUE_TYPE ? parseInt(val || 0, 10) : val;
83
+ },
84
+
85
+ filterTemplate: function () {
86
+ if (!this.filtering)
87
+ return "";
88
+ var data;
89
+ if (Array.isArray(this.items)) {
90
+ data = this.items.slice(0);
91
+ if (this.pseudoElement) {
92
+ data.unshift(this.pseudoElement);
93
+ } else {
94
+ var d = {};
95
+ d[this.textField] = '';
96
+ d[this.valueField] = null;
97
+ data.unshift(d);
98
+ }
99
+ } else if (typeof this.items === 'object') {
100
+ data = Object.assign({}, this.items);
101
+ if ((typeof this.pseudoElement === 'object') && this.pseudoElement) {
102
+ data = Object.assign({}, data, this.pseudoElement);
103
+ } else {
104
+ data = Object.assign({}, {'': null}, data);
105
+ }
106
+ }
107
+ if (this.defaultSelected !== null) {
108
+ var valueField = this.valueField;
109
+ var targetValue = this.defaultSelected;
110
+ var foundIndex = -1;
111
+
112
+ $.each(data, function (index, item) {
113
+ var value = valueField ? item[valueField] : index;
114
+ if (value == targetValue) {
115
+ foundIndex = index;
116
+ return false;
117
+ }
118
+ });
119
+ if (foundIndex !== -1) {
120
+ this.selectedIndex = foundIndex;
121
+ }
122
+ this.defaultSelected = null;
123
+ }
124
+
125
+ var grid = this._grid,
126
+ $result = this.filterControl = this._createSelect(data);
127
+
128
+ if (this.autosearch) {
129
+ $result.on("change", function (e) {
130
+ grid.search();
131
+ });
132
+ }
133
+
134
+ return $result;
135
+ },
136
+
137
+ filterValue: function () {
138
+ var val = this.filterControl.val();
139
+ return this.valueType === NUMBER_VALUE_TYPE ? parseInt(val || 0, 10) : val;
140
+ },
141
+
142
+ _createSelect: function (data) {
143
+ var $result = $("<select>"),
144
+ valueField = this.valueField,
145
+ textField = this.textField,
146
+ selectedIndex = this.selectedIndex;
147
+
148
+ $.each((data || this.items), function (index, item) {
149
+ var value = valueField ? item[valueField] : index,
150
+ text = textField ? item[textField] : item;
151
+
152
+ var $option = $("<option>")
153
+ .attr("value", value)
154
+ .text(text)
155
+ .appendTo($result);
156
+
157
+ $option.prop("selected", (selectedIndex === index));
158
+ });
159
+
160
+ $result.prop("disabled", !!this.readOnly);
161
+
162
+ if(this.select2){
163
+ var s2 = Object.assign({}, this.select2, {width: '100%'});
164
+ setTimeout(function() {
165
+ $result.select2(s2);
166
+ }, 0);
167
+ }
168
+
169
+ return $result;
170
+ }
171
+
172
+ });
173
+
174
+ jsGrid.fields.Xselect = Xselect;
175
+
176
+ }(jsGrid, jQuery));
@@ -0,0 +1,97 @@
1
+ (function(jsGrid, $, undefined) {
2
+
3
+ // Standalone: does not extend jsGrid.TextAreaField, only jsGrid.Field.
4
+
5
+ var Field = jsGrid.Field;
6
+
7
+ var Xtextarea = function (config) {
8
+ Field.call(this, config);
9
+ };
10
+
11
+ Xtextarea.prototype = new Field({
12
+ autosearch: true,
13
+ readOnly: false,
14
+ maxShowSymbols: 50,
15
+ defaultSelected: null,//value to preset the filter input with, applied once on first filter render then reset
16
+
17
+ filterTemplate: function () {
18
+ if (!this.filtering)
19
+ return "";
20
+
21
+ var grid = this._grid,
22
+ $result = this.filterControl = this._createTextBox();
23
+
24
+ if (this.autosearch) {
25
+ $result.on("keypress", function (e) {
26
+ if (e.which === 13) {
27
+ grid.search();
28
+ e.preventDefault();
29
+ }
30
+ });
31
+ }
32
+
33
+ if (this.defaultSelected !== null) {
34
+ $result.val(this.defaultSelected);
35
+ this.defaultSelected = null;
36
+ }
37
+
38
+ return $result;
39
+ },
40
+
41
+ filterValue: function () {
42
+ return this.filterControl.val();
43
+ },
44
+
45
+ insertTemplate: function () {
46
+ if (!this.inserting)
47
+ return "";
48
+
49
+ return this.insertControl = this._createTextArea();
50
+ },
51
+
52
+ editTemplate: function (value) {
53
+ if (!this.editing)
54
+ return this.itemTemplate.apply(this, arguments);
55
+
56
+ var $result = this.editControl = this._createTextArea();
57
+ $result.val(value);
58
+ return $result;
59
+ },
60
+
61
+ insertValue: function () {
62
+ return this.insertControl.val();
63
+ },
64
+
65
+ editValue: function () {
66
+ return this.editControl.val();
67
+ },
68
+
69
+ _createTextBox: function () {
70
+ return $("<input>").attr("type", "text")
71
+ .prop("readonly", !!this.readOnly);
72
+ },
73
+
74
+ _createTextArea: function () {
75
+ return $("<textarea>").prop("readonly", !!this.readOnly);
76
+ },
77
+
78
+ itemTemplate: function (value, item) {
79
+ value = value == null ? '' : String(value);
80
+
81
+ if (value.length <= this.maxShowSymbols) {
82
+ return $("<div>").text(value);
83
+ }
84
+ var str = value.slice(0, this.maxShowSymbols);
85
+ var div = $("<div>").text(str + ' ...').one("click",function () {
86
+ div.text(value);
87
+ return false;
88
+ });
89
+
90
+ return div;
91
+ }
92
+
93
+ });
94
+
95
+ jsGrid.fields.Xtextarea = Xtextarea;
96
+
97
+ }(jsGrid, jQuery));
@@ -0,0 +1,97 @@
1
+ (function(jsGrid, $, undefined) {
2
+
3
+ var Field = jsGrid.Field;
4
+
5
+ function CheckboxField(config) {
6
+ Field.call(this, config);
7
+ }
8
+
9
+ CheckboxField.prototype = new Field({
10
+
11
+ sorter: "number",
12
+ align: "center",
13
+ autosearch: true,
14
+
15
+ itemTemplate: function(value) {
16
+ return this._createCheckbox().prop({
17
+ checked: value,
18
+ disabled: true
19
+ });
20
+ },
21
+
22
+ filterTemplate: function() {
23
+ if(!this.filtering)
24
+ return "";
25
+
26
+ var grid = this._grid,
27
+ $result = this.filterControl = this._createCheckbox();
28
+
29
+ $result.prop({
30
+ readOnly: true,
31
+ indeterminate: true
32
+ });
33
+
34
+ $result.on("click", function() {
35
+ var $cb = $(this);
36
+
37
+ if($cb.prop("readOnly")) {
38
+ $cb.prop({
39
+ checked: false,
40
+ readOnly: false
41
+ });
42
+ }
43
+ else if(!$cb.prop("checked")) {
44
+ $cb.prop({
45
+ readOnly: true,
46
+ indeterminate: true
47
+ });
48
+ }
49
+ });
50
+
51
+ if(this.autosearch) {
52
+ $result.on("click", function() {
53
+ grid.search();
54
+ });
55
+ }
56
+
57
+ return $result;
58
+ },
59
+
60
+ insertTemplate: function() {
61
+ if(!this.inserting)
62
+ return "";
63
+
64
+ return this.insertControl = this._createCheckbox();
65
+ },
66
+
67
+ editTemplate: function(value) {
68
+ if(!this.editing)
69
+ return this.itemTemplate.apply(this, arguments);
70
+
71
+ var $result = this.editControl = this._createCheckbox();
72
+ $result.prop("checked", value);
73
+ return $result;
74
+ },
75
+
76
+ filterValue: function() {
77
+ return this.filterControl.get(0).indeterminate
78
+ ? undefined
79
+ : this.filterControl.is(":checked");
80
+ },
81
+
82
+ insertValue: function() {
83
+ return this.insertControl.is(":checked");
84
+ },
85
+
86
+ editValue: function() {
87
+ return this.editControl.is(":checked");
88
+ },
89
+
90
+ _createCheckbox: function() {
91
+ return $("<input>").attr("type", "checkbox");
92
+ }
93
+ });
94
+
95
+ jsGrid.fields.checkbox = jsGrid.CheckboxField = CheckboxField;
96
+
97
+ }(jsGrid, jQuery));