Skip to content

Commit 22b0b50

Browse files
author
pipeline
committed
config(EJ2-4094): Fixed theme switch and navigation issue.
1 parent d3328ce commit 22b0b50

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/common/sb.component.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, ElementRef, HostListener, Inject, Input, ViewChild } from '@angular/core';
22
import { Router,NavigationStart , NavigationEnd, ActivatedRoute } from '@angular/router';
3-
import { select, isVisible, createElement } from '@syncfusion/ej2-base';
3+
import { select, isVisible, createElement, Ajax } from '@syncfusion/ej2-base';
44
import { Button } from '@syncfusion/ej2-buttons';
55
import { Http, Response } from '@angular/http';
66
import { Browser, enableRipple, detach } from '@syncfusion/ej2-base';
@@ -81,6 +81,13 @@ export class SBController {
8181

8282
setSelectListItemSelect(id: string): void {
8383
this.enableNavClick();
84+
let paths: string[] = this.pathRoutes;
85+
let path: string = ':theme/' + id;
86+
if (paths.length - 1 <= paths.indexOf(path)) {
87+
this.grpNavButton.children[1].classList.add('disabled');
88+
} else if (paths.indexOf(path) <= 0) {
89+
this.grpNavButton.children[0].classList.add('disabled');
90+
}
8491
if (!window.isInteractedList) {
8592
let listObj: any = this.leftControl.listObj;
8693
if (this.prevControl !== this.currentControl && listObj) {
@@ -180,7 +187,8 @@ export class SBController {
180187
// Need to remove once created event has been supported
181188
setTimeout(() => {
182189
let hash: string[] = location.hash.split('/');
183-
this.setSelectListItemSelect(hash[2] + '/' + hash[3]);
190+
hash = hash.slice(2);
191+
this.setSelectListItemSelect(hash.join('/'));
184192
});
185193
});
186194
this.router.events
@@ -310,9 +318,8 @@ export class SBController {
310318

311319
updateSourceTab(path: string): void {
312320
let pathArray: string[] = path.split('/');
313-
let realPath: string[] = [];
314-
realPath.push('src', pathArray[2], pathArray[3]);
315-
let localPath: string = realPath.join('/');
321+
pathArray = pathArray.slice(2);
322+
let localPath: string = 'src/' + pathArray.join('/');
316323
let tsRequest: Observable<Response> = this.http.get(localPath + '.component.ts');
317324
let htmlRequst: Observable<Response> = this.http.get(localPath + '.html');
318325
let plunk: Observable<Response> = this.http.get(localPath + '-plnkr.json');
@@ -460,16 +467,20 @@ export class SBController {
460467
}
461468
getHash(): string {
462469
let hash: string[] = location.hash.split('/');
463-
return ':theme/' + hash[2] + '/' + hash[3];
470+
hash = hash.slice(2);
471+
return ':theme/' + hash.join('/');
464472
}
465473
}
466474

467475
function loadTheme(theme: string): void {
468476
selectedTheme = theme;
469-
let doc: HTMLFormElement = <HTMLFormElement>select('#themelink');
470-
doc.href = './styles/' + theme + '.css';
471-
select('#themeswitcher-icon').setAttribute('src', 'styles/images/SB_icon/SB_Switcher_icon_' + theme + '.png');
472-
document.body.classList.add(theme);
477+
let ajax: Ajax = new Ajax('./styles/' + theme + '.css','GET',true);
478+
ajax.send().then((result:any) =>{
479+
let doc: HTMLFormElement = <HTMLFormElement>select('#themelink');
480+
doc.href = './styles/' + theme + '.css';
481+
select('#themeswitcher-icon').setAttribute('src', 'styles/images/SB_icon/SB_Switcher_icon_' + theme + '.png');
482+
document.body.classList.add(theme);
483+
});
473484
}
474485

475486
function hideLoader(): void {

0 commit comments

Comments
 (0)