@chat21/chat21-web-widget 5.0.68 → 5.0.69-rc.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # chat21-web-widget ver 5.0
2
2
 
3
+ ### 5.0.69-rc.1
4
+ - added: display/dispose widget on mobile/desktop behavior
5
+ - added: open/close widget on page change behavior
6
+ - added: 'redirect' action link on message type 'redirect'
7
+
3
8
  ### 5.0.68 in PROD
4
9
  - bug-fixed: metadata.includes is not a function at isAudio function
5
10
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-web-widget",
3
3
  "author": "Tiledesk SRL",
4
- "version": "5.0.68",
4
+ "version": "5.0.69-rc.1",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.tiledesk.com",
7
7
  "repository": {
@@ -258,8 +258,26 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
258
258
  this.logger.setLoggerConfig(this.g.isLogEnabled, this.g.logLevel)
259
259
  this.tabTitle = this.g.windowContext.window.document.title
260
260
  this.appStorageService.initialize(environment.storage_prefix, this.g.persistence, this.g.projectid)
261
- this.logger.debug('[APP-COMP] check if token is passed throw url: ', this.g.jwt);
261
+
262
+ //set visibility
263
+ if((this.g.isMobile && !this.g.displayOnMobile) || (!this.g.isMobile && !this.g.displayOnDesktop)){
264
+ this.disposeWidget()
265
+ return;
266
+ }
267
+ //set status (open /close)
268
+ if(this.g.isMobile && this.g.onPageChangeVisibilityMobile !== 'last'){
269
+ let isOpen = this.g.onPageChangeVisibilityMobile === 'open'? true: false
270
+ this.g.setIsOpen(isOpen)
271
+ this.appStorageService.setItem('isOpen', isOpen)
272
+ }
273
+ if(!this.g.isMobile && this.g.onPageChangeVisibilityDesktop !== 'last'){
274
+ let isOpen = this.g.onPageChangeVisibilityDesktop === 'open'? true: false
275
+ this.g.setIsOpen(isOpen)
276
+ this.appStorageService.setItem('isOpen', isOpen)
277
+ }
278
+
262
279
  /**CHECK IF JWT IS IN URL PARAMETERS */
280
+ this.logger.debug('[APP-COMP] check if token is passed throw url: ', this.g.jwt);
263
281
  if (this.g.jwt) {
264
282
  // logging in with custom token from url
265
283
  // add JWY token to localstorage and authenticate with it this.logger.debug('[APP-COMP] token from url. isShown:', this.g.isShown, 'autostart:', this.g.autoStart)
@@ -488,40 +506,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
488
506
  this.logger.debug('[APP-COMP] ---------------- 13 ---------------- ');
489
507
  this.logger.debug('[APP-COMP] ----------- sono già loggato ------- ');
490
508
  this.signInWithCustomToken(tiledeskToken)
491
- // this.tiledeskAuthService.signInWithCustomToken(tiledeskToken).then(user => {
492
- // this.messagingAuthService.createCustomToken(tiledeskToken)
493
- // }).catch(error => { console.error('SIGNINWITHCUSTOMTOKEN error::' + error) })
494
-
495
-
496
- // const currentUser = this.authService2.getCurrentUser();
497
- // this.g.senderId = currentUser.uid;
498
- // this.g.setParameter('senderId', currentUser.uid);
499
-
500
- // const fullName = currentUser.firstname + ' ' + currentUser.lastname;
501
- // this.g.setParameter('userFullname', fullName);
502
- // this.g.setAttributeParameter('userFullname', fullName);
503
- // this.g.setParameter('userEmail', currentUser.email);
504
- // this.g.setAttributeParameter('userEmail', currentUser.email);
505
-
506
- // // if(currentUser.firstname || currentUser.lastname){
507
- // // this.g.wdLog([' ---------------- 13 fullname ---------------- ']);
508
- // // const fullName = currentUser.firstname + ' ' + currentUser.lastname;
509
- // // this.g.setParameter('userFullname', fullName);
510
- // // this.g.setAttributeParameter('userFullname', fullName);
511
- // // }
512
- // // if(currentUser.email){
513
- // // this.g.wdLog([' ---------------- 13 email ---------------- ']);
514
- // // this.g.setParameter('userEmail', currentUser.email);
515
- // // this.g.setAttributeParameter('userEmail', currentUser.email);
516
- // // }
517
-
518
- // // this.g.setParameter('isLogged', true);
519
- // // this.g.setParameter('attributes', this.setAttributesFromStorageService());
520
- // // this.startNwConversation();
521
- // //this.startUI();
522
- // // this.g.wdLog([' 13 - IMPOSTO STATO CONNESSO UTENTE ']);
523
- // // this.presenceService.setPresence(currentUser.uid);
524
- //
509
+
525
510
  } else {
526
511
  // AUTENTICAZIONE ANONIMA
527
512
  this.logger.debug('[APP-COMP] ---------------- 14 ---------------- ');
@@ -543,9 +528,6 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
543
528
  this.g.setAttributeParameter('userEmail', user.email);
544
529
  }
545
530
  });
546
- // this.authService.anonymousAuthentication();
547
- // this.g.wdLog([' authenticateFirebaseAnonymously']);
548
- // this.authService.authenticateFirebaseAnonymously();
549
531
  }
550
532
  }
551
533
 
@@ -599,8 +581,6 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
599
581
  this.logger.error('[APP-COMP] signInAnonymous ERR', error);
600
582
  return Promise.reject(error);
601
583
  });
602
- // this.authService.anonymousAuthentication();
603
- // this.authService.authenticateFirebaseAnonymously();
604
584
  }
605
585
  // ========= end:: AUTHENTICATION ============//
606
586
 
@@ -42,7 +42,7 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
42
42
  import { TiledeskRequestsService } from 'src/chat21-core/providers/tiledesk/tiledesk-requests.service';
43
43
  import { LIVE_PAGE } from 'src/chat21-core/utils/constants';
44
44
  import { getDateDifference, popupUrl } from 'src/chat21-core/utils/utils';
45
- import { isUserBanned } from 'src/chat21-core/utils/utils-message';
45
+ import { isJustRecived, isUserBanned } from 'src/chat21-core/utils/utils-message';
46
46
  import { AppComponent } from '../../../app.component';
47
47
  import { ConversationContentComponent } from '../conversation-content/conversation-content.component';
48
48
  // import { TranslateService } from '@ngx-translate/core';
@@ -165,6 +165,7 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
165
165
 
166
166
  public isButtonUrl: boolean = false;
167
167
  public buttonClicked: any;
168
+ public startTime: Date = new Date();
168
169
  private logger: LoggerService = LoggerInstance.getInstance();
169
170
 
170
171
  constructor(
@@ -890,6 +891,12 @@ export class ConversationComponent implements OnInit, AfterViewInit, OnChanges {
890
891
  }else {
891
892
  this.footerMessagePlaceholder = '';
892
893
  }
894
+
895
+ //check if redirect message is present inside message object
896
+ if(msg.type === 'redirect' && isJustRecived(this.startTime.getTime(), msg.timestamp)){
897
+ let button = { link: msg.metadata.src, target: msg.metadata.target}
898
+ this.openLink(button)
899
+ }
893
900
  }
894
901
 
895
902
  }
@@ -109,14 +109,17 @@
109
109
  </div>
110
110
 
111
111
  <!-- carousel -->
112
- <!-- <div *ngIf="message?.attributes && message?.attributes?.attachment && message?.attributes?.attachment?.gallery" [ngClass]="{'slide-in-left': false}" class="carousel_container">
112
+ <div *ngIf="message?.attributes && message?.attributes?.attachment
113
+ && message?.attributes?.attachment?.gallery" [ngClass]="{'slide-in-left': false}" class="carousel_container">
113
114
  <chat-carousel class="carousel_container"
114
115
  [message]="message"
116
+ [isConversationArchived]="isConversationArchived"
117
+ [isLastMessage] = "isLastMessage(message?.uid)"
115
118
  [stylesMap]="stylesMap"
116
119
  (onElementRendered)="onElementRenderedFN($event)"
117
120
  (onAttachmentButtonClicked)="onAttachmentButtonClickedFN($event)">
118
121
  </chat-carousel>
119
- </div> -->
122
+ </div>
120
123
 
121
124
  </div>
122
125
 
@@ -1,29 +1,35 @@
1
1
  <div class="wrapper">
2
- <div id="left" class="arrow" (click)="goTo('previous')" >
3
- <!-- *ngIf="activeElement > 1" -->
2
+ <div id="left" class="arrow left" (click)="goTo('previous')" *ngIf="activeElement > 1">
4
3
  <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
5
4
  <path d="M0 0h24v24H0V0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12l4.58-4.59z"/>
6
5
  </svg>
7
6
  </div>
8
7
  <div class="carousel">
9
- <div class="card" *ngFor="let card of gallery">
10
- <div class="card-image">
11
- <img [src]="card?.preview?.src" alt="img" draggable="false">
12
- </div>
13
- <div class="card-content">
14
- <div class="card-title">{{card?.title}}</div>
15
- <div class="card-description">{{card?.description}}</div>
16
- </div>
17
- <div class="buttons" *ngIf="card?.buttons && card?.buttons.length > 0">
18
- <div class="single-button action" *ngFor="let button of card?.buttons">
19
- <div>{{button.value}}</div>
8
+ <!-- <div class="card" style="width: 17px;"></div> -->
9
+ <div class="card" *ngFor="let card of gallery; let i = index">
10
+ <div [style.opacity]="i+1 === activeElement? 1: 0.5">
11
+ <div class="card-image">
12
+ <img [src]="card?.preview?.src" alt="img" draggable="false">
13
+ </div>
14
+ <div class="card-content">
15
+ <div class="card-title">{{card?.title}}</div>
16
+ <div class="card-description">{{card?.description}}</div>
17
+ </div>
18
+ <div class="buttons" *ngIf="card?.buttons && card?.buttons.length > 0">
19
+ <div *ngFor="let button of card?.buttons"
20
+ class="single-button action"
21
+ [ngClass]="{'disabled': (isConversationArchived || !isLastMessage), 'active': button?.active}"
22
+ (click)="actionButtonClick($event, button, i)" >
23
+ {{button.value}}
24
+ </div>
20
25
  </div>
21
26
  </div>
22
27
  </div>
28
+ <!-- <div class="card" style="width: 17px;"></div> -->
23
29
  </div>
24
- <div id="right" class="arrow" (click)="goTo('next')" *ngIf="activeElement !== gallery.length">
30
+ <div id="right" class="arrow right" (click)="goTo('next')" *ngIf="activeElement !== gallery.length">
25
31
  <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
26
32
  <path d="M0 0h24v24H0V0z" fill="none"/><path d="M10.02 6L8.61 7.41 13.19 12l-4.58 4.59L10.02 18l6-6-6-6z"/>
27
33
  </svg>
28
34
  </div>
29
- </div>
35
+ </div>
@@ -8,7 +8,7 @@
8
8
  --buttonFontSize: #{var(--button-in-msg-font-size)};
9
9
  --max-width: #{var(--button-in-msg-max-width)};
10
10
 
11
- --cardWidth: 240px;
11
+ --cardWidth: 220px;
12
12
  }
13
13
 
14
14
 
@@ -18,240 +18,243 @@
18
18
  position: relative;
19
19
  display: flex;
20
20
 
21
- overflow: scroll;
21
+ // overflow: scroll;
22
22
  gap: 10px;
23
23
  margin: 0;
24
24
  width: 100%;
25
25
  font-size: 14px;
26
- margin: 0 25px;
27
- }
28
- .wrapper .cards-scroll-spacer{
29
- -ms-flex-negative: 0;
30
- content: "";
31
- flex-shrink: 0;
32
- width: 17px;
33
- }
34
- .wrapper div.arrow {
35
- top: 50%;
36
- height: 40px;
37
- width: 40px;
38
- cursor: pointer;
39
- font-size: 1.25rem;
40
- position: absolute;
41
- text-align: center;
42
- line-height: 50px;
43
- background: #fff;
44
- border-radius: 50%;
45
- box-shadow: 0 3px 6px rgba(0,0,0,0.23);
46
- transform: translateY(-50%);
47
- transition: transform 0.1s linear;
26
+ // margin: 0 25px;
27
+ }
28
+ .wrapper div.arrow {
29
+ top: 50%;
30
+ height: 40px;
31
+ width: 40px;
32
+ cursor: pointer;
33
+ position: absolute;
34
+ background: #fff;
35
+ border-radius: 50%;
36
+ box-shadow: 0 3px 6px rgba(0,0,0,0.23);
37
+ transform: translateY(-50%);
38
+ transition: transform 0.1s linear;
39
+ z-index: 2;
48
40
 
49
- display: flex;
50
- justify-content: center;
51
- align-items: center;
52
- }
53
- .wrapper div.arrow:active{
54
- transform: translateY(-50%) scale(0.85);
55
- }
56
- .wrapper div.arrow:first-child{
57
- left: 5px;
58
- }
59
- .wrapper div.arrow:last-child{
60
- // right: -22px;
61
- // right: 22px;
62
- left: calc(var(--cardWidth) - -15px);
63
- }
64
- .wrapper .carousel{
65
- display: grid;
66
- grid-auto-flow: column;
67
- grid-auto-columns: calc((100% / 3) - 12px);
68
- align-items: start;
69
- overflow: hidden;
70
- // scroll-snap-type: x mandatory;
71
- gap: 16px;
72
- border-radius: 8px;
73
- scroll-behavior: smooth;
74
- scrollbar-width: none;
41
+ display: flex;
42
+ justify-content: center;
43
+ align-items: center;
44
+ }
45
+ .wrapper div.arrow:active{
46
+ transform: translateY(-50%) scale(0.85);
47
+ }
48
+ .wrapper div.arrow:first-child{
49
+ left: -22px;
50
+ }
51
+ .wrapper div.arrow:last-child{
52
+ right: -22px;
53
+ }
54
+ .wrapper .carousel{
55
+ display: grid;
56
+ align-items: start;
57
+ grid-auto-flow: column;
58
+ grid-auto-columns: calc((100% / 3) - 12px);
59
+ // overflow-x: auto;
60
+ overflow-x: hidden;
61
+ scroll-snap-type: x mandatory;
62
+ gap: 10px;
63
+ border-radius: 8px;
64
+ scroll-behavior: smooth;
65
+ scrollbar-width: none;
75
66
 
76
- // display: flex;
77
- // align-items: flex-start;
78
- }
79
- .carousel::-webkit-scrollbar {
80
- display: none;
81
- }
82
- .carousel.no-transition {
83
- scroll-behavior: auto;
84
- }
85
- .carousel.dragging {
86
- scroll-snap-type: none;
87
- scroll-behavior: auto;
88
- }
89
- .carousel.dragging .card {
90
- cursor: grab;
91
- user-select: none;
92
- }
93
- .carousel :where(.card, .card-imgage) {
94
- display: flex;
95
- justify-content: center;
96
- align-items: center;
97
- }
98
- .carousel .card {
99
- scroll-snap-align: start;
100
- width: var(--cardWidth);
101
- background: rgb(255, 255, 255);
102
- box-shadow: 0 3px 6px rgba(0,0,0,0.23);
103
- cursor: pointer;
104
- // padding-bottom: 15px;
105
- flex-direction: column;
106
- border-radius: 8px;
107
- border: 1px solid;
108
- border-color: rgb(219, 225, 232);
109
- }
67
+ padding: 10px 0px
68
+ }
69
+ .carousel::-webkit-scrollbar {
70
+ display: none;
71
+ }
72
+ .carousel.no-transition {
73
+ scroll-behavior: auto;
74
+ }
75
+ .carousel.dragging {
76
+ scroll-snap-type: none;
77
+ scroll-behavior: auto;
78
+ }
79
+ .carousel.dragging .card {
80
+ cursor: grab;
81
+ user-select: none;
82
+ }
83
+ .carousel :where(.card, .img) {
84
+ display: flex;
85
+ justify-content: center;
86
+ align-items: center;
87
+ }
88
+ .carousel .card {
89
+ // padding: 0px 5px;
90
+ scroll-snap-align: start;
91
+ width: var(--cardWidth);
92
+ background: rgb(255, 255, 255);
93
+ list-style: none;
94
+ cursor: pointer;
95
+ // padding-bottom: 15px;
96
+ flex-direction: column;
97
+ border-radius: 8px;
98
+ box-shadow: 0 3px 6px rgba(0,0,0,0.23);
99
+ }
100
+ .carousel .card .card-image {
101
+ height: 150px;
102
+ width: var(--cardWidth);
103
+ }
104
+ .card .card-image img {
105
+ height: 100%;
106
+ -o-object-fit: cover;
107
+ object-fit: cover;
110
108
 
111
- .carousel .card-image {
112
- height: 170px;
113
- width: var(--cardWidth);
114
- }
109
+ background: transparent!important;
110
+ display: block;
111
+ max-width: 100% !important;
112
+ border-radius: 8px 8px 0px 0px;
113
+ }
114
+ .carousel .card .card-content {
115
+ // font-weight: 500;
116
+ // font-size: 1.56rem;
117
+ // margin: 30px 0 5px;
118
+ -webkit-box-orient: vertical;
119
+ -webkit-box-direction: normal;
120
+ display: -webkit-box;
121
+ display: -ms-flexbox;
122
+ display: flex;
123
+ -ms-flex-direction: column;
124
+ flex-direction: column;
125
+ padding: 0 20px 30px;
115
126
 
116
- img {
117
- height: 100%;
118
- -o-object-fit: cover;
119
- object-fit: cover;
120
-
121
- background: transparent!important;
122
- display: block;
123
- max-width: 100% !important;
124
- border-radius: 8px 8px 0px 0px;
127
+ .card-title{
128
+ word-wrap: break-word;
129
+ font-size: 16px;
130
+ font-weight: 600;
131
+ line-height: 20px;
132
+ margin-top: 12px;
133
+ white-space: pre-wrap;
134
+ width: 100%;
125
135
  }
126
136
 
127
- .carousel .card-content{
128
- -webkit-box-orient: vertical;
129
- -webkit-box-direction: normal;
130
- display: -webkit-box;
131
- display: -ms-flexbox;
132
- display: flex;
133
- -ms-flex-direction: column;
134
- flex-direction: column;
135
- padding: 0 20px 30px;
136
-
137
- .card-title{
138
- word-wrap: break-word;
139
- font-size: 16px;
140
- font-weight: 600;
141
- line-height: 20px;
142
- margin-top: 12px;
143
- white-space: pre-wrap;
144
- width: 100%;
145
- }
146
-
147
- .card-description{
148
- word-wrap: break-word;
149
- font-size: 16px;
150
- line-height: 20px;
151
- margin-top: 12px;
152
- white-space: pre-wrap;
153
- }
137
+ .card-description{
138
+ word-wrap: break-word;
139
+ font-size: 16px;
140
+ line-height: 20px;
141
+ margin-top: 12px;
142
+ white-space: pre-wrap;
154
143
  }
155
144
 
156
- .carousel .buttons{
157
- -webkit-box-orient: vertical;
158
- -webkit-box-direction: normal;
159
- display: -webkit-box;
160
- display: -ms-flexbox;
161
- display: flex;
162
- -ms-flex-direction: column;
163
- flex-direction: column;
164
- width: 100%;
145
+ }
165
146
 
147
+ .cards-scroll-spacer{
148
+ -ms-flex-negative: 0;
149
+ content: "";
150
+ flex-shrink: 0;
151
+ width: 17px;
152
+ }
166
153
 
167
- .single-button{
168
- // border-top-color: rgb(219, 225, 232);
154
+ .carousel .card .buttons{
155
+ -webkit-box-orient: vertical;
156
+ -webkit-box-direction: normal;
157
+ display: -webkit-box;
158
+ display: -ms-flexbox;
159
+ display: flex;
160
+ -ms-flex-direction: column;
161
+ flex-direction: column;
162
+ width: 100%;
169
163
 
170
- -webkit-box-align: center;
171
- -ms-flex-align: center;
172
- align-items: center;
173
- justify-content: center;
174
- border-top: 1px solid var(--textColor);
175
- cursor: pointer;
176
- display: -webkit-box;
177
- display: -ms-flexbox;
178
- display: flex;
179
- font-weight: 600;
180
- height: 45px;
181
- padding: 0 10px;
182
- -webkit-transition: all .3s;
183
- transition: all .3s;
184
164
 
185
- color: var(--textColor);
186
- background: var(--backgroundColor);
187
- font-family: 'Muli', sans-serif;
188
- font-size: var(--buttonFontSize);
165
+ .single-button{
166
+ // border-top-color: rgb(219, 225, 232);
189
167
 
168
+ -webkit-box-align: center;
169
+ -ms-flex-align: center;
170
+ align-items: center;
171
+ justify-content: center;
172
+ border-top: 1px solid var(--textColor);
173
+ cursor: pointer;
174
+ display: -webkit-box;
175
+ display: -ms-flexbox;
176
+ display: flex;
177
+ font-weight: 600;
178
+ // height: 45px;
179
+ // padding: 0 10px;
180
+ -webkit-transition: all .3s;
181
+ transition: all .3s;
190
182
 
191
- div{
192
- overflow: hidden!important;
193
- text-align: center;
194
- text-overflow: ellipsis;
195
- white-space: nowrap;
196
- width: 100%;
197
- }
183
+ background: var(--backgroundColor);
184
+ font-family: 'Muli', sans-serif;
185
+ font-size: var(--buttonFontSize);
186
+ -o-text-overflow: ellipsis;
187
+ text-overflow: ellipsis;
188
+ // // white-space: nowrap;
189
+ word-wrap: break-word;
190
+ letter-spacing: -0.24px;
191
+ -webkit-font-smoothing: antialiased;
192
+ color: var(--textColor);
193
+ line-height: 16px;
194
+ padding: 8px 16px!important;
198
195
 
199
- &:focus,
200
- &:hover {
201
- color: var(--hoverTextColor);
202
- background: var(--hoverBackgroundColor);
203
- transform: scale(1.05);
204
- .icon-button-action {
205
- svg {
206
- fill: var(--hoverTextColor);
207
- }
196
+ &:focus,
197
+ &:hover {
198
+ color: var(--hoverTextColor);
199
+ background: var(--hoverBackgroundColor);
200
+ // transform: scale(1.05);
201
+ .icon-button-action {
202
+ svg {
203
+ fill: var(--hoverTextColor);
208
204
  }
209
205
  }
210
- &:after {
211
- content: "";
212
- position: absolute;
213
- width: 0;
214
- height: 0;
215
- top: 50%;
216
- left: 50%;
217
- transform-style: flat;
218
- transform: translate3d(-50%,-50%,0);
219
- background: rgba(white,.2);
220
- border-radius: 100%;
221
- transition: width .5s ease, height .5s ease;
206
+ }
207
+ &:after {
208
+ content: "";
209
+ position: absolute;
210
+ width: 0;
211
+ height: 0;
212
+ top: 50%;
213
+ left: 50%;
214
+ transform-style: flat;
215
+ transform: translate3d(-50%,-50%,0);
216
+ background: rgba(white,.2);
217
+ border-radius: 100%;
218
+ transition: width .5s ease, height .5s ease;
219
+ }
220
+ &.active{
221
+ color: var(--hoverTextColor);
222
+ background: var(--hoverBackgroundColor);
223
+ .icon-button-action {
224
+ svg {
225
+ fill: var(--hoverTextColor);
226
+ }
222
227
  }
228
+ }
223
229
 
224
230
 
225
- }
231
+ }
226
232
 
227
- .single-button:last-child{
228
- border-radius: 0px 0px 8px 8px;
229
- }
233
+ .disabled {
234
+ // border: 1px solid #999999;
235
+ // background-color: #cccccc;
236
+ // color: #666666;
237
+ cursor: default;
238
+ pointer-events: none;
230
239
  }
231
- // .card .card-image img {
232
- // width: 140px;
233
- // height: 140px;
234
- // border-radius: 50%;
235
- // object-fit: cover;
236
- // border: 4px solid #fff;
237
- // }
238
- .carousel .card h2 {
239
- font-weight: 500;
240
- font-size: 1.56rem;
241
- margin: 30px 0 5px;
242
- }
243
- .carousel .card span {
240
+
241
+ .single-button:last-child{
242
+ border-radius: 0px 0px 8px 8px;
243
+ }
244
+ }
245
+
246
+ .carousel .card span {
244
247
  color: #6A6D78;
245
248
  font-size: 1.31rem;
246
- }
247
- @media screen and (max-width: 900px) {
248
- .wrapper .carousel {
249
- grid-auto-columns: calc((100% / 2) - 9px);
250
- }
251
- }
252
- @media screen and (max-width: 600px) {
253
- .wrapper .carousel {
254
- // grid-auto-columns: 100%;
255
- grid-auto-columns: 75%;
256
- }
257
- }
249
+ }
250
+ @media screen and (max-width: 900px) {
251
+ .wrapper .carousel {
252
+ grid-auto-columns: calc((100% / 2) - 9px);
253
+ }
254
+ }
255
+ @media screen and (max-width: 600px) {
256
+ .wrapper .carousel {
257
+ grid-auto-columns: var(--cardWidth);
258
+ // grid-auto-columns: 17px repeat(var(--cardWidth)) 17px;
259
+ }
260
+ }
@@ -10,6 +10,8 @@ export class CarouselComponent implements OnInit{
10
10
 
11
11
  // ========= begin:: Input/Output values ============//
12
12
  @Input() message: MessageModel;
13
+ @Input() isConversationArchived: boolean;
14
+ @Input() isLastMessage: boolean;
13
15
  @Input() stylesMap: Map<string, string>;
14
16
  @Output() onAttachmentButtonClicked = new EventEmitter<any>();
15
17
  @Output() onElementRendered = new EventEmitter<{element: string, status: boolean}>()
@@ -26,6 +28,8 @@ export class CarouselComponent implements OnInit{
26
28
  textColor: string;
27
29
  hoverBackgroundColor: string;
28
30
  hoverTextColor: string;
31
+ type: string;
32
+ button: any;
29
33
 
30
34
  constructor(private elementRef: ElementRef) { }
31
35
 
@@ -38,9 +42,8 @@ export class CarouselComponent implements OnInit{
38
42
 
39
43
 
40
44
  // this.firstCardWidth = (this.elementRef.nativeElement.querySelector(".card") as HTMLElement).offsetWidth
41
- console.log('carrrrrrrrr', this.wrapper, this.elementRef.nativeElement.querySelector(".card"))
42
- // Get the number of cards that can fit in the carousel at once
43
- let cardPerView = Math.round(this.carousel.offsetWidth / this.firstCardWidth);
45
+ // // Get the number of cards that can fit in the carousel at once
46
+ // let cardPerView = Math.round(this.carousel.offsetWidth / this.firstCardWidth);
44
47
 
45
48
  // Insert copies of the last few cards to beginning of carousel for infinite scrolling
46
49
  // const carouselChildrens = [...this.carousel.children];
@@ -57,15 +60,11 @@ export class CarouselComponent implements OnInit{
57
60
  this.carousel.scrollLeft = this.carousel.offsetWidth;
58
61
  this.carousel.classList.remove("no-transition");
59
62
 
60
-
61
- console.log('[CAROUSEL-MESSAGE] cardPerView -->', cardPerView, this.carousel.querySelectorAll('.card') )
62
-
63
63
  let currentItem = 0
64
64
  // Store items as an array of objects
65
65
  const items = this.carousel.querySelectorAll('.card')
66
66
 
67
67
  this.carousel.addEventListener("scroll", function(el){
68
- // console.log('elementttt', el)
69
68
  // Find item closest to the goal
70
69
  // currentItem = items.reduce((prev, curr) => {
71
70
  // return (Math.abs(curr.offsetY - scrollY - goal) < Math.abs(prev.offsetY - scrollY - goal) ? curr : prev); // return the closest to the goal
@@ -78,34 +77,63 @@ export class CarouselComponent implements OnInit{
78
77
  if(this.message && this.message.attributes && this.message.attributes?.attachment && this.message.attributes?.attachment?.gallery){
79
78
  this.gallery = this.message.attributes.attachment.gallery
80
79
  console.log('carrrrrrrrr', this.wrapper, this.elementRef.nativeElement.querySelector(".card"))
81
-
80
+ // this.firstCardWidth = (this.elementRef.nativeElement.querySelector(".card") as HTMLElement).offsetWidth
82
81
  }
83
82
 
84
- if(this.stylesMap){
85
- if(this.stylesMap.has('buttonFontSize')) this.elementRef.nativeElement.querySelector('.action').style.setProperty('--buttonFontSize', this.stylesMap.has('buttonFontSize'));
86
- if(this.stylesMap.has('buttonBackgroundColor')) this.elementRef.nativeElement.querySelector('.action').style.setProperty('--backgroundColor', this.stylesMap.has('buttonBackgroundColor'));
87
- if(this.stylesMap.has('buttonTextColor')) this.elementRef.nativeElement.querySelector('.action').style.setProperty('--textColor', this.stylesMap.has('buttonTextColor'));
88
- if(this.stylesMap.has('buttonHoverBackgroundColor')) this.elementRef.nativeElement.querySelector('.action').style.setProperty('--hoverBackgroundColor', this.stylesMap.has('buttonHoverBackgroundColor'));
89
- if(this.stylesMap.has('buttonHoverTextColor')) this.elementRef.nativeElement.querySelector('.action').style.setProperty('--hoverTextColor', this.stylesMap.has('buttonHoverTextColor'));
83
+ if(this.stylesMap ){
84
+ if(this.stylesMap.has('buttonFontSize')) this.elementRef.nativeElement.querySelector('.wrapper').style.setProperty('--buttonFontSize', this.stylesMap.get('buttonFontSize'));
85
+ if(this.stylesMap.has('buttonBackgroundColor')) this.elementRef.nativeElement.querySelector('.wrapper').style.setProperty('--backgroundColor', this.stylesMap.get('buttonBackgroundColor'));
86
+ if(this.stylesMap.has('buttonTextColor')) this.elementRef.nativeElement.querySelector('.wrapper').style.setProperty('--textColor', this.stylesMap.get('buttonTextColor'));
87
+ if(this.stylesMap.has('buttonHoverBackgroundColor')) this.elementRef.nativeElement.querySelector('.wrapper').style.setProperty('--hoverBackgroundColor', this.stylesMap.get('buttonHoverBackgroundColor'));
88
+ if(this.stylesMap.has('buttonHoverTextColor')) this.elementRef.nativeElement.querySelector('.wrapper').style.setProperty('--hoverTextColor', this.stylesMap.get('buttonHoverTextColor'));
90
89
  }
91
-
92
-
90
+
93
91
  }
94
92
 
95
93
  goTo(direction: 'next' | 'previous' ){
96
- let width = (this.carousel.querySelector(".card") as HTMLElement).offsetWidth
97
- let gap = Math.round( 16 / 2)
94
+ let width = (this.carousel.querySelectorAll(".card")[1] as HTMLElement).offsetWidth
95
+ let gap = 17
98
96
  let cardPerView = Math.round(this.carousel.offsetWidth / width);
99
97
 
100
- console.log('go to -->', direction, width, cardPerView, this.carousel.offsetWidth)
98
+ console.log('go to -->', direction, width, this.firstCardWidth, cardPerView, this.carousel.offsetWidth)
101
99
 
102
- this.carousel.scrollLeft += direction == "previous" ? -(width+gap) : width+gap;
103
- // this.activeElement += direction == "previous" ? -1 : 1;
100
+ // this.carousel.scrollLeft += direction == "previous" ? -(width+gap) : width+gap;
101
+ this.carousel.scrollLeft += direction == "previous" ? -width : width;
102
+ this.activeElement += direction == "previous" ? -1 : 1;
104
103
 
105
104
  // this.carousel.classList.add("no-transition");
106
105
  // this.carousel.scrollLeft += width;
107
106
  // this.carousel.classList.remove("no-transition");
108
107
 
108
+ }
109
109
 
110
+ actionButtonClick(ev, button, index){
111
+ this.button = button
112
+ this.type = button.type
113
+ console.log('buttonnnnnnn', ev, button)
114
+ if ( button && ((button.action && button.action !== '') || (button.link && button.link !== '') || button.text !== '' )) {
115
+
116
+ //set clicked button as the active one
117
+ this.gallery[index].buttons.find((element)=> { return element === button}).active = true
118
+ const spanCheck = this.elementRef.nativeElement.querySelector('.action');
119
+ if (spanCheck) {
120
+ // const item = domRepresentation[0] as HTMLInputElement;
121
+ // if (!spanCheck.classList.contains('active')) {
122
+ // spanCheck.classList.add('active');
123
+ // }
124
+ // setTimeout(function() {
125
+ // if (spanCheck.classList.contains('active')) {
126
+ // spanCheck.classList.remove('active');
127
+ // }
128
+ // }, 400);
129
+ ev.target.classList.add('active')
130
+ // event.target.classList
131
+ }
132
+ const event = { target: this, currentTarget: this}
133
+ if ( event && event.target ) {
134
+ const ev = {target: event.target, message: this.message, currentTarget: this }
135
+ this.onAttachmentButtonClicked.emit(ev);
136
+ }
137
+ }
110
138
  }
111
139
  }
@@ -507,6 +507,18 @@ export class GlobalSettingsService {
507
507
  if (variables.hasOwnProperty('fileUploadAccept')) {
508
508
  globals['fileUploadAccept'] = variables['fileUploadAccept'];
509
509
  }
510
+ if (variables.hasOwnProperty('displayOnDesktop')) {
511
+ globals['displayOnDesktop'] = variables['displayOnDesktop'];
512
+ }
513
+ if (variables.hasOwnProperty('displayOnMobile')) {
514
+ globals['displayOnMobile'] = variables['displayOnMobile'];
515
+ }
516
+ if (variables.hasOwnProperty('onPageChangeVisibilityDesktop')) {
517
+ globals['onPageChangeVisibilityDesktop'] = variables['onPageChangeVisibilityDesktop'];
518
+ }
519
+ if (variables.hasOwnProperty('onPageChangeVisibilityMobile')) {
520
+ globals['onPageChangeVisibilityMobile'] = variables['onPageChangeVisibilityMobile'];
521
+ }
510
522
 
511
523
  }
512
524
  }
@@ -1023,6 +1035,26 @@ export class GlobalSettingsService {
1023
1035
  // this.logger.debug('[GLOBAL-SET] setVariablesFromSettings > disconnetTime:: ', TEMP]);
1024
1036
  if (TEMP !== undefined) {
1025
1037
  globals.disconnetTime = +TEMP;
1038
+ }
1039
+ TEMP = tiledeskSettings['displayOnDesktop'];
1040
+ // this.logger.debug('[GLOBAL-SET] setVariablesFromSettings > displayOnDesktop:: ', TEMP]);
1041
+ if (TEMP !== undefined) {
1042
+ globals.displayOnDesktop = (TEMP === true) ? true : false;
1043
+ }
1044
+ TEMP = tiledeskSettings['displayOnMobile'];
1045
+ // this.logger.debug('[GLOBAL-SET] setVariablesFromSettings > displayOnMobile:: ', TEMP]);
1046
+ if (TEMP !== undefined) {
1047
+ globals.displayOnMobile = (TEMP === true) ? true : false;
1048
+ }
1049
+ TEMP = tiledeskSettings['onPageChangeVisibilityDesktop'];
1050
+ // this.logger.debug('[GLOBAL-SET] setVariablesFromSettings > onPageChangeVisibilityDesktop:: ', TEMP]);
1051
+ if (TEMP !== undefined) {
1052
+ globals.onPageChangeVisibilityDesktop = TEMP;
1053
+ }
1054
+ TEMP = tiledeskSettings['onPageChangeVisibilityMobile'];
1055
+ // this.logger.debug('[GLOBAL-SET] setVariablesFromSettings > onPageChangeVisibilityMobile:: ', TEMP]);
1056
+ if (TEMP !== undefined) {
1057
+ globals.onPageChangeVisibilityMobile = TEMP;
1026
1058
  }
1027
1059
  }
1028
1060
 
@@ -213,6 +213,11 @@ export class Globals {
213
213
  telegramUsername: string; // ******* new ********
214
214
  fileUploadAccept: string; // ******* new ********
215
215
  disconnetTime: number; // ******* new ********
216
+
217
+ onPageChangeVisibilityMobile: 'open' | 'close' | 'last'; // ******* new ********
218
+ onPageChangeVisibilityDesktop: 'open' | 'close' | 'last'; // ******* new ********
219
+ displayOnMobile: boolean; // ******* new ********
220
+ displayOnDesktop: boolean; // ******* new ********
216
221
  constructor(
217
222
  ) { }
218
223
 
@@ -402,6 +407,14 @@ export class Globals {
402
407
  this.showAttachmentButton = true;
403
408
  this.showAllConversations = true;
404
409
 
410
+ //WIDGET VISIBILITY - desktop
411
+ this.displayOnDesktop = true
412
+ this.onPageChangeVisibilityDesktop ='close'
413
+ //WIDGET VISIBILITY - mobile
414
+ this.displayOnMobile = true
415
+ this.onPageChangeVisibilityMobile = 'close'
416
+
417
+
405
418
  // ============ END: SET EXTERNAL PARAMETERS ==============//
406
419
 
407
420