Update Guid and MobileDetect code
This commit is contained in:
parent
511a3997cf
commit
b0bbc9de2b
|
@ -1,12 +1,14 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import * as ReactDom from 'react-dom';
|
import * as ReactDom from 'react-dom';
|
||||||
import { Version, DisplayMode } from '@microsoft/sp-core-library';
|
import { Version, Guid } from '@microsoft/sp-core-library';
|
||||||
|
import { BrowserUtilities } from '@microsoft/sp-core-library/lib-commonjs/BrowserUtilities';
|
||||||
import {
|
import {
|
||||||
BaseClientSideWebPart,
|
BaseClientSideWebPart,
|
||||||
IWebPartPropertiesMetadata,
|
IWebPartPropertiesMetadata,
|
||||||
WebPartContext
|
WebPartContext
|
||||||
} from '@microsoft/sp-webpart-base';
|
} from '@microsoft/sp-webpart-base';
|
||||||
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IPropertyPaneConfiguration,
|
IPropertyPaneConfiguration,
|
||||||
PropertyPaneDropdown,
|
PropertyPaneDropdown,
|
||||||
|
@ -53,9 +55,9 @@ export default class TabAccordionWebPart extends BaseClientSideWebPart<ITabAccor
|
||||||
super();
|
super();
|
||||||
|
|
||||||
//Initialize unique GUID
|
//Initialize unique GUID
|
||||||
this.guid = this.getGuid();
|
this.guid = Guid.newGuid().toString();
|
||||||
|
|
||||||
this.isMobile = this.detectmob();
|
this.isMobile = BrowserUtilities.isMobileBrowser();
|
||||||
|
|
||||||
//Hack: to invoke correctly the onPropertyChange function outside this class
|
//Hack: to invoke correctly the onPropertyChange function outside this class
|
||||||
//we need to bind this object on it first
|
//we need to bind this object on it first
|
||||||
|
@ -64,7 +66,6 @@ export default class TabAccordionWebPart extends BaseClientSideWebPart<ITabAccor
|
||||||
|
|
||||||
|
|
||||||
public render(): void {
|
public render(): void {
|
||||||
console.log('Web Part Render Called');
|
|
||||||
this.properties.tabContent = "";
|
this.properties.tabContent = "";
|
||||||
this.properties.tabs.map((tab: any, tabindex: number) => {
|
this.properties.tabs.map((tab: any, tabindex: number) => {
|
||||||
this.properties.tabContent += tab.Title + "," + tab.Content + "|";
|
this.properties.tabContent += tab.Title + "," + tab.Content + "|";
|
||||||
|
@ -111,34 +112,6 @@ export default class TabAccordionWebPart extends BaseClientSideWebPart<ITabAccor
|
||||||
return Version.parse('1.0');
|
return Version.parse('1.0');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @function
|
|
||||||
* Generates a GUID
|
|
||||||
*/
|
|
||||||
private getGuid(): string {
|
|
||||||
return this.s4() + this.s4() + '-' + this.s4() + '-' + this.s4() + '-' +
|
|
||||||
this.s4() + '-' + this.s4() + this.s4() + this.s4();
|
|
||||||
}
|
|
||||||
|
|
||||||
private detectmob(): boolean {
|
|
||||||
console.log('inside detectmob');
|
|
||||||
if(window.innerWidth <= 480) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @function
|
|
||||||
* Generates a GUID part
|
|
||||||
*/
|
|
||||||
private s4(): string {
|
|
||||||
return Math.floor((1 + Math.random()) * 0x10000)
|
|
||||||
.toString(16)
|
|
||||||
.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//executes only before property pane is loaded.
|
//executes only before property pane is loaded.
|
||||||
protected async loadPropertyPaneResources(): Promise<void> {
|
protected async loadPropertyPaneResources(): Promise<void> {
|
||||||
// import additional controls/components
|
// import additional controls/components
|
||||||
|
|
Loading…
Reference in New Issue