mirror of
https://github.com/Nighthawk42/roll20-character-sheets.git
synced 2026-08-30 19:52:29 +00:00
87 lines
3.8 KiB
Plaintext
87 lines
3.8 KiB
Plaintext
//- @pugdoc
|
|
name: button
|
|
description: Creates a button element. Valid types are `roll` or `action`. If a type is not specified in the object argument, a roll button is created. If an action button is created, spaces in the name are replaced with dashes instead of underscores.
|
|
arguments:
|
|
- {object} buttonObj - The object describing the button
|
|
- {block} block - The contents of the button element
|
|
attributes:
|
|
example: |
|
|
include _htmlelements.pug
|
|
//A basic roll button
|
|
+button({name:'my button',value:'/r 3d10'})
|
|
//An action button
|
|
+button({name:'my button',type:'action','data-i18n':'action button',trigger:{triggeredFuncs:['doSomethingOnClick']}})
|
|
mixin button(obj, _attributes)
|
|
- checkKUse();
|
|
- obj.class = obj.class ? replaceProblems(obj.class) : undefined;
|
|
- obj.name = attrName(obj.name);
|
|
- obj.title = obj.title || buttonTitle(obj.name);
|
|
if obj.type === 'action'
|
|
- obj.name = `act_${obj.name}`;
|
|
else
|
|
- obj.type = 'roll';
|
|
- obj.name = `roll_${obj.name}`;
|
|
- const elementObj = makeElementObj(obj);
|
|
if obj.type !== 'roll'
|
|
- storeTrigger(obj);
|
|
button&attributes(elementObj)&attributes(attributes)
|
|
block
|
|
//-End Mixin
|
|
|
|
//- @pugdoc
|
|
name: action
|
|
description: Alias for {@link button} that creates a button element with a type of `action`. Spaces in the name are replaced with dashes instead of underscores.
|
|
arguments:
|
|
attributes:
|
|
example: |
|
|
include _htmlelements.pug
|
|
+action({name:'my button','data-i18n':'action button',trigger:{triggeredFuncs:['doSomethingOnClick']}})
|
|
mixin action(obj, _attributes)
|
|
- obj.class = obj.class ? replaceProblems(obj.class) : undefined;
|
|
- obj.type = 'action';
|
|
- obj.name = attrName(obj.name).replace(/[\s_]+/g,'-');
|
|
+button(obj)&attributes(attributes)
|
|
block
|
|
//- End Mixin
|
|
|
|
//- @pugdoc
|
|
name: navButton
|
|
description: Alias for {@link button} that creates a button element with a type of `action` for use in nav buttons. Spaces in the name are replaced with dashes instead of underscores. The name is prefixed with `nav_`. A {@link trigger} object should be passed
|
|
arguments:
|
|
attributes:
|
|
example: |
|
|
include _htmlelements.pug
|
|
+navButton({name:'my button','data-i18n':'action button'})
|
|
mixin navButton(obj)
|
|
- addIfUnique(obj.name,'navButtons');
|
|
- obj.name = `nav ${obj.name}`;
|
|
+action(obj)&attributes(attributes)
|
|
block
|
|
//- End Mixin
|
|
|
|
mixin rollerExtras(obj)
|
|
- obj.class = obj.class ? `${replaceProblems(obj.class)} roller` : 'roller';
|
|
- let attributeName = replaceSpaces(actionInputName(attrName(obj.name)));
|
|
- let actionName = actionButtonName(attributeName);
|
|
- obj.value = `@{${attributeName}}`;
|
|
- actionObj = {name:actionName,hidden:''};
|
|
- actionObj.trigger = obj.trigger || {listenerFunc:'initiateRoll'};
|
|
block
|
|
- addIfUnique(`${repeatingPrefix}${attributeName}`,'actionAttributes');
|
|
+action(actionObj)
|
|
+hidden({name:attributeName})
|
|
//- @pugdoc
|
|
name: roller
|
|
description: Creates a multi element construction made of a hidden input, a roll button, and a hidden action button. On sheet load, or character sheet name change, the hidden input is updated with an ability call to the action button. The roll button refers to the hidden input as its value. This allows for an action button to be used to call custom roll parsing (or other sheet functionality) while retaining the ability to drag the button to the macro bar. Uses the same arguments as {@link button}. A trigger should be passed, and will be associated with the action button's name.
|
|
arguments:
|
|
attributes:
|
|
example: |
|
|
include _htmlelements.pug
|
|
+roller({name:'my button','data-i18n':'action button',trigger:{triggeredFuncs:['doSomethingOnClick']}})
|
|
mixin roller(obj)
|
|
+rollerExtras(obj)
|
|
- let rollObj = {...obj};
|
|
- delete rollObj.trigger;
|
|
+button(obj)
|
|
block
|
|
//- End Mixin |