UNPKG

barsa-novin-ray-core

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.6.

1,462 lines (1,452 loc) 735 kB
import * as i0 from '@angular/core'; import { Injectable, inject, ElementRef, Input, ChangeDetectionStrategy, Component, Pipe, ComponentFactoryResolver, Injector, ApplicationRef, Compiler, signal, DOCUMENT, NgModuleFactory, InjectionToken, NgZone, EventEmitter, ChangeDetectorRef, Renderer2, HostBinding, Output, HostListener, ViewContainerRef, ViewChild, Directive, TemplateRef, input, NgModule, NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA, provideAppInitializer, ErrorHandler } from '@angular/core'; import { Subject, from, BehaviorSubject, of, exhaustMap, map as map$1, combineLatest, fromEvent, forkJoin, throwError, merge, interval, filter as filter$1, tap as tap$1, concatMap as concatMap$1, catchError as catchError$1, finalize as finalize$1, Observable, takeUntil as takeUntil$1, timer, debounceTime as debounceTime$1, mergeWith, Subscription } from 'rxjs'; import * as i1 from '@angular/router'; import { Router, NavigationEnd, ActivatedRoute, NavigationStart, RouterEvent, RouterModule } from '@angular/router'; import { DomSanitizer, Title } from '@angular/platform-browser'; import { filter, startWith, map, tap, takeUntil, withLatestFrom, delay, debounceTime, distinctUntilChanged, exhaustMap as exhaustMap$1, concatMap, finalize, publishReplay, refCount, shareReplay, switchMap, catchError, merge as merge$1, pluck, mergeWith as mergeWith$1 } from 'rxjs/operators'; import moment from 'moment'; import moment$1 from 'moment-hijri'; import 'moment/locale/ar'; import moment$2 from 'moment-jalaali'; import 'moment/locale/fa'; import { _isNumberValue } from '@angular/cdk/coercion'; import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClient, HttpEventType, HttpErrorResponse, HttpHeaders, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; import * as i1$1 from '@angular/common'; import { Location, TitleCasePipe, CommonModule } from '@angular/common'; import RecordRTC from 'recordrtc'; import { SwUpdate, SwPush } from '@angular/service-worker'; import Splide from '@splidejs/splide'; class BarsaApi { static { this.idGenerator = -10000; } static get GanttChartHelper() { return GanttChartHelper; } static get Offline() { return Offline; } static get Ext() { return Ext; } static get Common() { return Common; } static get Util() { return Util; } static get Ul() { return Ul; } static get Ui() { return Ui; } static get Bw() { return Bw; } static get BBB() { return BBB; } static get LoginForm() { return LoginForm; } static get LoginAction() { return LoginAction; } static get LoginFormUi() { return LoginFormUi; } static get LoginFormData() { return LoginFormData; } } // angular class LogService { static { this.DEBUG = { LEVEL_1: false, // .warn only LEVEL_2: false, // .error only LEVEL_3: false, // .log + all the above LEVEL_4: false, // .log + all the above + info LEVEL_5: false // just info (excluding all else) }; } // info (extra messages like analytics) // use LEVEL_5 to see only these info(...msg) { if (LogService.DEBUG.LEVEL_5 || LogService.DEBUG.LEVEL_4) { // extra messages /* eslint-disable */ console.info(msg); } } // debug (standard output) debug(...msg) { if (LogService.DEBUG.LEVEL_4 || LogService.DEBUG.LEVEL_3) { // console.debug does not work on {N} apps... use `log` /* eslint-disable */ console.debug(msg); } } // error error(...err) { if (LogService.DEBUG.LEVEL_4 || LogService.DEBUG.LEVEL_3 || LogService.DEBUG.LEVEL_2) { console.error(err); } } // warn warn(...warn) { if (LogService.DEBUG.LEVEL_4 || LogService.DEBUG.LEVEL_3 || LogService.DEBUG.LEVEL_1) { console.warn(warn); } } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LogService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: LogService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }] }); class BaseComponent { constructor() { this._el = inject(ElementRef); this._log = inject(LogService); this._onDestroy$ = new Subject(); } get el() { return this._el; } ngAfterContentInit() { if (!BarsaApi.Common.Debug?.Data?.CustomUi) { return; } console.log('ngAfterContentInit'); console.log(this); } ngOnChanges(changes) { if (!BarsaApi.Common.Debug?.Data?.CustomUi) { return; } console.log(changes); } ngOnInit() { this.rendered = true; if (!BarsaApi.Common.Debug?.Data?.CustomUi) { return; } console.log('ngOnInit'); console.log(this); } ngAfterViewInit() { if (!BarsaApi.Common.Debug?.Data?.CustomUi) { return; } console.log('ngAfterViewInit'); console.log(this); } ngOnDestroy() { this._onDestroy$.next(); this._onDestroy$.complete(); if (!BarsaApi.Common.Debug?.Data?.CustomUi) { return; } console.log('ngOnDestroy'); console.log(this); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: BaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: BaseComponent, isStandalone: false, selector: "bnrc-base", inputs: { rendered: "rendered" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: BaseComponent, decorators: [{ type: Component, args: [{ selector: 'bnrc-base', template: '', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false }] }], propDecorators: { rendered: [{ type: Input }] } }); class EmptyPageWithRouterAndRouterOutletComponent extends BaseComponent { constructor() { super(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: EmptyPageWithRouterAndRouterOutletComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: EmptyPageWithRouterAndRouterOutletComponent, isStandalone: false, selector: "bnrc-empty-page-with-router-and-router-outlet", usesInheritance: true, ngImport: i0, template: "<ng-container #containerRef></ng-container>\r\n<router-outlet></router-outlet>\r\n<router-outlet name=\"main\"></router-outlet>\r\n", styles: [""], dependencies: [{ kind: "directive", type: i1.RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: EmptyPageWithRouterAndRouterOutletComponent, decorators: [{ type: Component, args: [{ selector: 'bnrc-empty-page-with-router-and-router-outlet', changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, template: "<ng-container #containerRef></ng-container>\r\n<router-outlet></router-outlet>\r\n<router-outlet name=\"main\"></router-outlet>\r\n" }] }], ctorParameters: () => [] }); class DateService { constructor() { this.logService = new LogService(); } get now() { return new Date(); } monthNames() { return moment.localeData(this.locale).months(); } includeDay(date, startDate, endDate) { return moment(date).isBetween(startDate, endDate); } duration(inp, _) { return moment.duration(inp); } day(date) { return moment(date).weekday(); } getDayStr(mode) { let date; switch (mode) { case 'Today': date = this.now; break; case 'DaysBefore': date = new Date(this.now.setDate(this.now.getDate() - 1)); break; case 'DaysAfter': date = new Date(this.now.setDate(this.now.getDate() + 1)); break; } const momentOfDate = this.getMoment(date); return this.getDateString(momentOfDate, true, false); } getMonthStr(mode) { const momentOfDate = this.getMoment(this.now); let date; switch (mode) { case 'ThisMonth': date = this.now; break; case 'NextMonth': date = this.addMonth(momentOfDate, 1); break; case 'PrevMonth': date = this.subtractMonth(momentOfDate, 1); break; default: date = this.now; break; } const dateInfo = this.getDateInfo(date); return dateInfo.monthName + ' ' + dateInfo.strYear; } getYearStr(mode) { let year; const thisYear = this.getDateInfo(this.now).year; switch (mode) { case 'ThisYear': year = thisYear; break; case 'PrevYear': year = thisYear - 1; break; case 'NextYear': year = thisYear + 1; break; default: year = thisYear; break; } return year; } getWeekStr(mode) { const { from, to } = this.getWeekRange(mode); const strFirstDate = this.getDateString(from, true, false); const strLastDate = this.getDateString(to, true, false); return strFirstDate + this.toText() + strLastDate; } getWeekRange(mode) { let from = moment(); let to = moment(); from.locale(this.locale); to.locale(this.locale); switch (mode) { case 'ThisWeek': from = from.startOf('week'); to = to.endOf('week'); break; case 'NextWeek': from = from.day(+7).startOf('week'); to = to.day(+7).endOf('week'); break; case 'PrevWeek': from = from.day(-7).startOf('week'); to = to.day(-7).endOf('week'); break; } return { from, to }; } format(value, format) { const m = this.getMoment(value); return m.format(format); } getShortDateString(date) { const m = moment(date); m.locale('fa'); const format = 'YYYY/MM/DD'; return m.format(format); } checkSame(moment1, moment2, mode, prefix) { const yearF = `${prefix}YYYY`; const monthF = `${prefix}MM`; const dayF = `${prefix}DD`; const dayCompare = yearF + monthF + dayF; const monthCompare = yearF + monthF; const yearCompare = yearF; let val1; let val2; switch (mode) { case 'day': val1 = moment1.format(dayCompare); val2 = moment2.format(dayCompare); break; case 'month': val1 = moment1.format(monthCompare); val2 = moment2.format(monthCompare); break; case 'year': val1 = moment1.format(yearCompare); val2 = moment2.format(yearCompare); break; } return val1 === val2; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateService, decorators: [{ type: Injectable }] }); class DateHijriService extends DateService { constructor() { super(...arguments); this.locale = 'ar'; } getTimes(date) { return moment$1(date).format('HH:mm'); } weeksCount(momentObj) { return moment$1.duration(moment$1(momentObj).endOf('iMonth') - moment$1(momentObj).startOf('iMonth')).weeks() + 1; } subtractMonth(momentOfDate, value) { return momentOfDate.subtract(value, 'iMonth').toDate(); } addMonth(momentOfDate, value) { return momentOfDate.add(value, 'iMonth').toDate(); } toText() { return 'الی '; } to(date1, date2) { return moment$1(date1).to(date2); } from(date1, date2) { return moment$1(date1).from(date2); } isSame(date1, date2, mode) { const m1 = moment$1(date1); const m2 = moment$1(date2); return this.checkSame(m1, m2, mode, 'i'); } strDate(date) { return moment$1(date).format('iD'); } weekdaysMin() { return moment$1.weekdaysMin(); } weekDays() { return moment$1.weekdays(); } date(date) { return moment$1(date).iDate(); } endOfMonth(date) { return moment$1(date).endOf('iMonth').format('iYYYY-iMM-iDD hh:mm'); } startOfMonth(date) { return moment$1(date).startOf('iMonth').format('iYYYY-iMM-iDD hh:mm'); } getDateInfo(date) { const m = moment$1(date); const shamsi = { year: m.iYear(), month: m.iMonth(), day: m.iDate(), hour: m.hour(), minutes: m.minute(), strYear: m.format('iYYYY'), strMonth: m.format('iM'), strDay: m.format('iD'), monthName: m.format('iMMMM'), dayInWeek: 0, dayName: m.format('dddd'), moment: m, date }; shamsi.dayInWeek = m.daysInMonth(shamsi.year, shamsi.month); return shamsi; } daysInMonth(year, month) { return moment$1.jDaysInMonth(year, month); } getMoment(date) { if (!date) { date = new Date(); } return moment$1(date); } stringToMoment(str, format) { return moment$1(str, format); } getStrMonthName(date) { return moment$1(date).format('iMMMM'); } parse(payload) { const { year, month, day, hour, minutes } = payload; const format = 'iYYYY-iM-iD HH:mm'; const value = `${year}-${month}-${day} ${hour}:${minutes}`; if (this.logService) { this.logService.info(value, format); } return moment$1(value, format); } monthNames() { return moment$1.localeData()._iMonths; } format(value, format) { const m = this.getMoment(value); format = format.indexOf('YYYY') > -1 ? format.replace('YYYY', 'i1111') : format; format = format.indexOf('YY') > -1 ? format.replace('YY', 'i11') : format; format = format.indexOf('MMMM') > -1 ? format.replace('MMMM', 'i2222') : format; format = format.indexOf('MM') > -1 ? format.replace('MM', 'i22') : format; format = format.indexOf('DD') > -1 ? format.replace('DD', 'i33') : format; format = format.replace(/1/g, 'Y'); format = format.replace(/2/g, 'M'); format = format.replace(/3/g, 'D'); return m.format(format); } getShortDateString(date) { const m = moment$1(date); m.locale('ar-SA'); const format = 'iYYYY/iMM/iDD'; return m.format(format); } getDateTimeString(date) { const m = moment$1(date); m.locale('ar-SA'); return m.format('iYYYY-iMM-iDD HH:mm'); } getDateString(date, showDate, showTime) { const m = moment$1(date); let format = 'dddd'; if (showDate) { format = `${format} iYYYY/iMM/iDD `; } if (showTime) { format = `${format} HH:mm`; } return m.format(format); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateHijriService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateHijriService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateHijriService, decorators: [{ type: Injectable }] }); class DateMiladiService extends DateService { constructor() { super(); this.locale = 'en'; moment.locale('en'); } getTimes(date) { return moment(date).format('HH:mm'); } weeksCount(momentObj) { return moment.duration(moment(momentObj).endOf('month').diff(moment(momentObj).startOf('month'))).asWeeks() + 1; } subtractMonth(momentOfDate, value) { return momentOfDate.subtract(value, 'months').toDate(); } addMonth(momentOfDate, value) { return momentOfDate.add(value, 'months').toDate(); } to(date1, date2) { return moment(date1).to(date2); } from(date1, date2) { return moment(date1).from(date2); } isSame(date1, date2, mode) { return moment(date1).isSame(date2, mode); } strDate(date) { return moment(date).format('D'); } toText() { return 'to '; } date(date) { return moment(date).date(); } endOfMonth(date) { return new Date(moment(date).endOf('month').format('YYYY-MM-DD hh:mm')); } startOfMonth(date) { return new Date(moment(date).startOf('month').format('YYYY-MM-DD hh:mm')); } getDateInfo(date) { const m = moment(date); const miladi = { year: m.year(), month: m.month(), day: m.date(), hour: m.hour(), minutes: m.minute(), strYear: m.format('YYYY'), strMonth: m.format('M'), strDay: m.format('D'), monthName: m.format('MMMM'), dayInWeek: 0, moment: m, dayName: m.format('dddd'), date }; miladi.dayInWeek = m.daysInMonth(); return miladi; } daysInMonth(year, month) { return moment([year, month]).daysInMonth(); } getMoment(date) { if (!date) { date = new Date(); } return moment(date); } stringToMoment(str, format) { return moment(str, format); } getStrMonthName(date) { return moment(date).format('MMMM'); } parse(payload) { const { year, month, day, hour, minutes } = payload; const format = 'YYYY-M-D HH:mm'; const value = `${year}-${month}-${day} ${hour}:${minutes}`; if (this.logService) { this.logService.info(value, format); } return moment(value, format); } getDateString(date, showDate, showTime) { const m = moment(date); m.locale('en'); let format = 'dddd'; if (showDate) { format = `${format} DD MM YYYY`; } if (showTime) { format = `${format} HH:mm`; } return m.format(format); } getDateTimeString(date) { const m = moment(date); m.locale('en'); return m.format('YYYY-MM-DD HH:mm'); } weekdaysMin() { return moment.weekdaysMin(); } weekDays() { return moment.weekdays(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateMiladiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateMiladiService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateMiladiService, decorators: [{ type: Injectable }], ctorParameters: () => [] }); class DateShamsiService extends DateService { constructor() { super(); this.locale = 'fa'; moment$2.loadPersian({ usePersianDigits: true, dialect: 'persian-modern' }); } getTimes(date) { return moment$2(date).format('HH:mm'); } weeksCount(momentObj) { return moment$2.duration(moment$2(momentObj).endOf('jMonth') - moment$2(momentObj).startOf('jMonth')).weeks() + 1; } subtractMonth(momentOfDate, value) { return momentOfDate.subtract(value, 'jMonth').toDate(); } addMonth(momentOfDate, value) { return momentOfDate.add(value, 'jMonth').toDate(); } to(date1, date2) { return moment$2(date1).to(date2); } from(date1, date2) { return moment$2(date1).from(date2); } isSame(date1, date2, mode) { const m1 = moment$2(date1); const m2 = moment$2(date2); return this.checkSame(m1, m2, mode, 'j'); } strDate(date) { return moment$2(date).format('jD'); } weekdaysMin() { return 'ش_ی_د_س_چ_پ_ج'.split('_'); } weekDays() { return 'شنبه_یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه'.split('_'); } toText() { return 'تا '; } date(date) { return moment$2(date).jDate(); } endOfMonth(date) { return moment$2(date).endOf('jMonth').toDate(); } startOfMonth(date) { return moment$2(date).startOf('jMonth').toDate(); } monthNames() { return moment$2.localeData()._jMonths; } getDateInfo(date) { const m = moment$2(date); const shamsi = { year: m.jYear(), month: m.jMonth(), day: m.jDate(), hour: m.hour(), minutes: m.minute(), strYear: m.format('jYYYY'), strMonth: m.format('jM'), strDay: m.format('jD'), monthName: m.format('jMMMM'), dayInWeek: 0, moment: m, dayName: m.format('dddd'), date }; shamsi.dayInWeek = m.daysInMonth(shamsi.year, shamsi.month); return shamsi; } daysInMonth(year, month) { return moment$2.jDaysInMonth(year, month); } getMoment(date) { if (!date) { date = new Date(); } return moment$2(date); } stringToMoment(str, format) { format = this.convertFormatToJalali(format); return moment$2(str, format, true); } getStrMonthName(date) { return moment$2(date).format('jMMMM'); } getDateTimeString(date) { const m = moment$2(date); m.locale('fa'); return m.format('jYYYY/jMM/jDD HH:mm'); } format(value, format) { const m = this.getMoment(value); format = this.convertFormatToJalali(format); return m.format(format); } convertFormatToJalali(format) { format = format.indexOf('YYYY') > -1 ? format.replace('YYYY', 'j1111') : format; format = format.indexOf('YY') > -1 ? format.replace('YY', 'j11') : format; format = format.indexOf('MMMM') > -1 ? format.replace('MMMM', 'j2222') : format; format = format.indexOf('MM') > -1 ? format.replace('MM', 'j22') : format; format = format.indexOf('DD') > -1 ? format.replace('DD', 'j33') : format; format = format.replace(/1/g, 'Y'); format = format.replace(/2/g, 'M'); format = format.replace(/3/g, 'D'); return format; } getShortDateString(date) { const m = moment$2(date); m.locale('fa'); const format = 'jYYYY/jMM/jDD'; return m.format(format); } getDateString(date, showDate, showTime) { const m = moment$2(date); m.locale('fa'); let format = ''; if (showDate) { format = `dddd jYYYY/jMM/jDD`; } if (showTime) { format = `${format} HH:mm`; } return m.format(format); } parse(payload) { const { year, month, day, hour, minutes } = payload; const format = 'jYYYY-jM-jD HH:mm'; const value = `${year}-${month}-${day} ${hour}:${minutes}`; if (this.logService) { this.logService.info(value, format); } return moment$2(value, format); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateShamsiService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateShamsiService }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: DateShamsiService, decorators: [{ type: Injectable }], ctorParameters: () => [] }); /* eslint-disable */ const Device = {}; // * ******* OS Detection ******** /** * Contains information about the operating system of the Device. * @name Device.os */ /** * Enumeration containing the names of known operating systems. * @name Device.os.OS */ /** * The name of the operating system. * @name Device.os.name * @type String */ /** * The version of the operating system as <code>string</code>. Might be empty if no version can be determined. * @name Device.os.versionStr * @type String */ /** * The version of the operating system as <code>float</code>. Might be <code>-1</code> if no version can be determined. * @name Device.os.version * @type float */ /** * If this flag is set to <code>true</code>, a Windows operating system is used. * @name Device.os.windows * @type boolean */ /** * If this flag is set to <code>true</code>, a Mac operating system is used. * @name Device.os.macintosh * @type boolean */ /* * If this flag is set to <code>true</code>, an iOS operating system is used. * @name Device.os.ios * @type boolean */ /** * If this flag is set to <code>true</code>, an Android operating system is used. * @name Device.os.android * @type boolean */ /* * Windows operating system name. * @see Device.os.name * @name Device.os.OS.WINDOWS */ /** * MAC operating system name. * @see Device.os.name * @name Device.os.OS.MACINTOSH */ /** * iOS operating system name. * @see Device.os.name * @name Device.os.OS.IOS */ /** * Android operating system name. * @see Device.os.name * @name Device.os.OS.ANDROID */ const OS = { WINDOWS: 'win', MACINTOSH: 'mac', IOS: 'iOS', ANDROID: 'Android' }; const _getMobileOS = () => { const userAgent = navigator.userAgent; // iOS, Android let rPlatform = /\(([a-zA-Z ]+);\s(?:[U]?[;]?)([\D]+)((?:[\d._]*))(?:.*[)][^\d]*)([\d.]*)\s/; let aMatches = userAgent.match(rPlatform); if (aMatches) { const rAppleDevices = /iPhone|iPad|iPod/; if (aMatches[0].match(rAppleDevices)) { aMatches[3] = aMatches[3].replace(/_/g, '.'); return { name: OS.IOS, versionStr: aMatches[3] }; } if (aMatches[2].match(/Android/)) { aMatches[2] = aMatches[2].replace(/\s/g, ''); return { name: OS.ANDROID, versionStr: aMatches[3] }; } } // Firefox on Android rPlatform = /\((Android)[\s]?([\d][.\d]*)?;.*Firefox\/[\d][.\d]*/; aMatches = userAgent.match(rPlatform); if (aMatches) { return { name: OS.ANDROID, versionStr: aMatches.length === 3 ? aMatches[2] : '' }; } return {}; }; const _getDesktopOS = () => { const sPlatform = navigator.platform; if (sPlatform.indexOf('Win') !== -1) { const rVersion = /Windows NT (\d+).(\d)/i; // userAgent since windows 10: Windows NT 10[...] const uaResult = navigator.userAgent.match(rVersion); return { name: OS.WINDOWS, versionStr: (uaResult && uaResult[1]) || '' }; } if (sPlatform.indexOf('Mac') !== -1) { return { name: OS.MACINTOSH, versionStr: '' }; } return null; }; const _getOS = () => _getMobileOS() || _getDesktopOS(); const _setOS = () => { if (Device.os) { return; } Device.os = _getOS() || {}; Device.os.OS = OS; Device.os.version = Device.os.versionStr ? parseFloat(Device.os.versionStr) : -1; if (Device.os.name) { Object.keys(OS).forEach((name) => { if (OS[name] === Device.os.name) { Device.os[name.toLowerCase()] = true; } }); } }; const getOS = () => { if (!Device.os) { _setOS(); } return Device.os; }; const isAndroid = () => { if (!Device.os) { _setOS(); } return !!Device.os.android; }; // * ******* Browser Detection ******** /** * Contains information about the used browser. * @name Device.browser */ /** * Enumeration containing the names of known browsers. * @name Device.browser.BROWSER * * The name of the browser. * @name Device.browser.name * @type String */ /** * The version of the browser as <code>string</code>. Might be empty if no version can be determined. * @name Device.browser.versionStr * @type String */ /** * The version of the browser as <code>float</code>. Might be <code>-1</code> if no version can be determined. * @name Device.browser.version * @type float */ /** * If this flag is set to <code>true</code>, the mobile variant of the browser is used or * a tablet or phone device is detected. This information might not be available for all browsers. * @name Device.browser.mobile * @type boolean */ /** * If this flag is set to <code>true</code>, the Microsoft Internet Explorer browser is used. * @name Device.browser.internet_explorer * @type boolean * @deprecated since 1.20, use {@link Device.browser.msie} instead. */ /** * If this flag is set to <code>true</code>, the Microsoft Internet Explorer browser is used. * @name Device.browser.msie * @type boolean */ /** * If this flag is set to <code>true</code>, the Microsoft Edge browser is used. * @name Device.browser.edge * @type boolean */ /** * If this flag is set to <code>true</code>, the Mozilla Firefox browser is used. * @name Device.browser.firefox */ /** * If this flag is set to <code>true</code>, the Google Chrome browser is used. * @name Device.browser.chrome * @type boolean * * If this flag is set to <code>true</code>, the Apple Safari browser is used. * * <b>Note:</b> * This flag is also <code>true</code> when the standalone (fullscreen) mode or webview is used on iOS devices. * Please also note the flags {@link Device.browser.fullscreen} and {@link Device.browser.webview}. * * @name Device.browser.safari * @type boolean */ /** * If this flag is set to <code>true</code>, a browser featuring a Webkit engine is used. * * <b>Note:</b> * This flag is also <code>true</code> when the used browser was based on the Webkit engine, but * uses another rendering engine in the meantime. For example the Chrome browser started from version 28 and above * uses the Blink rendering engine. * * @name Device.browser.webkit * @type boolean */ /** * If this flag is set to <code>true</code>, the Safari browser runs in standalone fullscreen mode on iOS. * * <b>Note:</b> This flag is only available if the Safari browser was detected. Furthermore, if this mode is detected, * technically not a standard Safari is used. There might be slight differences in behavior and detection, e.g. * the availability of {@link Device.browser.version}. * * @name Device.browser.fullscreen * @type boolean */ /** * If this flag is set to <code>true</code>, the Safari browser runs in webview mode on iOS. * * <b>Note:</b> This flag is only available if the Safari browser was detected. Furthermore, if this mode is detected, * technically not a standard Safari is used. There might be slight differences in behavior and detection, e.g. * the availability of {@link Device.browser.version}. * * @name Device.browser.webview * @type boolean */ /** * If this flag is set to <code>true</code>, the Phantom JS browser is used. * @name Device.browser.phantomJS * @type boolean */ /** * The version of the used Webkit engine, if available. * @name Device.browser.webkitVersion * @type String */ /** * If this flag is set to <code>true</code>, a browser featuring a Mozilla engine is used. * @name Device.browser.mozilla * @type boolean */ /** * Internet Explorer browser name. * @name Device.browser.BROWSER.INTERNET_EXPLORER */ /** * Edge browser name. * @name Device.browser.BROWSER.EDGE */ /** * Firefox browser name. * @name Device.browser.BROWSER.FIREFOX */ /** * Chrome browser name. * @name Device.browser.BROWSER.CHROME */ /** * Safari browser name. * @name Device.browser.BROWSER.SAFARI */ /** * Android stock browser name. * @name Device.browser.BROWSER.ANDROID */ const BROWSER = { INTERNET_EXPLORER: 'ie', EDGE: 'ed', FIREFOX: 'ff', CHROME: 'cr', SAFARI: 'sf', ANDROID: 'an' }; /* ! * Taken from jQuery JavaScript Library v1.7.1 * http://jquery.com/ * * Copyright 2011, John Resig * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * Includes Sizzle.js * http://sizzlejs.com/ * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * * Date: Mon Nov 21 21:11:03 2011 -0500 */ const _calcBrowser = () => { const sUserAgent = navigator.userAgent.toLowerCase(); const rwebkit = /(webkit)[ /]([\w.]+)/; const rmsie = /(msie) ([\w.]+)/; const rmsie11 = /(trident)\/[\w.]+;.*rv:([\w.]+)/; const redge = /(edge)[ /]([\w.]+)/; const rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/; // WinPhone IE11 and MS Edge userAgents contain "WebKit" and "Mozilla" and therefore must be checked first const browserMatch = redge.exec(sUserAgent) || rmsie11.exec(sUserAgent) || rwebkit.exec(sUserAgent) || rmsie.exec(sUserAgent) || (sUserAgent.indexOf('compatible') < 0 && rmozilla.exec(sUserAgent)) || []; const oRes = { browser: browserMatch[1] || '', version: browserMatch[2] || '0' }; oRes[oRes.browser] = true; return oRes; }; const _getBrowser = () => { const oBrowser = _calcBrowser(); const sUserAgent = navigator.userAgent; const oNavigator = window.navigator; // jQuery checks for user agent strings. We differentiate between browsers let oExpMobile; let oResult; let fVersion; // Mozilla if (oBrowser.mozilla) { oExpMobile = /Mobile/; if (sUserAgent.match(/Firefox\/(\d+\.\d+)/)) { fVersion = parseFloat(RegExp.$1); oResult = { name: BROWSER.FIREFOX, versionStr: `${fVersion}`, version: fVersion, mozilla: true, mobile: oExpMobile.test(sUserAgent) }; } else { // unknown mozilla browser oResult = { mobile: oExpMobile.test(sUserAgent), mozilla: true, version: -1 }; } } else if (oBrowser.webkit) { // webkit version is needed for calculation if the mobile android device is a tablet (calculation of other mobile devices work without) const regExpWebkitVersion = sUserAgent.toLowerCase().match(/webkit[/]([\d.]+)/); let webkitVersion; if (regExpWebkitVersion) { webkitVersion = regExpWebkitVersion[1]; } oExpMobile = /Mobile/; const aChromeMatch = sUserAgent.match(/(Chrome|CriOS)\/(\d+\.\d+).\d+/); const aFirefoxMatch = sUserAgent.match(/FxiOS\/(\d+\.\d+)/); const aAndroidMatch = sUserAgent.match(/Android .+ Version\/(\d+\.\d+)/); if (aChromeMatch || aFirefoxMatch || aAndroidMatch) { let sName; let sVersion; let bMobile; if (aChromeMatch) { sName = BROWSER.CHROME; bMobile = oExpMobile.test(sUserAgent); sVersion = parseFloat(aChromeMatch[2]); } else if (aFirefoxMatch) { sName = BROWSER.FIREFOX; bMobile = true; sVersion = parseFloat(aFirefoxMatch[1]); } else if (aAndroidMatch) { sName = BROWSER.ANDROID; bMobile = oExpMobile.test(sUserAgent); sVersion = parseFloat(aAndroidMatch[1]); } oResult = { name: sName, mobile: bMobile, versionStr: `${sVersion}`, version: sVersion, webkit: true, webkitVersion }; } else { // Safari might have an issue with sUserAgent.match(...); thus changing const oExp = /(Version|PhantomJS)\/(\d+\.\d+).*Safari/; const bStandalone = oNavigator.standalone; if (oExp.test(sUserAgent)) { const aParts = oExp.exec(sUserAgent); fVersion = parseFloat(aParts[2]); oResult = { name: BROWSER.SAFARI, versionStr: `${fVersion}`, fullscreen: false, webview: false, version: fVersion, mobile: oExpMobile.test(sUserAgent), webkit: true, webkitVersion, phantomJS: aParts[1] === 'PhantomJS' }; } else if (/iPhone|iPad|iPod/.test(sUserAgent) && !/CriOS/.test(sUserAgent) && !/FxiOS/.test(sUserAgent) && (bStandalone === true || bStandalone === false)) { // WebView or Standalone mode on iOS oResult = { name: BROWSER.SAFARI, version: -1, fullscreen: bStandalone, webview: !bStandalone, mobile: oExpMobile.test(sUserAgent), webkit: true, webkitVersion }; } else { // other webkit based browser oResult = { mobile: oExpMobile.test(sUserAgent), webkit: true, webkitVersion, version: -1 }; } } } else if (oBrowser.msie || oBrowser.trident) { fVersion = parseFloat(oBrowser.version); oResult = { name: BROWSER.INTERNET_EXPLORER, versionStr: `${fVersion}`, version: fVersion, msie: true, mobile: false }; } else if (oBrowser.edge) { fVersion = parseFloat(oBrowser.version); oResult = { name: BROWSER.EDGE, versionStr: `${fVersion}`, version: fVersion, edge: true }; } else { oResult = { name: '', versionStr: '', version: -1, mobile: false }; } return oResult; }; const _setBrowser = () => { Device.browser = _getBrowser(); Device.browser.BROWSER = BROWSER; if (Device.browser.name) { Object.keys(BROWSER).forEach((b) => { if (BROWSER[b] === Device.browser.name) { Device.browser[b.toLowerCase()] = true; } }); } }; const getBrowser = () => { if (!Device.browser) { _setBrowser(); } return Device.browser; }; const isIE = () => { if (!Device.browser) { _setBrowser(); } return !!Device.browser.msie; }; const isEdge = () => { if (!Device.browser) { _setBrowser(); } return !!Device.browser.edge; }; const isChrome = () => { if (!Device.browser) { _setBrowser(); } return !!Device.browser.chrome; }; const isFF$1 = () => { if (!Device.browser) { _setBrowser(); } return !!Device.browser.firefox; }; const isSafari$1 = () => { if (!Device.browser) { _setBrowser(); } return !!Device.browser.safari; }; // * ******* Support Detection ******** const _setSupport = () => { if (Device.support) { return; } if (!Device.browser) { _setBrowser(); } Device.support = {}; Device.support.touch = !!('ontouchstart' in window || navigator.maxTouchPoints > 0 || (window.DocumentTouch && document instanceof window.DocumentTouch)); }; const supportTouch = () => { if (!Device.support) { _setSupport(); } return !!Device.support.touch; }; // * ******* System Detection ******** /** * Provides a basic categorization of the used device based on various indicators. * * <b>Note:</b> Depending on the capabilities of the device it is also possible that multiple flags are set to <code>true</code>. * * @namespace * @name Device.system */ /** * If this flag is set to <code>true</code>, the device is recognized as a phone. * * @name Device.system.phone * @type boolean */ /** * @name Device.system.SYSTEMTYPE * Enumeration containing the names of known types of the devices. */ const SYSTEMTYPE = { TABLET: 'tablet', PHONE: 'phone', DESKTOP: 'desktop', COMBI: 'combi' }; const _isTablet = () => { const sUserAgent = navigator.userAgent; if (Device.os.name === Device.os.OS.IOS) { return /ipad/i.test(sUserAgent); } // in real mobile device if (supportTouch()) { if (Device.os.windows && Device.os.version >= 8) { return true; } if (Device.browser.chrome && Device.os.android && Device.os.version >= 4.4) { return !/Mobile Safari\/[.0-9]+/.test(sUserAgent); } let densityFactor = window.devicePixelRatio ? window.devicePixelRatio : 1; // may be undefined in Windows Phone devices // On Android sometimes window.screen.width returns the logical CSS pixels, sometimes the physical device pixels; // Tests on multiple devices suggest this depends on the Webkit version. // The Webkit patch which changed the behavior was done here: https://bugs.webkit.org/show_bug.cgi?id=106460 // Chrome 27 with Webkit 537.36 returns the logical pixels, // Chrome 18 with Webkit 535.19 returns the physical pixels. // The BlackBerry 10 browser with Webkit 537.10+ returns the physical pixels. // So it appears like somewhere above Webkit 537.10 we do not hve to divide by the devicePixelRatio anymore. if (Device.os.android && Device.browser.webkit && parseFloat(Device.browser.webkitVersion) > 537.1) { densityFactor = 1; } // this is how android distinguishes between tablet and phone // http://android-developers.blogspot.de/2011/07/new-tools-for-managing-screen-sizes.html const bTablet = Math.min(window.screen.width / densityFactor, window.screen.height / densityFactor) >= 600; // special workaround for Nexus 7 where the window.screen.width is 600px or 601px in portrait mode (=> tablet) // but window.screen.height 552px in landscape mode (=> phone), because the browser UI takes some space on top. // So the detected device type depends on the orientation :-( // actually this is a Chrome bug, as "width"/"height" should return the entire screen's dimensions and // "availWidth"/"availHeight" should return the size available after subtracting the browser UI /* if (isLandscape() && (window.screen.height === 552 || window.screen.height === 553) // old/new Nexus 7 && (/Nexus 7/i.test(sUserAgent))) { bTablet = true; } */ return bTablet; } // This simple android phone detection can be used here because this is the mobile emulation mode in desktop browser const bAndroidPhone = /(?=android)(?=.*mobile)/i.test(sUserAgent); // in desktop browser, it's detected as tablet when // 1. Windows 8 device with a touch screen where "Touch" is contained in the userAgent // 2. Android emulation and it's not an Android phone return (Device.browser.msie && sUserAgent.indexOf('Touch') !== -1) || (Device.os.android && !bAndroidPhone); }; const _getSystem = () => { const bTabletDetected = _isTablet(); const isWin8Upwards = Device.os.windows && Device.os.version >= 8; const oSystem = {}; oSystem.tablet = !!((Device.support.touch || isWin8Upwards) && bTabletDetected); oSystem.phone = !!((Device.os.windows_phone || Device.support.touch) && !bTabletDetected); oSystem.desktop = !!((!oSystem.tablet && !oSystem.phone) || isWin8Upwards); oSystem.combi = oSystem.desktop && oSystem.tablet; oSystem.SYSTEMTYPE = SYSTEMTYPE; return oSystem; }; const _setSystem = () => { _setSupport(); _setOS(); Device.system = {}; Device.system = _getSystem(); if (Device.system.tablet || Device.system.phone) { Device.browser.mobile = true; } }; const getSystem = () => { if (!Device.system) { _setSystem(); } return Device.system; }; const isDesktop = () => { if (!Device.system) { _setSystem(); } return Device.system.desktop; }; const isTablet = () => { if (!Device.system) { _setSystem(); } return Device.system.tablet; }; const isPhone = () => { if (!Device.system) { _setSystem(); } return Device.system.phone; }; const isMobile = () => { if (!Device.system) { _setSystem(); } return Device.browser.mobile; }; /* eslint-disable */ var TableHeaderWidthMode; (function (TableHeaderWidthMode) { TableHeaderWidthMode[TableHeaderWidthMode["FitToRowContent"] = 1] = "FitToRowContent"; TableHeaderWidthMode[TableHeaderWidthMode["FitToContainer"] = 2] = "FitToContainer"; TableHeaderWidthMode[TableHeaderWidthMode["FreeColumnSize"] = 3] = "FreeColumnSize"; TableHeaderWidthMode[TableHeaderWidthMode["ColumnWidth"] = 4] = "ColumnWidth"; })(TableHeaderWidthMode || (TableHeaderWidthMode = {})); function setTableThWidth(tableHeaderMode, columns, thList, renderer2) { let propName = ''; switch (tableHeaderMode) { case TableHeaderWidthMode.FitToRowContent: propName = '$FitToContent'; break; case TableHeaderWidthMode.FitToContainer: propName = '$FitContainerWidth'; break; case TableHeaderWidthMode.FreeColumnSize: propName = '$Width'; break; case TableHeaderWidthMode.ColumnWidth: propName = '$ColumnWidth'; break; } thList.forEach((c, i) => { const wx = _calcWidthOfTh(columns[i], i, propName, thList); wx && renderer2.setStyle(c, 'width', wx); }); } function _calcWidthOfTh(column, i, propName, thList) { if (!column) { return ''; } if (column.$IsImageOricon && i < thList.length - 1) { const fieldTypeId = +column.FieldTypeId; if (fieldTypeId === 6 || fieldTypeId === 5 || fieldTypeId === 42) { return '32px'; } debugger; } return column.$IsImageOricon && i < thList.length - 1 ? '42px' : column[propName]; } function calculateColumnContent(columns, moDataList) { columns.forEach((column) => { setColumnWidthByMaxMoContentWidth(moDataList, column); }); } function calculateColumnWidth(container, columns, moDataList, disableContextMenuOverflow, contextMenuItems) { columns .filter((c) => !c.Hidden) .forEach((column) => { setColumnCaptionWidth(column); }); const contextMenuWidth = calcContextMenuWidth(contextMenuItems, disableContextMenuOverflow); return { columns: [...columns], contextMenuWidth }; } function setColumnCaptionWidth(column) { if (column.$ColumnWidthNum) { return column.$ColumnWidthNum; } const colCaptionWidth = measureText(column.Alias) + 16 + 10; column.$ColumnWidthNum = Math.ceil(colCaptionWidth); column.$ColumnWidth = `${column.$ColumnWidthNum}px`; return colCaptionWidth; } function setColumnWidthByMaxMoContentWidth(moDataList, column) { const width = calculateMoDataListContentWidthByColumnName(moDataList, column); column.$ContentWidth = `${Math.ceil(width)}px`; } function calculateMoDataListContentWidthByColumnName(moDataList, column) { let maxWidth = 0; moDataList.forEach((c, index) => { const caption = getColumnValueOfMoDataList(column.Name, c, undefined, true); const captionWidth = measureText(caption) + 16; if (maxWidth < ca