inviton-powerduck 0.0.136 → 0.0.138

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 (39) hide show
  1. package/app/powerduck-system-resources.ts +2 -0
  2. package/common/css/ladda-themeless-zoomin.min.css +89 -89
  3. package/common/dialog-utils.ts +1 -1
  4. package/common/external-barcode-scanner.ts +0 -1
  5. package/common/utils/array-extend.ts +32 -29
  6. package/common/utils/broswer-image-compression.ts +1 -1
  7. package/common/utils/language-utils.ts +3 -1
  8. package/components/app/vue-plugin-jsxtransform.ts +1 -1
  9. package/components/bootstrap-toggle/index.tsx +6 -1
  10. package/components/chart-js/pie-chart.tsx +1 -1
  11. package/components/chart-js/thirdparty/flot/jquery.flot.categories.min.js +93 -93
  12. package/components/chart-js/thirdparty/flot/jquery.flot.crosshair.min.js +83 -83
  13. package/components/chart-js/thirdparty/flot/jquery.flot.navigate.min.js +270 -270
  14. package/components/chart-js/thirdparty/flot/jquery.flot.pie.min.js +507 -507
  15. package/components/chart-js/thirdparty/flot/jquery.flot.resize.min.js +147 -147
  16. package/components/chart-js/thirdparty/flot/jquery.flot.stack.min.js +104 -104
  17. package/components/datatable/datatable-static.tsx +5 -5
  18. package/components/datatable/datatable.tsx +1 -1
  19. package/components/datatable/ts/reorder.ts +0 -2
  20. package/components/dropdown/currency-code-picker.tsx +42 -39
  21. package/components/dropdown/index.tsx +2 -1
  22. package/components/fullcalendar/timegrid-calendar.tsx +1 -1
  23. package/components/image-crop/image-cropping-modal.tsx +54 -15
  24. package/components/image-crop/upload-and-crop.tsx +21 -13
  25. package/components/image-crop/vendor/jquery.Jcrop.min.css +344 -344
  26. package/components/import/import-mapper.tsx +231 -231
  27. package/components/input/localized-info-input.tsx +9 -0
  28. package/components/input/localized-string-input.tsx +21 -0
  29. package/components/input/localized-string-textarea.tsx +16 -0
  30. package/components/input/localized-string-wysiwyg.tsx +16 -0
  31. package/components/input/plugins/daterangepicker/daterangepicker.min.css +400 -400
  32. package/components/input/plugins/daterangepicker/jquery.daterangepicker.min.js +1903 -1903
  33. package/components/input/translate.tsx +100 -0
  34. package/components/modal/modal.tsx +1 -1
  35. package/components/photos/photo-manager.tsx +7 -11
  36. package/components/share/share-modal.tsx +1 -1
  37. package/components/share/share.tsx +1 -1
  38. package/components/svg/skilift-svg.tsx +6 -6
  39. package/package.json +2 -1
@@ -50,6 +50,7 @@ export interface IPowerduckSystemResources {
50
50
  quickEdit: string;
51
51
  quickEditItemsCount: string;
52
52
  quickEditErrorNamed: string;
53
+ translateFromThisLanguage: string;
53
54
 
54
55
  languageSK: string;
55
56
  languageEN: string;
@@ -76,6 +77,7 @@ export interface IPowerduckSystemResources {
76
77
  validationErrorIpAddress: string;
77
78
  validationErrorMacAddress: string;
78
79
  validationErrorGeneric: string;
80
+ uploadImageInvalidFileType: string;
79
81
 
80
82
  signInGoogle: string;
81
83
  signInFacebook: string;
@@ -1,89 +1,89 @@
1
- /*! Ladda http://lab.hakim.se/ladda MIT licensed Copyright (C) 2016 Hakim El Hattab, http://hakim.se ....Lightweight adaptation for Inviton API needs*/
2
- .ladda-button {
3
- position: relative;
4
- }
5
- .ladda-button .ladda-spinner {
6
- position: absolute;
7
- z-index: 2;
8
- display: inline-block;
9
- width: 32px;
10
- height: 32px;
11
- top: 50%;
12
- margin-top: 0;
13
- opacity: 0;
14
- pointer-events: none;
15
- }
16
- .ladda-button .ladda-label {
17
- position: relative;
18
- z-index: 3;
19
- }
20
- .ladda-button .ladda-progress {
21
- position: absolute;
22
- width: 0;
23
- height: 100%;
24
- left: 0;
25
- top: 0;
26
- background: rgba(0, 0, 0, 0.2);
27
- visibility: hidden;
28
- opacity: 0;
29
- -webkit-transition: 0.1s linear all !important;
30
- -moz-transition: 0.1s linear all !important;
31
- -ms-transition: 0.1s linear all !important;
32
- -o-transition: 0.1s linear all !important;
33
- transition: 0.1s linear all !important;
34
- }
35
- .ladda-button[data-loading] .ladda-progress {
36
- opacity: 1;
37
- visibility: visible;
38
- }
39
- .ladda-button,
40
- .ladda-button .ladda-label,
41
- .ladda-button .ladda-spinner {
42
- -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
43
- -moz-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
44
- -ms-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
45
- -o-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
46
- transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
47
- }
48
- .ladda-button[data-style="zoom-in"],
49
- .ladda-button[data-style="zoom-in"] .ladda-label,
50
- .ladda-button[data-style="zoom-in"] .ladda-spinner {
51
- -webkit-transition: 0.3s ease all !important;
52
- -moz-transition: 0.3s ease all !important;
53
- -ms-transition: 0.3s ease all !important;
54
- -o-transition: 0.3s ease all !important;
55
- transition: 0.3s ease all !important;
56
- }
57
- .ladda-button[data-style="zoom-in"] {
58
- overflow: hidden;
59
- }
60
- .ladda-button[data-style="zoom-in"] .ladda-spinner {
61
- left: 50%;
62
- margin-left: -16px;
63
- -webkit-transform: scale(0.2);
64
- -moz-transform: scale(0.2);
65
- -ms-transform: scale(0.2);
66
- -o-transform: scale(0.2);
67
- transform: scale(0.2);
68
- }
69
- .ladda-button[data-style="zoom-in"] .ladda-label {
70
- position: relative;
71
- display: inline-block;
72
- }
73
- .ladda-button[data-style="zoom-in"][data-loading] .ladda-label {
74
- opacity: 0;
75
- -webkit-transform: scale(2.2);
76
- -moz-transform: scale(2.2);
77
- -ms-transform: scale(2.2);
78
- -o-transform: scale(2.2);
79
- transform: scale(2.2);
80
- }
81
- .ladda-button[data-style="zoom-in"][data-loading] .ladda-spinner {
82
- opacity: 1;
83
- margin-left: 0;
84
- -webkit-transform: none;
85
- -moz-transform: none;
86
- -ms-transform: none;
87
- -o-transform: none;
88
- transform: none;
89
- }
1
+ /*! Ladda http://lab.hakim.se/ladda MIT licensed Copyright (C) 2016 Hakim El Hattab, http://hakim.se ....Lightweight adaptation for Inviton API needs*/
2
+ .ladda-button {
3
+ position: relative;
4
+ }
5
+ .ladda-button .ladda-spinner {
6
+ position: absolute;
7
+ z-index: 2;
8
+ display: inline-block;
9
+ width: 32px;
10
+ height: 32px;
11
+ top: 50%;
12
+ margin-top: 0;
13
+ opacity: 0;
14
+ pointer-events: none;
15
+ }
16
+ .ladda-button .ladda-label {
17
+ position: relative;
18
+ z-index: 3;
19
+ }
20
+ .ladda-button .ladda-progress {
21
+ position: absolute;
22
+ width: 0;
23
+ height: 100%;
24
+ left: 0;
25
+ top: 0;
26
+ background: rgba(0, 0, 0, 0.2);
27
+ visibility: hidden;
28
+ opacity: 0;
29
+ -webkit-transition: 0.1s linear all !important;
30
+ -moz-transition: 0.1s linear all !important;
31
+ -ms-transition: 0.1s linear all !important;
32
+ -o-transition: 0.1s linear all !important;
33
+ transition: 0.1s linear all !important;
34
+ }
35
+ .ladda-button[data-loading] .ladda-progress {
36
+ opacity: 1;
37
+ visibility: visible;
38
+ }
39
+ .ladda-button,
40
+ .ladda-button .ladda-label,
41
+ .ladda-button .ladda-spinner {
42
+ -webkit-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
43
+ -moz-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
44
+ -ms-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
45
+ -o-transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
46
+ transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) all !important;
47
+ }
48
+ .ladda-button[data-style="zoom-in"],
49
+ .ladda-button[data-style="zoom-in"] .ladda-label,
50
+ .ladda-button[data-style="zoom-in"] .ladda-spinner {
51
+ -webkit-transition: 0.3s ease all !important;
52
+ -moz-transition: 0.3s ease all !important;
53
+ -ms-transition: 0.3s ease all !important;
54
+ -o-transition: 0.3s ease all !important;
55
+ transition: 0.3s ease all !important;
56
+ }
57
+ .ladda-button[data-style="zoom-in"] {
58
+ overflow: hidden;
59
+ }
60
+ .ladda-button[data-style="zoom-in"] .ladda-spinner {
61
+ left: 50%;
62
+ margin-left: -16px;
63
+ -webkit-transform: scale(0.2);
64
+ -moz-transform: scale(0.2);
65
+ -ms-transform: scale(0.2);
66
+ -o-transform: scale(0.2);
67
+ transform: scale(0.2);
68
+ }
69
+ .ladda-button[data-style="zoom-in"] .ladda-label {
70
+ position: relative;
71
+ display: inline-block;
72
+ }
73
+ .ladda-button[data-style="zoom-in"][data-loading] .ladda-label {
74
+ opacity: 0;
75
+ -webkit-transform: scale(2.2);
76
+ -moz-transform: scale(2.2);
77
+ -ms-transform: scale(2.2);
78
+ -o-transform: scale(2.2);
79
+ transform: scale(2.2);
80
+ }
81
+ .ladda-button[data-style="zoom-in"][data-loading] .ladda-spinner {
82
+ opacity: 1;
83
+ margin-left: 0;
84
+ -webkit-transform: none;
85
+ -moz-transform: none;
86
+ -ms-transform: none;
87
+ -o-transform: none;
88
+ transform: none;
89
+ }
@@ -267,7 +267,7 @@ export class DialogUtils {
267
267
  DialogIcons.Error,
268
268
  false,
269
269
  );
270
- console.log(modalSelector);
270
+ // console.log(modalSelector);
271
271
  modalContext.show();
272
272
  return modalSelector;
273
273
  }
@@ -240,7 +240,6 @@
240
240
 
241
241
  this._onKeyUp = function (e) {
242
242
  var value = e.which ? e.which : e.keyCode;
243
- console.log(value);
244
243
 
245
244
  if (value > 31) {
246
245
  clearTimeout(self._t);
@@ -1,6 +1,6 @@
1
1
  import { arraySort } from './array-sort';
2
2
 
3
- interface ArrayExtended<T> extends Array<T> {
3
+ export interface ArrayExtended<T> extends Array<T> {
4
4
  /**
5
5
  * Removes given items from the Array
6
6
  *
@@ -16,6 +16,11 @@ interface ArrayExtended<T> extends Array<T> {
16
16
  */
17
17
  insertAt: (item: T, index: number) => void;
18
18
 
19
+ /**
20
+ * Clones current array into new instance
21
+ */
22
+ clone: () => ArrayExtended<T>;
23
+
19
24
  /**
20
25
  * Sorts array by given property
21
26
  *
@@ -75,10 +80,10 @@ interface ArrayExtended<T> extends Array<T> {
75
80
  }
76
81
 
77
82
  if (!(Array.prototype as any).find) {
78
- (Array.prototype as any).find = function (callback) {
83
+ (Array.prototype as any).find = function (callback, ...args) {
79
84
  const list = new Object(this);
80
85
  const length = (list as any).length >>> 0;
81
- const thisArg = arguments[1];
86
+ const thisArg = args[0];
82
87
  for (let i = 0; i < length; i++) {
83
88
  const element = list[i];
84
89
  if (callback.call(
@@ -98,9 +103,9 @@ export const arrayExtend = <T>(arr: T[]): ArrayExtended<T> => {
98
103
  arr = [];
99
104
  }
100
105
 
101
- ((arr as any)).remove = function (items: []): void {
102
- for (let i = 0, len = arguments.length; i < len; i++) {
103
- const item = arguments[i];
106
+ ((arr as any)).remove = (items: [], ...args): void => {
107
+ for (let i = 0, len = args.length; i < len; i++) {
108
+ const item = args[i];
104
109
  const itemIndex = arr.indexOf(item);
105
110
 
106
111
  if (itemIndex > -1) {
@@ -109,7 +114,11 @@ export const arrayExtend = <T>(arr: T[]): ArrayExtended<T> => {
109
114
  }
110
115
  };
111
116
 
112
- ((arr as any)).insertAt = function (item, index) {
117
+ ((arr as any)).clone = function () {
118
+ return arrayExtend(this.slice(0));
119
+ };
120
+
121
+ ((arr as any)).insertAt = (item, index) => {
113
122
  arr.splice(
114
123
  index,
115
124
  0,
@@ -117,7 +126,7 @@ export const arrayExtend = <T>(arr: T[]): ArrayExtended<T> => {
117
126
  );
118
127
  };
119
128
 
120
- ((arr as any)).contains = function (item) {
129
+ ((arr as any)).contains = (item) => {
121
130
  if (item != null) {
122
131
  let idProp = 'Id';
123
132
  if (item[idProp] == null) {
@@ -137,7 +146,7 @@ export const arrayExtend = <T>(arr: T[]): ArrayExtended<T> => {
137
146
  return arr.includes(item);
138
147
  };
139
148
 
140
- ((arr as any)).min = function <T>(callbackfn: (value: T, index: number, array: T[]) => number, defaultValue?: number): number {
149
+ ((arr as any)).min = <T>(callbackfn: (value: T, index: number, array: T[]) => number, defaultValue?: number): number => {
141
150
  if (arr.length == 0) {
142
151
  return defaultValue;
143
152
  }
@@ -153,7 +162,7 @@ export const arrayExtend = <T>(arr: T[]): ArrayExtended<T> => {
153
162
  )), Number.MAX_VALUE);
154
163
  };
155
164
 
156
- ((arr as any)).max = function <T>(callbackfn: (value: T, index: number, array: T[]) => number, defaultValue?: number): number {
165
+ ((arr as any)).max = <T>(callbackfn: (value: T, index: number, array: T[]) => number, defaultValue?: number): number => {
157
166
  if (arr.length == 0) {
158
167
  return defaultValue;
159
168
  }
@@ -169,7 +178,7 @@ export const arrayExtend = <T>(arr: T[]): ArrayExtended<T> => {
169
178
  )), 0);
170
179
  };
171
180
 
172
- ((arr as any)).sum = function <T>(callbackfn: (value: T, index: number, array: T[]) => number, defaultValue?: number): number {
181
+ ((arr as any)).sum = <T>(callbackfn: (value: T, index: number, array: T[]) => number, defaultValue?: number): number => {
173
182
  if (arr.length == 0) {
174
183
  return defaultValue;
175
184
  }
@@ -185,28 +194,22 @@ export const arrayExtend = <T>(arr: T[]): ArrayExtended<T> => {
185
194
  ), 0);
186
195
  };
187
196
 
188
- ((arr as any)).selectMany = function (callback): any {
189
- return arr.reduce((
190
- prevVal,
197
+ ((arr as any)).selectMany = (callback): any => arr.reduce((
198
+ prevVal,
199
+ u,
200
+ i,
201
+ ) => [
202
+ ...prevVal,
203
+ ...(callback(
191
204
  u,
192
205
  i,
193
- ) => [
194
- ...prevVal,
195
- ...(callback(
196
- u,
197
- i,
198
- arr,
199
- ) as any),
200
- ], []);
201
- };
206
+ arr,
207
+ ) as any),
208
+ ], []);
202
209
 
203
- ((arr as any)).distinct = function (): any {
204
- return arr.reduce((un, u) => ({ ...un, u }), {});
205
- };
210
+ ((arr as any)).distinct = (): any => arr.reduce((un, u) => ({ ...un, u }), {});
206
211
 
207
- ((arr as any)).sortBy = function <T>(propName: string | ((item: T) => string | number)): ArrayExtended<T> {
208
- return arraySort(arr as any, propName) as any;
209
- };
212
+ ((arr as any)).sortBy = <T>(propName: string | ((item: T) => string | number)): ArrayExtended<T> => arraySort(arr as any, propName) as any;
210
213
 
211
214
  return arr as any;
212
215
  };
@@ -25,7 +25,7 @@ export class BrowserImageCompression {
25
25
  compressedImage.isCompressed = true;
26
26
  return compressedImage;
27
27
  } catch (error) {
28
- console.log(error);
28
+ console.error(error);
29
29
  return file;
30
30
  }
31
31
  }
@@ -25,7 +25,7 @@ export namespace LanguageUtils {
25
25
  return name;
26
26
  }
27
27
 
28
- export function getLanguageList(): Array<LanguageListItem> {
28
+ export function getLanguageList(sort?: boolean): Array<LanguageListItem> {
29
29
  const retVal = <Array<LanguageListItem>>[];
30
30
 
31
31
  const getLanguage = (langCode: Language): LanguageListItem => {
@@ -80,6 +80,7 @@ export namespace LanguageUtils {
80
80
  }
81
81
  }
82
82
 
83
+ if (sort === true) {
83
84
  try {
84
85
  retVal.sort((a, b) => {
85
86
  return a.text.localeCompare(b.text);
@@ -87,6 +88,7 @@ export namespace LanguageUtils {
87
88
  } catch (e) {
88
89
  arraySort(retVal, 'text');
89
90
  }
91
+ }
90
92
 
91
93
  LanguageUtils.getLanguageList = function () {
92
94
  return retVal;
@@ -22,7 +22,7 @@ export const VueJsxTransform = {
22
22
  }
23
23
 
24
24
  if (data?.onClick != null) {
25
- console.log(data);
25
+ console.error(data);
26
26
  (window as any).kurek = data;
27
27
  }
28
28
 
@@ -1,7 +1,7 @@
1
1
  import type { Validation } from '@vuelidate/core';
2
2
  import type { DropdownButtonItemArgs } from '../dropdown-button/dropdown-button-item';
3
3
  import type { FormItemWrapperArgs, MarginType } from '../form/form-item-wrapper';
4
- import { Prop, toNative } from 'vue-facing-decorator';
4
+ import { Prop, toNative, Watch } from 'vue-facing-decorator';
5
5
  import PowerduckState from '../../app/powerduck-state';
6
6
  import TsxComponent, { Component } from '../../app/vuetsx';
7
7
  import { isNullOrEmpty } from '../../common/utils/is-null-or-empty';
@@ -68,6 +68,11 @@ class BootstrapToggleComponent extends TsxComponent<BootstrapToggleArgs> impleme
68
68
 
69
69
  }
70
70
 
71
+ @Watch('value')
72
+ onValueChanged() {
73
+ this.$forceUpdate();
74
+ }
75
+
71
76
  getCaptionTrue(): string {
72
77
  return this.captionTrue || PowerduckState.getResourceValue('yes');
73
78
  }
@@ -84,7 +84,7 @@ class PieChartComponent extends TsxComponent<PieArgs> implements PieArgs {
84
84
  this.destroyChart();
85
85
 
86
86
  this.$nextTick(() => {
87
- console.log(this.getCanvasContext() == null);
87
+ // console.log(this.getCanvasContext() == null);
88
88
 
89
89
  this._chart = new Chart(this.getCanvasContext(), {
90
90
  type: this.type || PieChartType.Doughnut,
@@ -1,93 +1,93 @@
1
- /* Javascript plotting library for jQuery, version 0.8.3.
2
-
3
- Copyright (c) 2007-2014 IOLA and Ole Laursen.
4
- Licensed under the MIT license.
5
-
6
- */
7
- (function ($) {
8
- var options = { xaxis: { categories: null }, yaxis: { categories: null } };
9
- function processRawData(plot, series, data, datapoints) {
10
- var xCategories = series.xaxis.options.mode == "categories",
11
- yCategories = series.yaxis.options.mode == "categories";
12
- if (!(xCategories || yCategories)) return;
13
- var format = datapoints.format;
14
- if (!format) {
15
- var s = series;
16
- format = [];
17
- format.push({ x: true, number: true, required: true });
18
- format.push({ y: true, number: true, required: true });
19
- if (s.bars.show || (s.lines.show && s.lines.fill)) {
20
- var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
21
- format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
22
- if (s.bars.horizontal) {
23
- delete format[format.length - 1].y;
24
- format[format.length - 1].x = true;
25
- }
26
- }
27
- datapoints.format = format;
28
- }
29
- for (var m = 0; m < format.length; ++m) {
30
- if (format[m].x && xCategories) format[m].number = false;
31
- if (format[m].y && yCategories) format[m].number = false;
32
- }
33
- }
34
- function getNextIndex(categories) {
35
- var index = -1;
36
- for (var v in categories) if (categories[v] > index) index = categories[v];
37
- return index + 1;
38
- }
39
- function categoriesTickGenerator(axis) {
40
- var res = [];
41
- for (var label in axis.categories) {
42
- var v = axis.categories[label];
43
- if (v >= axis.min && v <= axis.max) res.push([v, label]);
44
- }
45
- res.sort(function (a, b) {
46
- return a[0] - b[0];
47
- });
48
- return res;
49
- }
50
- function setupCategoriesForAxis(series, axis, datapoints) {
51
- if (series[axis].options.mode != "categories") return;
52
- if (!series[axis].categories) {
53
- var c = {},
54
- o = series[axis].options.categories || {};
55
- if ($.isArray(o)) {
56
- for (var i = 0; i < o.length; ++i) c[o[i]] = i;
57
- } else {
58
- for (var v in o) c[v] = o[v];
59
- }
60
- series[axis].categories = c;
61
- }
62
- if (!series[axis].options.ticks) series[axis].options.ticks = categoriesTickGenerator;
63
- transformPointsOnAxis(datapoints, axis, series[axis].categories);
64
- }
65
- function transformPointsOnAxis(datapoints, axis, categories) {
66
- var points = datapoints.points,
67
- ps = datapoints.pointsize,
68
- format = datapoints.format,
69
- formatColumn = axis.charAt(0),
70
- index = getNextIndex(categories);
71
- for (var i = 0; i < points.length; i += ps) {
72
- if (points[i] == null) continue;
73
- for (var m = 0; m < ps; ++m) {
74
- var val = points[i + m];
75
- if (val == null || !format[m][formatColumn]) continue;
76
- if (!(val in categories)) {
77
- categories[val] = index;
78
- ++index;
79
- }
80
- points[i + m] = categories[val];
81
- }
82
- }
83
- }
84
- function processDatapoints(plot, series, datapoints) {
85
- setupCategoriesForAxis(series, "xaxis", datapoints);
86
- setupCategoriesForAxis(series, "yaxis", datapoints);
87
- }
88
- function init(plot) {
89
- plot.hooks.processRawData.push(processRawData);
90
- plot.hooks.processDatapoints.push(processDatapoints);
91
- }
92
- $.plot.plugins.push({ init: init, options: options, name: "categories", version: "1.0" });
93
- })(jQuery);
1
+ /* Javascript plotting library for jQuery, version 0.8.3.
2
+
3
+ Copyright (c) 2007-2014 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ */
7
+ (function ($) {
8
+ var options = { xaxis: { categories: null }, yaxis: { categories: null } };
9
+ function processRawData(plot, series, data, datapoints) {
10
+ var xCategories = series.xaxis.options.mode == "categories",
11
+ yCategories = series.yaxis.options.mode == "categories";
12
+ if (!(xCategories || yCategories)) return;
13
+ var format = datapoints.format;
14
+ if (!format) {
15
+ var s = series;
16
+ format = [];
17
+ format.push({ x: true, number: true, required: true });
18
+ format.push({ y: true, number: true, required: true });
19
+ if (s.bars.show || (s.lines.show && s.lines.fill)) {
20
+ var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
21
+ format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
22
+ if (s.bars.horizontal) {
23
+ delete format[format.length - 1].y;
24
+ format[format.length - 1].x = true;
25
+ }
26
+ }
27
+ datapoints.format = format;
28
+ }
29
+ for (var m = 0; m < format.length; ++m) {
30
+ if (format[m].x && xCategories) format[m].number = false;
31
+ if (format[m].y && yCategories) format[m].number = false;
32
+ }
33
+ }
34
+ function getNextIndex(categories) {
35
+ var index = -1;
36
+ for (var v in categories) if (categories[v] > index) index = categories[v];
37
+ return index + 1;
38
+ }
39
+ function categoriesTickGenerator(axis) {
40
+ var res = [];
41
+ for (var label in axis.categories) {
42
+ var v = axis.categories[label];
43
+ if (v >= axis.min && v <= axis.max) res.push([v, label]);
44
+ }
45
+ res.sort(function (a, b) {
46
+ return a[0] - b[0];
47
+ });
48
+ return res;
49
+ }
50
+ function setupCategoriesForAxis(series, axis, datapoints) {
51
+ if (series[axis].options.mode != "categories") return;
52
+ if (!series[axis].categories) {
53
+ var c = {},
54
+ o = series[axis].options.categories || {};
55
+ if ($.isArray(o)) {
56
+ for (var i = 0; i < o.length; ++i) c[o[i]] = i;
57
+ } else {
58
+ for (var v in o) c[v] = o[v];
59
+ }
60
+ series[axis].categories = c;
61
+ }
62
+ if (!series[axis].options.ticks) series[axis].options.ticks = categoriesTickGenerator;
63
+ transformPointsOnAxis(datapoints, axis, series[axis].categories);
64
+ }
65
+ function transformPointsOnAxis(datapoints, axis, categories) {
66
+ var points = datapoints.points,
67
+ ps = datapoints.pointsize,
68
+ format = datapoints.format,
69
+ formatColumn = axis.charAt(0),
70
+ index = getNextIndex(categories);
71
+ for (var i = 0; i < points.length; i += ps) {
72
+ if (points[i] == null) continue;
73
+ for (var m = 0; m < ps; ++m) {
74
+ var val = points[i + m];
75
+ if (val == null || !format[m][formatColumn]) continue;
76
+ if (!(val in categories)) {
77
+ categories[val] = index;
78
+ ++index;
79
+ }
80
+ points[i + m] = categories[val];
81
+ }
82
+ }
83
+ }
84
+ function processDatapoints(plot, series, datapoints) {
85
+ setupCategoriesForAxis(series, "xaxis", datapoints);
86
+ setupCategoriesForAxis(series, "yaxis", datapoints);
87
+ }
88
+ function init(plot) {
89
+ plot.hooks.processRawData.push(processRawData);
90
+ plot.hooks.processDatapoints.push(processDatapoints);
91
+ }
92
+ $.plot.plugins.push({ init: init, options: options, name: "categories", version: "1.0" });
93
+ })(jQuery);