File indexing completed on 2025-01-26 05:27:58

0001 import React, { Component } from 'react';
0002 import MobileSiteHeader from './MobileSiteHeader';
0003 import Support from './Support';
0004 class SiteHeader extends Component {
0005   constructor(props){
0006         super(props);
0007         this.state = {
0008       baseUrl:window.json_baseurl,
0009       searchBaseUrl:window.json_searchbaseurl,
0010       cat_title:window.json_cat_title,
0011       hasIdentity:window.json_hasIdentity,
0012       is_show_title:window.json_is_show_title,
0013       redirectString:window.json_redirectString,
0014       serverUrl:window.json_serverUrl,
0015       serverUri:window.json_serverUri,
0016       store:{
0017         sName:window.json_sname,
0018         name:window.json_store_name,
0019         order:window.json_store_order,
0020         last_char_store_order:window.json_last_char_store_order,
0021       },
0022       user:window.json_member,
0023       logo:window.json_logoWidth,
0024       cat_title_left:window.json_cat_title_left,
0025       tabs_left:window.tabs_left,
0026       template:window.json_template,
0027       status:"",
0028       section:window.json_section,
0029       url_logout:window.json_logouturl,
0030       cat_id:window.json_cat_id,
0031       isShowAddProject: window.json_isShowAddProduct,
0032       baseurlStore:window.json_baseurlStore,
0033     };
0034     this.updateDimensions = this.updateDimensions.bind(this);
0035   }
0036 
0037   componentWillMount() {
0038     this.updateDimensions();
0039   }
0040 
0041   componentDidMount() {
0042     window.addEventListener("resize", this.updateDimensions);
0043     window.addEventListener("orientationchange",this.updateDimensions);
0044   }
0045 
0046   updateDimensions(){
0047     const width = window.innerWidth;
0048     let device;
0049     if (width >= 910){
0050       device = "large";
0051     } else if (width < 910 && width >= 610){
0052       device = "mid";
0053     } else if (width < 610){
0054       device = "tablet";
0055     }
0056     this.setState({device:device});
0057   }
0058 
0059   render(){
0060     let  siteHeaderTopRightCssClass;
0061     let logoLink = this.state.serverUrl;
0062     if (this.state.serverUri.indexOf('/s/') > -1){
0063       logoLink += "/s/" + this.state.store.name;
0064     }
0065 
0066     let siteHeaderStoreNameDisplay;
0067     if (this.state.is_show_title === "1"){
0068       siteHeaderStoreNameDisplay = (
0069         <div id="site-header-store-name-container" style={{"margin-left":"80px"}}>
0070           <a href={logoLink}>
0071             {this.state.store.name}
0072           </a>
0073         </div>
0074       );
0075     }
0076     let PlingDisplay;
0077     if(this.state.section)
0078     {
0079         PlingDisplay =
0080             <div id="siter-header-pling">
0081             <Support section={this.state.section}
0082                     headerStyle={this.state.template['header']['header-supporter-style']}
0083             />
0084             </div>
0085     }
0086 
0087     let HeaderDisplay;
0088     if (this.state.device !== "tablet"){     
0089       let logoStyle = this.state.template['header-logo'];
0090       logoStyle.left="80px";
0091       HeaderDisplay = (
0092         <section id="site-header-wrapper" >
0093           <div id="siter-header-left" style={{"paddingLeft":this.state.template['header-logo']['width']}}>
0094             <div id="site-header-logo-container" style={logoStyle}>
0095               <a href={logoLink}>
0096                 <img src={this.state.template['header-logo']['image-src']}/>
0097               </a>
0098             </div>
0099             {siteHeaderStoreNameDisplay}
0100           </div>
0101           
0102 
0103           <div id="site-header-right">
0104             <div id="site-header-right-top" className={siteHeaderTopRightCssClass}>
0105                
0106                 { PlingDisplay }
0107             </div>
0108 
0109           </div>
0110         </section>
0111       );
0112     } else {
0113       HeaderDisplay = (
0114         <MobileSiteHeader
0115           logoLink={logoLink}
0116           template={this.state.template}
0117           user={this.state.user}
0118           baseUrl={this.state.baseUrl}
0119           searchBaseUrl={this.state.searchBaseUrl}
0120           serverUrl={this.state.serverUrl}
0121           store={this.state.store}
0122           redirectString={this.state.redirectString}
0123           section={this.state.section}
0124         />
0125       )
0126     }
0127 
0128     let templateHeaderStyle;
0129     if (this.state.template){
0130       templateHeaderStyle = {
0131         "backgroundImage":this.state.template.header['background-image'],
0132         "backgroundColor":this.state.template.header['background-color'],
0133         "height":this.state.template.header['height']
0134       }
0135     }
0136 
0137     let headerStoreClassName = this.state.store.name.toLowerCase();
0138     if (headerStoreClassName.indexOf('.') > -1) headerStoreClassName = headerStoreClassName.split('.')[0]
0139 
0140     return (
0141       <section id="site-header" style={templateHeaderStyle} className={headerStoreClassName}>
0142         {HeaderDisplay}
0143       </section>
0144     )
0145   }
0146 }
0147 
0148 export default SiteHeader;