@magic-xpa/angular 4.801.0-dev481.311 → 4.801.0-dev481.317

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.
@@ -2243,6 +2243,7 @@ class MagicColorService {
2243
2243
  constructor(http, colorFile1 = 'clr_rnt.eng') {
2244
2244
  this.http = http;
2245
2245
  this.colorFileName = 'clr_rnt.eng';
2246
+ this.fileNotFound = false;
2246
2247
  if (colorFile1)
2247
2248
  this.colorFileName = colorFile1;
2248
2249
  else
@@ -2255,10 +2256,13 @@ class MagicColorService {
2255
2256
  if (!this.colorsData) {
2256
2257
  this.http.get(this.getColorFilePath(), { responseType: 'text' }).subscribe(resp => {
2257
2258
  this.colorsData = resp.replace(/\n/g, '@').split('@');
2259
+ }, error1 => {
2260
+ console.error('File not found ' + this.colorFileName);
2261
+ this.fileNotFound = true;
2258
2262
  });
2259
2263
  }
2260
2264
  }
2261
- hexToRgba(hex) {
2265
+ hexToRgba(hex, isTransperent) {
2262
2266
  let shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])$/i;
2263
2267
  hex = hex.replace(shorthandRegex, function (m, r, g, b, a) {
2264
2268
  return a + a + r + r + g + g + b + b;
@@ -2270,33 +2274,42 @@ class MagicColorService {
2270
2274
  'blue': parseInt(result[2], 16),
2271
2275
  'alpha': (255 - parseInt(result[1], 16)) / 255
2272
2276
  };
2277
+ if (isTransperent)
2278
+ rgb.alpha = 0;
2273
2279
  return 'rgba(' + rgb.red + ',' + rgb.green + ',' + rgb.blue + ',' + rgb.alpha + ')';
2274
2280
  }
2275
2281
  getColor(colorIndex, colorType) {
2276
- if (!this.colorsData)
2282
+ let isTransperent = false;
2283
+ if (!this.colorsData && !this.fileNotFound)
2277
2284
  this.getColorData();
2278
- if (this.colorsData && this.colorsData[colorIndex - 1]) {
2279
- let hex = '';
2280
- const grayHashCode = '00808080';
2281
- let color = this.colorsData[colorIndex].split(',');
2282
- if (+color[3] <= 1) {
2283
- switch (colorType) {
2284
- case MAGIC_FG_COLOR:
2285
- hex = (color[1]);
2286
- break;
2287
- case MAGIC_BG_COLOR:
2288
- hex = (color[2]);
2289
- break;
2290
- default:
2291
- console.log('Please enter valid color type : 1-FG, 2-BG ' + colorIndex);
2292
- return '';
2285
+ if (this.colorsData) {
2286
+ if (this.colorsData[colorIndex - 1]) {
2287
+ let hex = '';
2288
+ const grayHashCode = '00808080';
2289
+ let color = this.colorsData[colorIndex - 1].split(',');
2290
+ if (+color[3] || 1 == +color[3]) {
2291
+ isTransperent = true;
2293
2292
  }
2293
+ if (+color[3] <= 1) {
2294
+ switch (colorType) {
2295
+ case MAGIC_FG_COLOR:
2296
+ hex = (color[1]);
2297
+ break;
2298
+ case MAGIC_BG_COLOR:
2299
+ hex = (color[2]);
2300
+ break;
2301
+ default:
2302
+ console.log('Please enter valid color type : 1-FG, 2-BG ' + colorIndex);
2303
+ return '';
2304
+ }
2305
+ }
2306
+ else
2307
+ hex = grayHashCode;
2308
+ return this.hexToRgba('#' + hex, isTransperent);
2294
2309
  }
2295
2310
  else
2296
- hex = grayHashCode;
2297
- return this.hexToRgba('#' + hex);
2311
+ console.log('Could not get color for number ' + colorIndex);
2298
2312
  }
2299
- console.log('Could not get color for number ' + colorIndex);
2300
2313
  return '';
2301
2314
  }
2302
2315
  }