UNPKG

office-ui-fabric-react

Version:

Reusable React components for building experiences for Office 365.

68 lines 3.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* tslint:disable:no-unused-variable */ var React = require("react"); /* tslint:enable:no-unused-variable */ var ReactDOM = require("react-dom"); var AppDefinition_1 = require("./AppDefinition"); var index_1 = require("office-ui-fabric-react/lib/utilities/router/index"); var GettingStartedPage_1 = require("./GettingStartedPage"); var Utilities_1 = require("office-ui-fabric-react/lib/Utilities"); var Fabric_1 = require("office-ui-fabric-react/lib/Fabric"); var example_app_base_1 = require("@uifabric/example-app-base"); require("./index.scss"); require("./ColorStyles.scss"); var index_2 = require("@uifabric/icons/lib/index"); index_2.initializeIcons(); Utilities_1.setBaseUrl('./dist/'); example_app_base_1.ComponentPage.defaultProps.areBadgesVisible = true; var rootElement; // Return the anchor link from the URL without the hash function _extractAnchorLink(path) { var index = path.lastIndexOf('#'); if (index >= 0) { path = path.substr(index + 1, path.length - index); } return path; } function _scrollAnchorLink() { if ((window.location.hash.match(/#/g) || []).length > 1) { var anchor = _extractAnchorLink(window.location.hash); document.getElementById(anchor).scrollIntoView(); } } function _onLoad() { rootElement = rootElement || document.getElementById('content'); ReactDOM.render(React.createElement(Fabric_1.Fabric, null, React.createElement(index_1.Router, { onNewRouteLoaded: _scrollAnchorLink }, _getRoutes())), rootElement); } function _getRoutes() { var routes = AppDefinition_1.AppDefinition.testPages.map(function (page) { return React.createElement(index_1.Route, { key: page.key, path: page.url, component: page.component }); }); var appRoutes = []; AppDefinition_1.AppDefinition.examplePages.forEach(function (group) { group.links .filter(function (link) { return link.hasOwnProperty('component') || link.hasOwnProperty('getComponent'); }) .forEach(function (link, linkIndex) { var component = link.component, getComponent = link.getComponent; appRoutes.push(React.createElement(index_1.Route, { key: link.key, path: link.url, component: component, getComponent: getComponent })); }); }); // Default route. appRoutes.push(React.createElement(index_1.Route, { key: 'gettingstarted', component: GettingStartedPage_1.GettingStartedPage })); routes.push(React.createElement(index_1.Route, { key: 'app', component: AppDefinition_1.App }, appRoutes)); return routes; } function _onUnload() { if (rootElement) { ReactDOM.unmountComponentAtNode(rootElement); } } var isReady = document.readyState === 'interactive' || document.readyState === 'complete'; if (isReady) { _onLoad(); } else { window.onload = _onLoad; } window.onunload = _onUnload; //# sourceMappingURL=index.js.map