Änderungen von Dokument Button

Zuletzt geändert von xwikiadmin am 2025/05/21 09:49

Von Version 4.1
bearbeitet von xwikiadmin
am 2025/05/21 09:24
Änderungskommentar: Migrated property [feature] from class [XWiki.WikiMacroParameterClass]
Auf Version 5.1
bearbeitet von xwikiadmin
am 2025/05/21 09:49
Änderungskommentar: Install extension [com.xwiki.pro:xwiki-pro-macros-ui/1.26.19]

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -10,6 +10,9 @@
10 10  |width|$services.localization.render('rendering.macro.button.parameter.width.description')|-
11 11  |newTab|$services.localization.render('rendering.macro.button.parameter.newTab.description')|false
12 12  |icon|$services.localization.render('rendering.macro.button.parameter.icon.description')|-
13 +|type|$services.localization.render('rendering.macro.button.parameter.type.description')|Default
14 +|id|$services.localization.render('rendering.macro.button.parameter.id.description')|Default
15 +|class|$services.localization.render('rendering.macro.button.parameter.class.description')|Default
13 13  
14 14  == Examples ==
15 15  
... ... @@ -31,4 +31,8 @@
31 31  {{code}}{{button label="Store" url="http://store.xwiki.com" color="#889cb8" newTab="true" icon="page" width="100%"/}}{{/code}}
32 32  
33 33  {{button label="Store" url="http://store.xwiki.com" color="#889cb8" newTab="true" icon="page" width="100%"/}}
37 +
38 +{{code}}{{button label="Delete example" url="http://store.xwiki.com" type="DANGER"/}}{{/code}}
39 +
40 +{{button label="Delete example" url="http://store.xwiki.com" type="DANGER"/}}
34 34  {{/velocity}}
XWiki.WikiMacroClass[0]
Makro-Code
... ... @@ -32,6 +32,9 @@
32 32   #set ($width = $escapetool.xml($wikimacro.parameters.width))
33 33   #set ($newTab = $escapetool.xml($wikimacro.parameters.newTab))
34 34   #set ($icon = $escapetool.xml($xcontext.macro.params.icon))
35 + #set ($macro.id = $wikimacro.parameters.id)
36 + #set ($macro.classParam = $wikimacro.parameters.get('class'))
37 + #set ($macro.type = $wikimacro.parameters.type)
35 35   ## Resolve the url as a Wiki Document if it exists, else assume it is an external link
36 36   #if ($xwiki.exists($url))
37 37   #set ($url = $xwiki.getDocument($url).getURL())
... ... @@ -43,6 +43,13 @@
43 43   #else
44 44   #set ($colors = [255, 255, 255])
45 45   #end
49 + #set ($macro.additionalClass = '')
50 + #if ("$!macro.classParam" != '')
51 + #set ($macro.additionalClass = "$macro.additionalClass $macro.classParam")
52 + #end
53 + #if ("$!macro.type" != '')
54 + #set ($macro.additionalClass = "$macro.additionalClass btn-$macro.type.name().toLowerCase()")
55 + #end
46 46   #set ($darkenedColors = [])
47 47   #darken($colors, $darkenedColors)
48 48   {{html clean=false}}
... ... @@ -54,13 +54,18 @@
54 54   #if (!$wikimacro.context.isInline())<p>#end
55 55   <a href="$url" #if($newTab == 'true')target="_blank"#end>
56 56   <button
67 + #if ("$!macro.id" != '')
68 + id="$escapetool.xml($macro.id)"
69 + #end
57 57   style="
71 + #if ("$!color" != '')
58 58   background-color: #toCssRGB($colors);
59 59   border-color: #toCssRGB($darkenedColors);
60 60   color: #fontColor($colors);
75 + #end
61 61   width: $!width;
62 62   "
63 - class="btn">
78 + class="btn $escapetool.xml($macro.additionalClass)">
64 64   $!services.icon.renderHTML($!icon)
65 65   $label
66 66   </button>
Makrobeschreibung
... ... @@ -1,1 +1,0 @@
1 -Insert a button!
XWiki.WikiMacroParameterClass[0]
Parameter-Beschreibung
... ... @@ -1,1 +1,0 @@
1 -The label of the button.
XWiki.WikiMacroParameterClass[1]
Parameter-Beschreibung
... ... @@ -1,1 +1,0 @@
1 -A link or a page reference.
XWiki.WikiMacroParameterClass[2]
Parameter-Beschreibung
... ... @@ -1,1 +1,0 @@
1 -The color of the button.
XWiki.WikiMacroParameterClass[3]
Parameter-Beschreibung
... ... @@ -1,1 +1,0 @@
1 -The width of the button specified in pixels, percentage or other valid CSS value (ex. 30px, 30%, 30em). If no value is specified, the width will be determined by the length of the label.
XWiki.WikiMacroParameterClass[4]
Parameter-Beschreibung
... ... @@ -1,1 +1,0 @@
1 -Denotes whether the page will be opened in a new page or not.
XWiki.WikiMacroParameterClass[5]
Parameter-Beschreibung
... ... @@ -1,1 +1,0 @@
1 -Icon associated with the button, placed before the label.
XWiki.WikiMacroParameterClass[6]
Parameter-Vorgabe
... ... @@ -1,0 +1,1 @@
1 +DEFAULT
Parameter-Name
... ... @@ -1,0 +1,1 @@
1 +type
Parameter-Typ
... ... @@ -1,0 +1,1 @@
1 +com.xwiki.macros.button.ButtonType
Parameter verpflichtend
... ... @@ -1,0 +1,1 @@
1 +Nein
XWiki.WikiMacroParameterClass[7]
Parameter-Name
... ... @@ -1,0 +1,1 @@
1 +id
Parameter-Typ
... ... @@ -1,0 +1,1 @@
1 +java.lang.String
Parameter verpflichtend
... ... @@ -1,0 +1,1 @@
1 +Nein
XWiki.WikiMacroParameterClass[8]
Parameter-Name
... ... @@ -1,0 +1,1 @@
1 +class
Parameter-Typ
... ... @@ -1,0 +1,1 @@
1 +java.lang.String
Parameter verpflichtend
... ... @@ -1,0 +1,1 @@
1 +Nein