Skip to content

Commit

Permalink
optimize function
Browse files Browse the repository at this point in the history
  • Loading branch information
akaravi committed Nov 16, 2023
1 parent 39fb4b6 commit d5d2476
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ntk-cms-web",
"version": "15.2.0825.3",
"version": "15.2.0825.4",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
11 changes: 6 additions & 5 deletions src/app/_metronic/kt/_utils/DomHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { environment } from 'src/environments/environment'
import { ElementAnimateUtil } from './ElementAnimateUtil'
import { OffsetModel } from './models/OffsetModel'
import { ViewPortModel } from './models/ViewPortModel'
import { DataUtil } from './_DataUtil'
import { ElementStyleUtil } from './_ElementStyleUtil'
import { getObjectPropertyValueByKey, toJSON } from './_TypesHelpers'
import { OffsetModel } from './models/OffsetModel'
import { ViewPortModel } from './models/ViewPortModel'

function getCSS(el: HTMLElement, styleProp: string) {
const defaultView = (el.ownerDocument || document).defaultView
Expand Down Expand Up @@ -242,9 +243,9 @@ function getElementChild(element: HTMLElement, selector: string): HTMLElement |
}

function isMobileDevice(): boolean {
if (getViewPort().width < 1000)
if (window.innerWidth < environment.cmsViewConfig.mobileWindowInnerWidth)
return true;
let test = getViewPort().width < +getBreakpoint('lg') ? true : false
let test = window.innerWidth < +getBreakpoint('lg') ? true : false

if (test === false) {
// For use within normal web clients
Expand Down Expand Up @@ -397,7 +398,7 @@ function getAttributeValueByBreakpoint(incomingAttr: string): string | JSON {
return incomingAttr
}

const width = getViewPort().width
const width = window.innerWidth
let resultKey
let resultBreakpoint = -1
let breakpoint
Expand Down
2 changes: 1 addition & 1 deletion src/app/_metronic/kt/components/SearchComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class SearchComponent {
// Check if responsive form mode is enabled
private getResponsiveFormMode = () => {
const responsive = this.getOption('responsive') as string
const width = getViewPort().width
const width = window.innerWidth

if (!responsive) {
return null
Expand Down
3 changes: 1 addition & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { getAnalytics } from "firebase/analytics";
import { initializeApp } from "firebase/app";
import { CoreAuthService, CoreSiteService, CoreSiteSupportModel, DeviceTypeEnum, ErrorExceptionResult, OperatingSystemTypeEnum, TokenDeviceClientInfoDtoModel, TokenDeviceSetNotificationIdDtoModel } from 'ntk-cms-api';
import { environment } from 'src/environments/environment';
import { getViewPort } from './_metronic/kt/_utils/DomHelpers';
import { ThemeModeService } from './_metronic/partials/layout/theme-mode-switcher/theme-mode.service';
import { PublicHelper } from './core/helpers/publicHelper';
import { TokenHelper } from './core/helpers/tokenHelper';
Expand Down Expand Up @@ -101,7 +100,7 @@ export class AppComponent implements OnInit {
});
}

console.log('windows innerWidth size:', getViewPort());
console.log('windows innerWidth size:', window.innerWidth);
}
cmsApiStoreSubscribe: Subscription;
dataSupportModelResult: ErrorExceptionResult<CoreSiteSupportModel>;
Expand Down
3 changes: 2 additions & 1 deletion src/app/cms-modules/auth/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PublicHelper } from 'src/app/core/helpers/publicHelper';
import { ProgressSpinnerModel } from 'src/app/core/models/progressSpinnerModel';
import { CmsToastrService } from 'src/app/core/services/cmsToastr.service';
import { getViewPort } from 'src/app/_metronic/kt/_utils/DomHelpers';
import { environment } from 'src/environments/environment';
@Component({
selector: 'app-auth',
templateUrl: './auth.component.html',
Expand All @@ -26,7 +27,7 @@ export class AuthComponent implements OnInit {

showSplashModel = true;
ngOnInit(): void {
if (getViewPort().width < 860) {
if (window.innerWidth < environment.cmsViewConfig.mobileWindowInnerWidth) {
setTimeout(() => {
this.showSplashModel = false;
this.cdr.markForCheck();
Expand Down
6 changes: 2 additions & 4 deletions src/app/core/helpers/publicHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ export class PublicHelper {
}

get isMobile() {
if (window.innerWidth < 1000)
if (window.innerWidth < environment.cmsViewConfig.mobileWindowInnerWidth)
return true;
// if (isMobileDevice())
// return true;
return false;
};

Expand Down Expand Up @@ -521,7 +519,7 @@ export class PublicHelper {
cloumnAdminAccessDispaly = [];
}
var cloumn: string[] = [];
if (window.innerWidth < 1000 && cloumnMobileDispalySource && cloumnMobileDispalySource.length > 0) {
if (window.innerWidth < environment.cmsViewConfig.mobileWindowInnerWidth && cloumnMobileDispalySource && cloumnMobileDispalySource.length > 0) {
cloumn = JSON.parse(JSON.stringify(cloumnMobileDispalySource));
} else if (cloumnDesktopSource && cloumnDesktopSource.length > 0) {
cloumn = JSON.parse(JSON.stringify(cloumnDesktopSource));
Expand Down
5 changes: 2 additions & 3 deletions src/app/core/helpers/tokenHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { Observable, Subscription, firstValueFrom } from 'rxjs';
import { TranslationService } from '../i18n/translation.service';
import { CmsStoreService } from '../reducers/cmsStore.service';
import { environment } from 'src/environments/environment';

@Injectable({
providedIn: 'root',
Expand All @@ -26,10 +27,8 @@ export class TokenHelper implements OnDestroy {
}

get isMobile() {
if (window.innerWidth < 1000)
if (window.innerWidth < environment.cmsViewConfig.mobileWindowInnerWidth)
return true;
// if (isMobileDevice())
// return true;
return false;
};
tokenInfo: TokenInfoModel = new TokenInfoModel();
Expand Down
1 change: 1 addition & 0 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const environment = {
PackageName: '',
},
cmsViewConfig: {
mobileWindowInnerWidth:1000,
tableRowMouseEnter: false,
enterAnimationDuration: '1500ms',
exitAnimationDuration: '1000ms'
Expand Down
1 change: 1 addition & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const environment = {
PackageName: '',
},
cmsViewConfig: {
mobileWindowInnerWidth:1000,
tableRowMouseEnter: true,
enterAnimationDuration: '1500ms',
exitAnimationDuration: '1000ms'
Expand Down

0 comments on commit d5d2476

Please sign in to comment.