@lidorsystems/integralui-web
Version:
IntegralUI Web - Advanced UI Components for Angular
148 lines (134 loc) • 7.07 kB
text/typescript
/*
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, ViewContainerRef, ViewChild, ViewChildren, ViewEncapsulation } from '@angular/core';
import { IntegralUIContextMenu } from '../../integralui/directives/integralui.contextmenu';
export class ContextMenuOverviewSample {
applicationRef: ViewContainerRef;
public menuSettings: any = {
appRef: null,
items: []
}
public fontWeight: string = 'bold';
public fontStyle: string = 'normal';
public fontSize: string = '1';
public textDecoration: string = 'none';
constructor(){}
ngAfterViewInit(){
this.menuSettings = {
appRef: this.applicationRef,
items: [
//{ id: 1, text: "Font Menu", type: "header" },
{ id: 2, text: "Bold", icon: 'cmnu-icons-medium check-mark', checked: true },
{ id: 3, text: "Italic", icon: 'cmnu-icons-medium empty' },
{ id: 4, text: "Strikethrough", icon: 'cmnu-icons-medium empty' },
{ id: 5, type: "separator" },
{ id: 6, text: "x1", icon: 'cmnu-icons-medium radio-mark-filled' },
{ id: 7, text: "x1.5", icon: 'cmnu-icons-medium radio-mark-empty' },
{ id: 8, text: "x2", icon: 'cmnu-icons-medium radio-mark-empty' }
]
}
}
menuItemClick(e: any){
if (e.item){
if (e.item.id < 5)
e.item.checked = e.item.checked != undefined ? !e.item.checked : true;
else
e.item.checked = true;
switch (e.item.id){
case 2:
this.fontWeight = e.item.checked != false ? 'bold' : 'normal';
break;
case 3:
this.fontStyle = e.item.checked != false ? 'italic' : 'normal';
break;
case 4:
this.textDecoration = e.item.checked != false ? 'line-through' : 'none';
break;
case 6:
this.fontSize = e.item.checked != false ? '1' : '1';
break;
case 7:
this.fontSize = e.item.checked != false ? '1.5' : '1';
break;
case 8:
this.fontSize = e.item.checked != false ? '2' : '1';
break;
}
if (e.item.id < 5)
e.item.icon = e.item.checked != false ? 'cmnu-icons-medium check-mark' : 'cmnu-icons-medium empty';
else {
for (var i = 4; i < this.menuSettings.items.length; i++){
if (this.menuSettings.items[i] != e.item)
this.menuSettings.items[i].checked = false;
this.menuSettings.items[i].icon = this.menuSettings.items[i].checked != false ? 'cmnu-icons-medium radio-mark-filled' : 'cmnu-icons-medium radio-mark-empty';
}
}
}
}
}