UNPKG

@lidorsystems/integralui-web

Version:

IntegralUI Web - Advanced UI Components for Angular

157 lines (138 loc) 6.55 kB
/* Copyright © 2016-2019 Lidor Systems. All rights reserved. This file is part of the "IntegralUI Web" Library. The contents of this file are subject to the IntegralUI Web License, and may not be used except in compliance with the License. A copy of the License should have been installed in the product's root installation directory or it can be found at http://www.lidorsystems.com/products/web/studio/license-agreement.aspx. This SOFTWARE is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Any infringement will be prosecuted under applicable laws. */ import { Component, ElementRef, ViewContainerRef, ViewChild, ViewChildren, ViewEncapsulation } from '@angular/core'; @Component({ selector: '', template: ` <style> .sidebar { cursor: pointer; position: absolute; top: 61px; left: 0; width: 251px; overflow: hidden; } .sidebar ul { color: #ababab; list-style-type: none; margin: 15px 0 15px 15px; padding: 0; } .sidebar li { margin: 7px 0; padding: 5px; position: relative; } .sel-mark { border: 12px solid #ffffff; border-color: transparent #ffffff transparent transparent; display: block; position: absolute; top: 2px; right: 0; } </style> <div style="background:url('app/sidebar.png') repeat-y 0 0;margin:0;" [ngStyle]="{ height: blockHeight }"> <div class="sidebar"> <ul> <li *ngFor="let sideItem of sideList" routerLink="{{sideItem.link}}" (mousedown)="selectFeature(sideItem)" (mouseenter)="itemMouseEnter(sideItem)" (mouseleave)="itemMouseLeave()" [ngStyle]="{ 'margin-top': sideItem.margin + 'px' }"> <span [ngStyle]="getItemStyle(sideItem)">{{sideItem.text}}</span> <span class="sel-mark" *ngIf="sideItem==selectedItem"></span> </li> </ul> </div> <div style="display:inline-block;margin-left:275px" #featureContent> <router-outlet></router-outlet> </div> </div> `, encapsulation: ViewEncapsulation.None }) export class GridSample { @ViewChild('featureContent', {read: ElementRef, static: false}) featureContentElem: ElementRef; public blockHeight: any = "auto"; // List of features public sideList: Array<any>; public selectedItem: any = null; private hoverItem: any = null; constructor(){ this.sideList = [ { text: "Add/Remove", link: './add-remove' }, { text: "Add Row Dynamically", link: './add-row-dynamically' }, { text: "Auto-Size Columns", link: './auto-size-columns' }, { text: "Built-in Editors", link: './builtin-editors' }, { text: "Cell with CheckBox", link: './edit-cell-checkbox', space: 20 }, { text: "Cell with Color Picker", link: './edit-cell-colorpicker', space: 20 }, { text: "Cell with Date Picker", link: './edit-cell-datepicker', space: 20 }, { text: "Cell with DropList", link: './edit-cell-droplist', space: 20 }, { text: "Cell with Numeric UpDown", link: './edit-cell-numeric', space: 20 }, { text: "Cell with Rating", link: './edit-cell-rating', space: 20 }, { text: "Cell with TextBox", link: './edit-cell-text', space: 20 }, { text: "Buttons on Row Hovering", link: './row-hover-buttons' }, { text: "Cell with DropDown", link: './cell-dropdown' }, { text: "Column with DropDown", link: './column-dropdown' }, { text: "Context Menu", link: './context-menu' }, { text: "Different Cell Templates", link: './cell-templates' }, { text: "Drag Drop to TreeGrid", link: './drag-drop-treegrid' }, { text: "Dynamic Grouping", link: './grouping' }, { text: "Events", link: './events' }, { text: "Excel Editor", link: './excel-editor' }, { text: "Export to CSV or JSON", link: './export' }, { text: "Fast Load", link: './fast-load' }, { text: "Filter", link: './filter' }, { text: "Fixed Columns", link: './fixed-columns' }, { text: "Multi Level Headers", link: './multi-level-headers' }, { text: "Multi Select", link: './multi-select' }, { text: "Overview", link: './overview' }, { text: "Pagination", link: './pagination' }, { text: "Show/Hide Header | Footer", link: './show-hide-header-footer' }, { text: "Sorting", link: './sorting' }, { text: "Tooltip", link: './tooltip' }, { text: "Back to Main", link: '', margin: 50 } ]; this.selectedItem = this.sideList[26]; } ngAfterContentChecked(){ let self = this; if (self.featureContentElem && self.featureContentElem.nativeElement.offsetHeight < window.innerHeight - 61) self.blockHeight = window.innerHeight - 61 + 'px'; else self.blockHeight = "auto"; self.blockHeight = '1200px'; } selectFeature(item: any){ this.selectedItem = item; } itemMouseEnter(item: any){ this.hoverItem = item; } itemMouseLeave(){ this.hoverItem = null; } getItemStyle(item: any){ let style: any = { color: '#ababab', 'font-weight': 'normal', 'margin-left': item.space ? item.space + 'px': '0' } if (item == this.selectedItem){ style.color = 'white'; style['font-weight'] = 'bold'; } else if (item == this.hoverItem) style.color = '#f5f5f5'; return style; } }