Page History
Excerpt |
---|
To include a web resource (such as custom CSS or JavaScript file) on the page every time Structure Widget is displayed, add a |
Use cases:
- You create your own custom field and would like it to be editable in the Structure grid. The field is powered by additional JavaScript or CSS, which should be loaded on the page that displays structure.
- You create your own column type. You'll need to use the Structure JavaScript API and register the web resource with your JavaScript code as a widget extension.
Widget Extensions
Structure 2.5 introduces a new module type – structure-widget-extension
. Widget extensions contain references to the web resource modules that will be included on all pages where the Structure widget is present. Creating a widget extension is the preferred method of adding JavaScript and CSS code to the Structure widget since Structure 2.5.
Sample snippet from atlassian-plugin.xml
:
Code Block | ||||
---|---|---|---|---|
| ||||
<structure-widget-extension key="we-sbcolumn" name="widget-extension:Status Bar Column"> <web-resource>com.almworks.jira.structure.sbcolumn:wr-sbcolumn</web-resource> </structure-widget-extension> |
structure.widget
Web Resource Context
Before Structure 2.5, the only way to add JavaScript or CSS to the Structure widget was to add a web resource to the structure.widget
context. Note, however, that due to Atlassian API limitations, context-provided web resources may not be loaded on all pages with the Structure widget. The notable exceptions are the Structure Gadget and the JIRA Agile (GreenHopper) Structure panel.
In Structure 2.5+ the structure.widget
resource context is still present, but its resources are loaded only for the Structure Board and the Structure Gadget. We recommend you to use widget extensions instead.
Sample snippet from atlassian-plugin.xml
:
Code Block | ||||
---|---|---|---|---|
| ||||
<web-resource key="custom-field-resource" name="My Custom Field Web Resource"> <context>structure.widget</context> <resource type="download" name="custom-field-resource.js" location="js/myplugin/custom-field-resource.js"/> </web-resource> |
structure.printable
Web Resource Context
Web resources from the structure.printable
context are loaded on the printable page. While this context is not directly associated with the Structure widget, you'll need it to add a new column type that uses custom CSS in its printable representation.