PowerButton JAVASCRIPT UI Component API

PowerButton Javascript API

Class

PowerButton

PowerButton is On/Off rounded button.

Selector

smart-power-button

Properties

Events

Properties

animation"none" | "simple" | "advanced"

Sets or gets the animation mode. Animation is disabled when the property is set to 'none'

Default value

"advanced"

Example

Set the animation property.

 <smart-power-button animation='none'></smart-power-button>

Set the animation property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.animation = 'simple';

Get the animation property.

 const powerbutton = document.querySelector('smart-power-button');
 let animation = powerbutton.animation;

checkedboolean

Sets or gets the check state.

Default value

false

Example

Set the checked property.

 <smart-power-button checked></smart-power-button>

Set the checked property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.checked = false;

Get the checked property.

 const powerbutton = document.querySelector('smart-power-button');
 let checked = powerbutton.checked;

clickMode"hover" | "press" | "release" | "pressAndRelease"

Sets the click mode of the button.

Default value

"release"

Example

Set the clickMode property.

 <smart-power-button click-mode='hover'></smart-power-button>

Set the clickMode property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.clickMode = 'release';

Get the clickMode property.

 const powerbutton = document.querySelector('smart-power-button');
 let clickMode = powerbutton.clickMode;

disabledboolean

Enables or disables the power button.

Default value

false

Example

Set the disabled property.

 <smart-power-button disabled></smart-power-button>

Set the disabled property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.disabled = false;

Get the disabled property.

 const powerbutton = document.querySelector('smart-power-button');
 let disabled = powerbutton.disabled;

localestring

Sets or gets the language. Used in conjunction with the property messages.

Default value

"en"

Example

Set the locale property.

 <smart-power-button locale='de'></smart-power-button>

Set the locale property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.locale = 'fr';

Get the locale property.

 const powerbutton = document.querySelector('smart-power-button');
 let locale = powerbutton.locale;

localizeFormatFunctionfunction | null

Callback, related to localization module.

Example

Set the localizeFormatFunction property.

 <smart-power-button localize-format-function='function(){return '...'}'></smart-power-button>

Set the localizeFormatFunction property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.localizeFormatFunction = function(){return '...'};

Get the localizeFormatFunction property.

 const powerbutton = document.querySelector('smart-power-button');
 let localizeFormatFunction = powerbutton.localizeFormatFunction;

messagesobject

Sets or gets an object specifying strings used in the widget that can be localized. Used in conjunction with the property locale.

Default value




"en": {

"propertyUnknownType": "'{{name}}' property is with undefined 'type' member!",

"propertyInvalidValue": "Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!",

"propertyInvalidValueType": "Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!",

"elementNotInDOM": "Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.",

"moduleUndefined": "Module is undefined.",

"missingReference": "{{elementType}}: Missing reference to {{files}}.",

"htmlTemplateNotSuported": "{{elementType}}: Browser doesn't support HTMLTemplate elements.",

"invalidTemplate": "{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM."

}

Example

Set the messages property.

 <smart-power-button messages='{"de":{"propertyUnknownType":"Die Eigenschaft '{{name}}' hat ein nicht definiertes 'type'-Member!","propertyInvalidValue":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualValue}}, Erwarteter Wert: {{value}}!","propertyInvalidValueType":"Ungultiger Eigenschaftswert '{{name}}'! Aktueller Wert: {{actualType}}, Erwarteter Wert: {{type}}!","elementNotInDOM":"Element existiert nicht in DOM! Bitte fugen Sie das Element zum DOM hinzu, bevor Sie eine Methode aufrufen.","moduleUndefined":"Modul ist nicht definiert.","missingReference":"{{elementType}}: Fehlender Verweis auf {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser unterstutzt keine HTMLTemplate-Elemente.","invalidTemplate":"{{elementType}}: '{{property}}' Die Eigenschaft akzeptiert eine Zeichenfolge, die mit der ID eines HTMLTemplate-Elements aus dem DOM ubereinstimmen muss."}}'></smart-power-button>

Set the messages property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.messages = {"en":{"propertyUnknownType":"'{{name}}' property is with undefined 'type' member!","propertyInvalidValue":"Invalid '{{name}}' property value! Actual value: {{actualValue}}, Expected value: {{value}}!","propertyInvalidValueType":"Invalid '{{name}}' property value type! Actual type: {{actualType}}, Expected type: {{type}}!","elementNotInDOM":"Element does not exist in DOM! Please, add the element to the DOM, before invoking a method.","moduleUndefined":"Module is undefined.","missingReference":"{{elementType}}: Missing reference to {{files}}.","htmlTemplateNotSuported":"{{elementType}}: Browser doesn't support HTMLTemplate elements.","invalidTemplate":"{{elementType}}: '{{property}}' property accepts a string that must match the id of an HTMLTemplate element from the DOM."}};

Get the messages property.

 const powerbutton = document.querySelector('smart-power-button');
 let messages = powerbutton.messages;

namestring

Sets or gets the widget's name.

Default value

""""

Example

Set the name property.

 <smart-power-button name='Name'></smart-power-button>

Set the name property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.name = 'New Name';

Get the name property.

 const powerbutton = document.querySelector('smart-power-button');
 let name = powerbutton.name;

readonlyboolean

If the custom element is readonly, it cannot be interacted with.

Default value

false

Example

Set the readonly property.

 <smart-power-button readonly></smart-power-button>

Set the readonly property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.readonly = false;

Get the readonly property.

 const powerbutton = document.querySelector('smart-power-button');
 let readonly = powerbutton.readonly;

themestring

Determines the theme. Theme defines the look of the element

Default value

""

Example

Set the theme property.

 <smart-power-button theme='blue'></smart-power-button>

Set the theme property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.theme = 'red';

Get the theme property.

 const powerbutton = document.querySelector('smart-power-button');
 let theme = powerbutton.theme;

unfocusableboolean

If is set to true, the element cannot be focused.

Default value

false

Example

Set the unfocusable property.

 <smart-power-button unfocusable></smart-power-button>

Set the unfocusable property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.unfocusable = false;

Get the unfocusable property.

 const powerbutton = document.querySelector('smart-power-button');
 let unfocusable = powerbutton.unfocusable;

valuestring

Sets or gets the widget's value.

Default value

""""

Example

Set the value property.

 <smart-power-button value='Value'></smart-power-button>

Set the value property by using the HTML Element's instance.

 const powerbutton = document.querySelector('smart-power-button');
 powerbutton.value = 'New Value';

Get the value property.

 const powerbutton = document.querySelector('smart-power-button');
 let value = powerbutton.value;

Events

changeCustomEvent

This event is triggered when the widget is checked/unchecked.

  • Bubbles Yes
  • Cancelable No
  • Interface CustomEvent
  • Event handler property onChange

Arguments

evCustomEvent

Methods

isDefaultPrevented

Returns true if the event was prevented by any of its subscribers.

Returns

boolean true if the default action was prevented. Otherwise, returns false.

preventDefault

The preventDefault() method prevents the default action for a specified event. In this way, the source component suppresses the built-in behavior that follows the event.

stopPropagation

The stopPropagation() method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.

Example

Set up the event handler of change event.

const powerbutton = document.querySelector('smart-power-button');
powerbutton.addEventListener('change', function (event) {
	// event handling code goes here.
})

CSS Variables

--smart-power-button-default-widthvar()

Default value

"var(--smart-editor-height)"

smartPowerButton default width

--smart-power-button-default-heightvar()

Default value

"var(--smart-editor-height)"

smartPowerButton default height