cronapi-js 2.8.15 → 2.8.19

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.
package/cronapi.js CHANGED
@@ -33,6 +33,14 @@ if (!window.fixedTimeZone) {
33
33
 
34
34
  this.cronapi = {};
35
35
 
36
+ this.cronapi.getRequestData = data => {
37
+ let result = data || {};
38
+ if (data.data && typeof data.data === 'object') {
39
+ result = data.data;
40
+ }
41
+ return result;
42
+ };
43
+
36
44
  this.cronapi.toDate = function(value) {
37
45
  return new Date(value);
38
46
  }
@@ -1252,6 +1260,7 @@ if (!window.fixedTimeZone) {
1252
1260
  };
1253
1261
 
1254
1262
  /**
1263
+ * @deprecated true
1255
1264
  * @type function
1256
1265
  * @name {{screenNotifyName}}
1257
1266
  * @description {{screenNotifyDescription}}
@@ -1631,8 +1640,8 @@ if (!window.fixedTimeZone) {
1631
1640
  return null;
1632
1641
  };
1633
1642
 
1634
-
1635
1643
  /**
1644
+ * @deprecated true
1636
1645
  * @type function
1637
1646
  * @name {{confirmDialogName}}
1638
1647
  * @nameTags confirmDialog|Confirmar
@@ -1645,7 +1654,7 @@ if (!window.fixedTimeZone) {
1645
1654
  var value = confirm(msg);
1646
1655
  return value;
1647
1656
  };
1648
-
1657
+
1649
1658
  /**
1650
1659
  * @type function
1651
1660
  * @name {{createDefaultModalName}}
@@ -3467,6 +3476,8 @@ if (!window.fixedTimeZone) {
3467
3476
  let barCodeOneD = "UPC_A|UPC_E|EAN_8|EAN_13|CODE_39|CODE_128|ITF|RSS14|RSS_EXPANDED";
3468
3477
  let codeReader;
3469
3478
 
3479
+ navigator.mediaDevices.getUserMedia({audio: false, video: true}).then(stream => {
3480
+
3470
3481
  switch (scanOptions.formats) {
3471
3482
  case "AZTEC":
3472
3483
  codeReader = new ZXing.BrowserAztecCodeReader();
@@ -3488,43 +3499,84 @@ if (!window.fixedTimeZone) {
3488
3499
  codeReader = new ZXing.BrowserBarcodeReader();
3489
3500
  }
3490
3501
 
3491
- codeReader.listVideoInputDevices()
3502
+ codeReader.listVideoInputDevices()
3492
3503
  .then((videoInputDevices) => {
3493
3504
  selectedDeviceId = videoInputDevices[0].deviceId
3494
- var cameraContainer = '<div style="position: fixed; display: flex; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; background-color: \
3495
- rgb(0 0 0 / 72%); z-index: 9999999; cursor: pointer; justify-content: center; align-items: center;">\
3496
- <div style="position: absolute">\
3497
- <video id="video" style="width: 100%; max-width: 600px; border-radius: 5px;"></video>\
3498
- <button class="btn btn-danger button button-assertive" id="cronapiBarCodeCancel" style="position: absolute; right: 0; z-index: 999999999;">\
3499
- <span class="glyphicon glyphicon-remove icon ion-android-close"></span>\
3500
- <span class="sr-only">{{"Cancel" | translate}}</span>\
3501
- </button>\
3502
- </div>\
3503
- </div>';
3504
- var cronappVideoBarCode = $(cameraContainer);
3505
+ let cameraContainer = `<div style="position: fixed; display: flex; width: 100%; height: 100%; top: 0; left: 0; right: 0; bottom: 0; background-color:
3506
+ rgb(0 0 0 / 72%); z-index: 9999999; cursor: pointer; justify-content: center; align-items: center;">
3507
+ <div style="position: absolute">
3508
+ <div class="row" style="position: absolute; bottom 50px; z-index: 999999999;">
3509
+ <div class="col-xs-8">
3510
+ <select style="width: 100%; position: absolute; bottom: 10px; left: 0; z-index: 999999999;" id="videoSource"></select>
3511
+ </div>
3512
+ <div class="col-xs-2">
3513
+ <button class="btn btn-danger button button-dark" id="cronapiBarCodeChangeCam" >
3514
+ <span class="glyphicon glyphicon-remove icon ion ion-ios-reverse-camera"></span>
3515
+ <span class="sr-only">{{"ChangeCam" | translate}}</span>
3516
+ </button>
3517
+ </div>
3518
+ <div class="col-xs-2">
3519
+ <button class="btn btn-danger button button-assertive" id="cronapiBarCodeCancel" >
3520
+ <span class="glyphicon glyphicon-remove icon ion-android-close"></span>
3521
+ <span class="sr-only">{{"Cancel" | translate}}</span>
3522
+ </button>
3523
+ </div>
3524
+ </div>
3525
+ <video id="video" style="width: 100%; max-width: 600px; border-radius: 5px;"></video>
3526
+ </div>
3527
+ </div>`;
3528
+ let cronappVideoBarCode = $(cameraContainer);
3505
3529
  cronappVideoBarCode.prependTo("body");
3506
- cronappVideoBarCode.find('#cronapiBarCodeCancel').on('click', function() {
3530
+ videoInputDevices.map((device, index)=>{
3531
+ if (device.kind === 'videoinput') {
3532
+ let option = document.createElement('option');
3533
+ option.value = device.deviceId;
3534
+ option.text = device.label || 'Câmera ' + (index + 1);
3535
+ if (index === 0) {
3536
+ option.selected = true;
3537
+ }
3538
+ document.querySelector('select#videoSource').appendChild(option);
3539
+ }
3540
+ });
3541
+ cronappVideoBarCode.find('#cronapiBarCodeCancel').on('click', (() => {
3507
3542
  codeReader.reset();
3508
3543
  $(cronappVideoBarCode).remove();
3509
- fail();
3510
- }.bind(this));
3511
-
3544
+ }).bind(this));
3545
+ cronappVideoBarCode.find('#cronapiBarCodeChangeCam').on('click', (() => {
3546
+ let selectedIndex = $("#videoSource").prop("selectedIndex");
3547
+ let itemsInDropDownList = $("#videoSource option").length;
3548
+
3549
+ if (selectedIndex < (itemsInDropDownList - 1)) {
3550
+ $("#videoSource").prop("selectedIndex", selectedIndex + 1);
3551
+ } else {
3552
+ $("#videoSource").prop("selectedIndex", 0);
3553
+ }
3554
+ $("#videoSource").trigger('change');
3555
+ }).bind(this));
3556
+ cronappVideoBarCode.find('#videoSource').on('change', (() => {
3557
+ codeReader.decodeOnceFromVideoDevice($("#videoSource").val(), 'video').then((result) => {
3558
+ if (result) {
3559
+ success(result.text);
3560
+ $(cronappVideoBarCode).remove();
3561
+ codeReader.reset();
3562
+ }
3563
+ });
3564
+ }).bind(this));
3512
3565
  codeReader.decodeOnceFromVideoDevice(selectedDeviceId, 'video').then((result) => {
3513
3566
  if (result) {
3514
3567
  success(result.text);
3515
3568
  $(cronappVideoBarCode).remove();
3516
3569
  codeReader.reset();
3517
3570
  }
3518
- }).catch((err) => {
3519
- fail(err);
3520
- $(cronappVideoBarCode).remove();
3521
- codeReader.reset();
3522
3571
  });
3523
3572
 
3524
3573
  }).catch((err) => {
3525
3574
  fail(err);
3526
3575
  codeReader.reset();
3527
3576
  });
3577
+ }).catch(function(err) {
3578
+ fail(err);
3579
+ });
3528
3580
  }
3529
3581
 
3530
3582
  this.cronapi.internal.castBinaryStringToByteArray = function(binary_string) {
@@ -3774,8 +3826,10 @@ if (!window.fixedTimeZone) {
3774
3826
  'Content-Type': 'application/json',
3775
3827
  'X-AUTH-TOKEN': _u.token,
3776
3828
  }
3777
- }).success(function(data, status, headers, config) {
3829
+ }).then(function(data, status, headers, config) {
3830
+ headers = headers || data.headers;
3778
3831
  headers = headers();
3832
+ data = this.cronapi.getRequestData(data);
3779
3833
  var filename = headers['x-filename'] || 'download.bin';
3780
3834
  var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
3781
3835
  try
@@ -3786,7 +3840,7 @@ if (!window.fixedTimeZone) {
3786
3840
  console.log('Error downloading file');
3787
3841
  console.log(ex);
3788
3842
  }
3789
- }.bind(this)).error(function(data, status, headers, config) {
3843
+ }.bind(this)).catch(function(data, status, headers, config) {
3790
3844
  console.log('Error downloading file');
3791
3845
  }.bind(this));
3792
3846
  }
@@ -3834,9 +3888,10 @@ if (!window.fixedTimeZone) {
3834
3888
 
3835
3889
  }
3836
3890
  }
3837
- }).success(function(data, status, headers, config) {
3891
+ }).then(function(data, status, headers, config) {
3892
+ data = this.cronapi.getRequestData(data);
3838
3893
  this.cronapi.screen.changeValueOfField(field, data.jsonString);
3839
- }.bind(this)).error(function(data, status, headers, config) {
3894
+ }.bind(this)).catch(function(data, status, headers, config) {
3840
3895
  alert('Error uploading file');
3841
3896
  }.bind(this));
3842
3897
 
@@ -4268,8 +4323,13 @@ if (!window.fixedTimeZone) {
4268
4323
  let options = { destinationType: Number(destinationType) , sourceType : Number(pictureSourceType) , mediaType: Number(mediaType) , allowEdit: allowEdit};
4269
4324
  if(window.cordova && window.cordova.platformId && window.cordova.platformId !== 'browser') {
4270
4325
 
4271
- let resultWithData = (data) => {
4272
- if (data && !data.startsWith("data:image")) data = "data:image/jpeg;base64, " + data;
4326
+ let resultWithData = async (data) => {
4327
+ if (data.startsWith("file://")) {
4328
+ data = Ionic.WebView.convertFileSrc(data);
4329
+ }
4330
+ else if (data && !data.startsWith("data:image")) {
4331
+ data = "data:image/jpeg;base64, " + data;
4332
+ }
4273
4333
  !success || success(data);
4274
4334
  };
4275
4335
  navigator.camera.getPicture(this.cronapi.util.handleCallback(resultWithData), this.cronapi.util.handleCallback(error), options);
@@ -4716,26 +4776,6 @@ if (!window.fixedTimeZone) {
4716
4776
  this.cronapi.event = {};
4717
4777
 
4718
4778
 
4719
- /**
4720
- * @type function
4721
- * @name {itemContextMenu}
4722
- * @nameTags contextMenu | menu | contexto | context | item
4723
- * @description {contextMenuDescription}
4724
- * @param {ObjectType.STRING} text {{text}}
4725
- * @param {ObjectType.STRING} cssClass {{cssClass}}
4726
- * @param {ObjectType.STATEMENT} action {{kendoContextMenuActionItem}}
4727
- * @param {ObjectType.OBJECT} subItens {{kendoDatasource}}
4728
- * @returns {ObjectType.OBJECT}
4729
- */
4730
- this.cronapi.event.itemContextMenu = function (/** @type{ObjectType.STRING} */ text, /** @type{ObjectType.STRING} */ cssClass, /** @type {ObjectType.STATEMENT} @description {kendoContextMenuActionItem} */action, subItens) {
4731
-
4732
- let jsonItem = { text: text }
4733
- if (subItens) { jsonItem.items = (Array.isArray(subItens) ? subItens : [subItens]) };
4734
- if (!subItens) { jsonItem.select = action }
4735
- if (cssClass) { jsonItem.cssClass = cssClass };
4736
- return jsonItem;
4737
- };
4738
-
4739
4779
  /**
4740
4780
  * @type function
4741
4781
  * @name {{contextMenu}}
@@ -4786,16 +4826,16 @@ if (!window.fixedTimeZone) {
4786
4826
 
4787
4827
  /**
4788
4828
  * @type function
4789
- * @name {itemContextMenu}
4829
+ * @name {{itemContextMenu}}
4790
4830
  * @nameTags contextMenu | menu | contexto | context | item
4791
- * @description {contextMenuDescription}
4831
+ * @description {{contextMenuDescription}}
4792
4832
  * @param {ObjectType.STRING} text {{text}}
4793
4833
  * @param {ObjectType.STRING} cssClass {{cssClass}}
4794
- * @param {ObjectType.STATEMENT} action {{kendoContextMenuActionItem}}
4834
+ * @param {ObjectType.STATEMENT} action {{contextMenuItemActionDescription}}
4795
4835
  * @param {ObjectType.OBJECT} subItens {{kendoDatasource}}
4796
4836
  * @returns {ObjectType.OBJECT}
4797
4837
  */
4798
- this.cronapi.event.itemContextMenu = function (/** @type{ObjectType.STRING} */ text, /** @type{ObjectType.STRING} */ cssClass, /** @type {ObjectType.STATEMENT} @description {kendoContextMenuActionItem} */action, subItens) {
4838
+ this.cronapi.event.itemContextMenu = function (/** @type{ObjectType.STRING} */ text, /** @type{ObjectType.STRING} */ cssClass, /** @type {ObjectType.STATEMENT} */ action, subItens) {
4799
4839
 
4800
4840
  let jsonItem = { text: text }
4801
4841
  if (subItens) { jsonItem.items = (Array.isArray(subItens) ? subItens : [subItens]) };
@@ -4806,7 +4846,7 @@ if (!window.fixedTimeZone) {
4806
4846
 
4807
4847
  /**
4808
4848
  * @type function
4809
- * @name {{changeValueAccordion}}
4849
+ * @name {{accordionChangeValue}}
4810
4850
  * @nameTags accordion | acordeão | abrir | fechar | colapse
4811
4851
  * @description {{accordionChangeValueDescription}}
4812
4852
  * @param {ObjectType.STRING} idAccordion {{accordionIdParamDescription}}
@@ -4817,9 +4857,11 @@ if (!window.fixedTimeZone) {
4817
4857
 
4818
4858
  switch (action) {
4819
4859
  case "collapseAll":
4860
+ $('#' + idAccordion + ' .panel-collapse').data("bs.collapse", null);
4820
4861
  $('#' + idAccordion + ' .panel-collapse').collapse('hide');
4821
4862
  break;
4822
4863
  case "expandAll":
4864
+ $('#' + idAccordion + ' .panel-collapse').data("bs.collapse", null);
4823
4865
  $('#' + idAccordion + ' .panel-collapse').collapse('show');
4824
4866
  break;
4825
4867
  case "collapseOne":
@@ -5055,6 +5097,7 @@ if (!window.fixedTimeZone) {
5055
5097
  return message;
5056
5098
  };
5057
5099
 
5100
+
5058
5101
  /**
5059
5102
  * @type internal
5060
5103
  */
@@ -5086,8 +5129,9 @@ if (!window.fixedTimeZone) {
5086
5129
  * @description {{createChartDescription}}
5087
5130
  * @arbitraryParams true
5088
5131
  */
5089
- this.cronapi.chart.createChart = function(/** @type {ObjectType.OBJECT} @description {{createChartId}} @blockType ids_from_screen*/ chartId, /** @type {ObjectType.STRING} @description {{createChartType}} @blockType util_dropdown @keys line|bar|horizontalBar|doughnut|pie|polarArea @values line|bar|horizontalBar|doughnut|pie|polarArea */ type, /** @type {ObjectType.LIST} @description {{createChartLegends}} */ chartLegends, /** @type {ObjectType.LIST} @description {{createChartOptions}} */ options, /** @type {ObjectType.LIST} @description {{createChartSeries}} */ series) {
5132
+ this.cronapi.chart.createChart = function(/** @type {ObjectType.OBJECT} @description {{createChartId}} @blockType ids_from_screen*/ chartId, /** @type {ObjectType.STRING} @description {{createChartType}} @blockType util_dropdown @keys line|bar|horizontalBar|doughnut|pie|polarArea @values line|bar|horizontalBar|doughnut|pie|polarArea */ type, /** @type {ObjectType.LIST} @description {{createChartLegends}} */ chartLegends, /** @type {ObjectType.LIST} @description {{createChartOptions}} */ options, /** @type {ObjectType.LIST} @description {{createChartSeries}} */ series) {
5090
5133
 
5134
+ var colors = options && options.colors ? options.colors : [];
5091
5135
  var CSS_COLOR_NAMES = ["#FF5C00","#0E53A7","#48DD00","#FFD500","#7309AA","#CD0074","#00AF64","#BF8230","#F16D95","#A65000","#A65000","#AF66D5"];
5092
5136
  var colorIndex = 0;
5093
5137
 
@@ -5192,7 +5236,7 @@ if (!window.fixedTimeZone) {
5192
5236
  //Applying configs in Datasets
5193
5237
  $.each(json.data.datasets, function(index,value){
5194
5238
  value.fill = false;
5195
- value.backgroundColor = CSS_COLOR_NAMES[nextColor()];
5239
+ value.backgroundColor = colors[index] ? colors[index] : CSS_COLOR_NAMES[nextColor()];
5196
5240
  value.borderColor = value.backgroundColor;
5197
5241
  beginAtZero();
5198
5242
  displayLegend();
@@ -5205,7 +5249,11 @@ if (!window.fixedTimeZone) {
5205
5249
  json.data.datasets = getDataset(arguments);
5206
5250
  //Applying configs in Datasets
5207
5251
  $.each(json.data.datasets, function(index,value){
5208
- value.backgroundColor = CSS_COLOR_NAMES[nextColor()];
5252
+ if(json.data.datasets.length === 1 && colors.length > 1){
5253
+ value.backgroundColor = colors;
5254
+ }else{
5255
+ value.backgroundColor = colors[index] ? colors[index] : CSS_COLOR_NAMES[nextColor()];
5256
+ }
5209
5257
  value.borderColor = value.backgroundColor;
5210
5258
  });
5211
5259
  beginAtZero();
@@ -5223,8 +5271,7 @@ if (!window.fixedTimeZone) {
5223
5271
  dtset.backgroundColor = [];
5224
5272
  dtset.borderColor = [];
5225
5273
  $.each(dtset.data, function(indexx,valuee){
5226
- dtset.backgroundColor.push( CSS_COLOR_NAMES[nextColor()] );
5227
-
5274
+ dtset.backgroundColor.push( colors[indexx] ? colors[indexx] : CSS_COLOR_NAMES[nextColor()] );
5228
5275
  });
5229
5276
  dtset.borderColor = dtset.backgroundColor;
5230
5277
  json.data.datasets.push(dtset);
@@ -5413,7 +5460,324 @@ if (!window.fixedTimeZone) {
5413
5460
  */
5414
5461
  this.cronapi.screen.back = function() {
5415
5462
  history.back();
5416
- }
5463
+ };
5464
+
5465
+ /**
5466
+ * @category {{notificationCategory}}
5467
+ * @categoryTags notification | notification
5468
+ */
5469
+ this.cronapi.notification = {};
5470
+
5471
+ /**
5472
+ * @type function
5473
+ * @name {{confirmDialogAlertName}}
5474
+ * @nameTags confirmDialog | Confirmar | alert | modal | alerta
5475
+ * @description {{confirmDialogAlertDescription}}
5476
+ * @param {ObjectType.STRING} icon {{icon}
5477
+ * @param {ObjectType.STRING} title {{title}}
5478
+ * @param {ObjectType.STRING} subtitle {{subtitle}}
5479
+ * @param {ObjectType.OBJECT} buttonConfirmDialogAlert {{confimDialogAlert.listButton}}
5480
+ * @platform W
5481
+ * @multilayer true
5482
+ */
5483
+ this.cronapi.notification.confirmDialogAlert = function(/** @type {ObjectType.STRING} @description {{icon}} @blockType util_dropdown @keys error|success|warning|info @values {{error}}|{{success}}|{{warning}}|{{info}} */ icon, title, subtitle, /** @type {ObjectType.OBJECT} */ buttonConfirmDialogAlert) {
5484
+
5485
+ let idDialog = 'cronapp-dialog-' + Math.random();
5486
+ let dialog = $(`<span id="${idDialog}"></span>`);
5487
+ $('body').append(dialog);
5488
+
5489
+ let dataDialog = {
5490
+ width: "450px",
5491
+ title: false,
5492
+ closable: false,
5493
+ modal: true,
5494
+ content: "",
5495
+ animation: {
5496
+ open: {
5497
+ effects: "zoom:in"
5498
+ },
5499
+ close: {
5500
+ effects: "zoom:out"
5501
+ }
5502
+ },
5503
+ buttonLayout: "normal",
5504
+ actions: [],
5505
+ close: function(e) {
5506
+ setInterval(() => {
5507
+ $(`#${idDialog}`).data("kendoDialog").destroy();
5508
+ }, 3000);
5509
+ }
5510
+ };
5511
+
5512
+ setIcon(icon, title, subtitle);
5513
+ setButton(buttonConfirmDialogAlert);
5514
+
5515
+ dialog.kendoDialog(dataDialog);
5516
+ dialog.data("kendoDialog").open();
5517
+
5518
+ async function setIcon(icon, title, subtitle){
5519
+ switch (icon){
5520
+ case "error":
5521
+ icon = '<div class="cronapp-icon cronapp-error" style="display: flex;"> <span class="cronapp-x-mark"><span class="cronapp-x-mark-line-left"></span><span class="cronapp-x-mark-line-right"></span></span></div>';
5522
+ break;
5523
+
5524
+ case "success":
5525
+ icon = '<div class="cronapp-icon cronapp-success"><div class="cronapp-success-circular-line-left"></div><span class="cronapp-success-line-tip"></span> <span class="cronapp-success-line-long"></span><div class="cronapp-success-ring"></div><div class="cronapp-success-fix"></div> <div class="cronapp-success-circular-line-right"></div></div>';
5526
+ break;
5527
+
5528
+ case "warning":
5529
+ icon = '<div class="cronapp-icon cronapp-warning"><div class="cronapp-icon-content">!</div></div>';
5530
+ break;
5531
+
5532
+ case "info":
5533
+ icon = '<div class="cronapp-icon cronapp-info"><div class="cronapp-icon-content">i</div></div>';
5534
+ break;
5535
+ }
5536
+ await setContent(icon, title, subtitle);
5537
+ }
5538
+
5539
+ function setContent(icon, title, subtitle){
5540
+ dataDialog.content = '<div id="modalBodyConfirmDialog"> <div class="icon">'+ icon +'</div> <h2 class="title">'+ title +'</h2> <h3 class="subtitle">'+ subtitle +'</h3> </div>';
5541
+ }
5542
+
5543
+ function setButton(buttonConfirmDialogAlert){
5544
+ let buttons = (Array.isArray(buttonConfirmDialogAlert) ? buttonConfirmDialogAlert : [buttonConfirmDialogAlert]);
5545
+
5546
+ let hasButton = false;
5547
+
5548
+ for (let i = 0; i < buttons.length; i++) {
5549
+ let button = buttons[i];
5550
+ if(button){
5551
+ dataDialog.actions.push({
5552
+ text: button.title,
5553
+ action: button.value,
5554
+ primary: button.primaryValue == 'true' ? true : null
5555
+ });
5556
+
5557
+ hasButton = true;
5558
+
5559
+ }
5560
+ };
5561
+
5562
+ // If you have not added a button to the modal. Add to be able to close the modal.
5563
+ if(!hasButton){
5564
+ dataDialog.actions.push({
5565
+ text: "OK",
5566
+ primary: true
5567
+ });
5568
+ };
5569
+
5570
+ }
5571
+
5572
+ };
5573
+
5574
+ /**
5575
+ * @type function
5576
+ * @name {{buttonConfirmDialogAlert}}
5577
+ * @nameTags confirmDialog | botão | button | alert | modal | alerta
5578
+ * @description {{buttonConfirmDialogAlertDescription}}
5579
+ * @platform W
5580
+ * @param {ObjectType.BOOLEAN} primaryButton {{buttonConfirmDialogAlert.primaryButton}}
5581
+ * @param {ObjectType.STRING} title {{title}}
5582
+ * @param {ObjectType.STRING} value {{buttonConfirmDialogAlert.value}}
5583
+ * @returns {ObjectType.OBJECT}
5584
+ */
5585
+ this.cronapi.notification.buttonConfirmDialogAlert = function (/** @type {ObjectType.STRING} @description {{buttonConfirmDialogAlert.primaryButton}} @blockType util_dropdown @keys true|false @values {{yes}}|{{no}} */ primaryButton, title, /** @type {ObjectType.STATEMENT} @description {{buttonConfirmDialogAlert.value}} */ value) {
5586
+ return {
5587
+ title: title,
5588
+ value: value,
5589
+ primaryValue: primaryButton
5590
+ };
5591
+ };
5592
+
5593
+ /**
5594
+ * @type function
5595
+ * @name {{screenNotifySimpleName}}
5596
+ * @description {{screenNotifySimpleDescription}}
5597
+ * @nameTags show | exibir | exibe | notification | notificação
5598
+ * @param {ObjectType.STRING} status {{screenNotifySimpleParam0}}
5599
+ * @param {ObjectType.STRING} message {{screenNotifySimpleParam1}}
5600
+ * @param {ObjectType.STRING} animation {{screenNotifySimpleParam2}}
5601
+ * @param {ObjectType.STRING} verticalPosition {{screenNotifySimpleParam3}}
5602
+ * @param {ObjectType.STRING} horizontalPosition {{screenNotifySimpleParam4}}
5603
+ * @param {ObjectType.STRING} autoHide {{screenNotifySimpleParam5}}
5604
+ */
5605
+ this.cronapi.notification.customNotify = function(/** @type {ObjectType.STRING} @description {{status}} @blockType util_dropdown @keys error|success|warning|info @values {{error}}|{{success}}|{{warning}}|{{info}} */ status, /** @type {ObjectType.STRING} */ message, /** @type {ObjectType.STRING} @description {{animation}} @blockType util_dropdown @keys fade|slide|zoom @values {{fade}}|{{slide}}|{{zoom}} */ animation, /** @type {ObjectType.STRING} @description {{verticalPosition}} @blockType util_dropdown @keys top|bottom @values {{top}}|{{bottom}} */ verticalPosition, /** @type {ObjectType.STRING} @description {{horizontalPosition}} @blockType util_dropdown @keys left|center|right @values {{left}}|{{center}}|{{right}} */ horizontalPosition, /** @type {ObjectType.STRING} @description {{autoHide}} @blockType util_dropdown @keys true|false @values {{yes}}|{{no}} */ autoHide) {
5606
+
5607
+ let idCustomNotification = "customNotification" ;
5608
+
5609
+ let dataNotification = {
5610
+ stacking: "default",
5611
+ autoHideAfter: 5000,
5612
+ position: {
5613
+ pinned: true
5614
+ },
5615
+ animation: {
5616
+ open: {
5617
+ effects: null
5618
+ },
5619
+ close: {
5620
+ effects: null
5621
+ }
5622
+ }
5623
+ };
5624
+
5625
+ if (animation || verticalPosition || horizontalPosition || autoHide) {
5626
+ customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide);
5627
+ } else {
5628
+ defaultNotification(message, status);
5629
+ }
5630
+
5631
+ async function defaultNotification(message, status) {
5632
+
5633
+ let cronappConfig = {
5634
+ id: "CronappNotification",
5635
+ verticalPosition: "top",
5636
+ horizontalPosition: "left",
5637
+ animation: "slide",
5638
+ autoHide: "false"
5639
+ };
5640
+
5641
+ setVerticalPosition(cronappConfig.verticalPosition);
5642
+ setHorizontalPosition(cronappConfig.horizontalPosition);
5643
+ setAnimation(cronappConfig.animation);
5644
+ setAutoHide(cronappConfig.autoHide);
5645
+
5646
+ if (!isNotificationInitialized(cronappConfig.id)) {
5647
+ initializeNotification(cronappConfig.id, dataNotification);
5648
+ }
5649
+
5650
+ showNotification(cronappConfig.id, message, status);
5651
+
5652
+ }
5653
+
5654
+ async function customNotification(message, status, animation, verticalPosition, horizontalPosition, autoHide) {
5655
+
5656
+ setVerticalPosition(verticalPosition);
5657
+ setHorizontalPosition(horizontalPosition);
5658
+ setAnimation(animation);
5659
+ setAutoHide(autoHide);
5660
+
5661
+ initializeNotification(idCustomNotification, dataNotification);
5662
+ showNotification(idCustomNotification, message, status);
5663
+
5664
+ }
5665
+
5666
+ function setVerticalPosition(verticalPosition){
5667
+ switch (verticalPosition) {
5668
+ case "bottom":
5669
+ dataNotification.position.bottom = 20;
5670
+ idCustomNotification = idCustomNotification.concat('-bottom');
5671
+ break;
5672
+
5673
+ default:
5674
+ dataNotification.position.top = 60;
5675
+ idCustomNotification = idCustomNotification.concat('-top');
5676
+
5677
+ }
5678
+ }
5679
+
5680
+ function setHorizontalPosition(horizontalPosition){
5681
+ switch (horizontalPosition) {
5682
+ case "right":
5683
+ dataNotification.position.right = 20;
5684
+ idCustomNotification = idCustomNotification.concat('-right');
5685
+ break;
5686
+
5687
+ case "center":
5688
+ dataNotification.show = centerElementScreen;
5689
+ idCustomNotification = idCustomNotification.concat('-center');
5690
+ break;
5691
+
5692
+ default:
5693
+ dataNotification.position.left = 20;
5694
+ idCustomNotification = idCustomNotification.concat('-left');
5695
+
5696
+ }
5697
+ }
5698
+
5699
+ function centerElementScreen(e){
5700
+ if (e.sender.getNotifications().length == 1) {
5701
+ var element = e.element.parent(),
5702
+ eWidth = element.width(),
5703
+ wWidth = $(window).width()
5704
+ var newLeft;
5705
+
5706
+ newLeft = Math.floor(wWidth / 2 - eWidth / 2);
5707
+
5708
+ e.element.parent().css({ left: newLeft });
5709
+ }
5710
+ }
5711
+
5712
+ function setAnimation(animation){
5713
+ switch (animation) {
5714
+ case "slide":
5715
+ if (dataNotification.show && dataNotification.position.bottom != null) {
5716
+ dataNotification.animation.open.effects = "slideIn:up";
5717
+ idCustomNotification = idCustomNotification.concat('-slideIn-up');
5718
+
5719
+ } else if (dataNotification.show && dataNotification.position.top != null) {
5720
+ dataNotification.animation.open.effects = "slideIn:down";
5721
+ idCustomNotification = idCustomNotification.concat('-slideIn-dow');
5722
+
5723
+ } else if (dataNotification.position.left != null) {
5724
+ dataNotification.animation.open.effects = "slideIn:right";
5725
+ idCustomNotification = idCustomNotification.concat('-slideIn-right');
5726
+
5727
+ } else if (dataNotification.position.left == null) {
5728
+ dataNotification.animation.open.effects = "slideIn:left";
5729
+ idCustomNotification = idCustomNotification.concat('-slideIn-left');
5730
+ }
5731
+
5732
+ dataNotification.animation.close.effects = "slideOut";
5733
+ break;
5734
+
5735
+ case "zoom":
5736
+ dataNotification.animation.open.effects = "zoomIn";
5737
+ dataNotification.animation.close.effects = "zoomOut";
5738
+ idCustomNotification = idCustomNotification.concat('-zoom');
5739
+ break;
5740
+
5741
+ default:
5742
+ dataNotification.animation.open.effects = "fadeIn";
5743
+ dataNotification.animation.close.effects = "fadeOut";
5744
+ idCustomNotification = idCustomNotification.concat('-fade');
5745
+ }
5746
+ }
5747
+
5748
+ function setAutoHide(autoHide){
5749
+ if(autoHide == "false"){
5750
+ dataNotification.autoHideAfter = 0;
5751
+ idCustomNotification = idCustomNotification.concat('-autoHideAfter');
5752
+ }
5753
+ }
5754
+
5755
+ async function initializeNotification(id, options) {
5756
+ if (!hasHTMLElement(id)) {
5757
+ let idNotification = $(`<span id="${id}"></span>`);
5758
+ $('body').append(idNotification);
5759
+
5760
+ await $(`#${id}`).kendoNotification(options);
5761
+
5762
+ if(horizontalPosition == "center"){
5763
+ centerElementScreen(e)
5764
+ }
5765
+ }
5766
+ }
5767
+
5768
+ function isNotificationInitialized(id) {
5769
+ return $(`#${id}`).getKendoNotification();
5770
+ }
5771
+
5772
+ function showNotification(id, message, status) {
5773
+ $(`#${id}`).getKendoNotification().show(message, status);
5774
+ }
5775
+
5776
+ function hasHTMLElement(id) {
5777
+ return document.getElementById(id);
5778
+ }
5779
+
5780
+ };
5417
5781
 
5418
5782
  /**
5419
5783
  * @category CategoryType.REGEX