@ale-rainbow/rainbow-notification
Advanced tools
Comparing version 1.0.36 to 1.0.37
@@ -6,2 +6,6 @@ export declare class RainbowNotificationAction { | ||
icon: string; | ||
options: any[]; | ||
optionsDefaultLabel: string; | ||
optionsHeaderLabel: string; | ||
optionHandler: any; | ||
choice: any[]; | ||
@@ -14,5 +18,8 @@ choiceTitleLabel: string; | ||
private choiceVisible; | ||
private optionVisible; | ||
static create(config: any): RainbowNotificationAction; | ||
toogleChoice(notif: RainbowNotification): any; | ||
toogleOption(notif: RainbowNotification): any; | ||
choiceAction(choiceId: string): () => void; | ||
optionAction(optionId: string): () => void; | ||
} | ||
@@ -19,0 +26,0 @@ export declare class RainbowNotification { |
@@ -6,2 +6,4 @@ "use strict"; | ||
constructor() { | ||
this.optionsDefaultLabel = 'default'; | ||
this.optionsHeaderLabel = null; | ||
this.choiceTitleLabel = null; | ||
@@ -11,2 +13,3 @@ this.handler = null; | ||
this.choiceVisible = false; | ||
this.optionVisible = false; | ||
} | ||
@@ -31,5 +34,12 @@ static create(config) { | ||
} | ||
choiceAction(choiceId) { | ||
return () => { this.choiceHandler(choiceId); }; | ||
toogleOption(notif) { | ||
const optionElem = document.getElementById(`callNotif_option_${notif.id}_${this.name}`); | ||
if (optionElem) { | ||
this.optionVisible = !this.optionVisible; | ||
optionElem.style.opacity = this.optionVisible ? 1 : 0; | ||
optionElem.style.zIndex = this.optionVisible ? 1 : -1; | ||
} | ||
} | ||
choiceAction(choiceId) { return () => { this.choiceHandler(choiceId); }; } | ||
optionAction(optionId) { return () => { this.optionHandler(optionId); }; } | ||
} | ||
@@ -104,4 +114,15 @@ exports.RainbowNotificationAction = RainbowNotificationAction; | ||
} | ||
let arrow = ''; | ||
let options = ''; | ||
if (action.options) { | ||
const optionsHeader = `<div class='extCallNotif__option--header'>${action.optionsHeaderLabel}</div>`; | ||
const optionsItems = action.options.reduce((buff, option, ind) => { | ||
return buff + `<div id='${option.id}' class='extCallNotif__option'><svg draggable='false'><use xlink:href='${this.iconPath}/sprite.svg#${option.icon}'></use></svg>${option.label}${ind ? '' : ' (' + action.optionsDefaultLabel + ')'}</div>`; | ||
}, ''); | ||
options = `<div id='callNotif_option_${this.id}_${action.name}' class='extCallNotif__options'>${optionsHeader}${optionsItems}</div>`; | ||
action.label = action.options[0].label; | ||
arrow = `<div class='extCallNotif__arrow' id='callNotif_${this.id}_${action.name}_options'><div><svg draggable='false'><use xlink:href ='${this.iconPath}/sprite.svg#arrow_dropup'></use></svg></div></div>`; | ||
} | ||
const icon = action.icon ? `<svg class='extCallNotif__icon' draggable='false'><use xlink:href='${this.iconPath}/sprite.svg#${action.icon}'></use></svg>` : ''; | ||
return buffer + `<div id='callNotif_${this.id}_${action.name}' class='extCallNotif__button extCallNotif__button--${action.color}'>${icon}${action.label}</div>`; | ||
return buffer + `<div class='extCallNotif__button extCallNotif__button--${action.color}'>${options}<div class='extCallNotif__button--content' id='callNotif_${this.id}_${action.name}'>${icon}${action.label}</div>${arrow}</div>`; | ||
}, ''); | ||
@@ -125,6 +146,3 @@ actionsArea = `<div class='extCallNotif__actions'>${actionsArea}</div>`; | ||
if (actionButtonElem) { | ||
if (!action.choice) { | ||
actionButtonElem[methodName]('click', action.handler); | ||
} | ||
else { | ||
if (action.choice) { | ||
actionButtonElem[methodName]('click', action.toogleChoice(this)); | ||
@@ -143,2 +161,14 @@ const childnodes = Array.from(document.getElementById(`callNotif_choice_${this.id}_${action.name}`).childNodes); | ||
} | ||
else if (action.options) { | ||
actionButtonElem[methodName]('click', action.optionAction(action.options[0].id)); | ||
const actionButtonOptionsElem = document.getElementById(`callNotif_${this.id}_${action.name}_options`); | ||
actionButtonOptionsElem[methodName]('click', () => { action.toogleOption(this); }); | ||
const childnodes = Array.from(document.getElementsByClassName(`extCallNotif__option`)); | ||
childnodes.forEach((optionElem) => { | ||
optionElem[methodName]('click', action.optionAction(optionElem.getAttribute('id'))); | ||
}); | ||
} | ||
else { | ||
actionButtonElem[methodName]('click', action.handler); | ||
} | ||
} | ||
@@ -145,0 +175,0 @@ }); |
{ | ||
"name": "@ale-rainbow/rainbow-notification", | ||
"version": "v1.0.36", | ||
"version": "v1.0.37", | ||
"description": "Alcatel-Lucent Enterprise Rainbow Notification", | ||
@@ -5,0 +5,0 @@ "main": "./dist/rainbowNotification.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
60129
1611