Local sub-theme definitions - Javascript

Description

Define the Javascript for any locally defined sub-themes. Sub-themes are used to create custom appearance of certain control types such as windows, buttons, tabs, accordions, sliders. switches, etc.

images/ls.png
Defining a sub-theme lets you easily add customized CSS to controls.

Sub-themes are just what their name implies, variations on a larger theme. The larger theme in this case is the Style name of a component, for example 'iOS7', 'Alpha', or 'MobBlue'. This main theme can be set using the Style name property on the UX Properties page. Once a style has been choosen, the sub-theme property for a given javascript-based control can be used to alter the appearance of that control.

You can change a control's sub-theme by clicking on the sub-theme property in the control's properties list, on the UX Controls page, and selecting the desired sub-theme from a menu. Most styles have multiple existing sub-theme options that are available for most controls. If you add a button control to a component using the iOS7 style, for instance, you will then be able to select a 'base', 'confirm', 'deny', 'left', or 'right' sub-theme for that button. This will change the appearance of the button while still maintaining the overall look and feel of the iOS7 style.

You can also define your own sub-themes. Doing this requires defining both the javascript and css for the sub-theme. The javascript definition can be created in the 'Local sub-theme definitions - Javascript' property's code editor. The javascript itself can be pulled from an existing style, using the hyperlinks in the editor, and copied and pasted into the editor. The names of any new custom CSS classes that you want to add, as part of the sub-theme, should be included in the javascript code. These CSS classes can then be defined using the 'Local sub-theme definitions - CSS' property. For a video explanation on how this is done, watch the following video. Or read the guide below.

Define a Control and Select a Main Theme

  1. In the UX Builder on the UX Controls page. Open the 'Other Controls' menu and click on the [Button] option to add a button control to the component.

    images/ls2.png
  2. Open the UX Properties. In the UX Properties section click on the [...] button next to the 'Style name' property.

    images/ls3.png
  3. In the Select Style dialog's 'Location' menu select the 'System' option. Choose one of the listed styles, this example uses 'iOS7'. Click OK.

    images/ls4.png

Defining the Javascript for a Custom Subtheme

  1. On the UX Properties page click the [...] button next to the 'Local sub-theme definitions - Javascript' option.

    images/ls5.png
  2. Click the 'Show style.js file for current style' hyperlink at the top of the "Javascript and CSS for Local Sub-Theme Definitions" dialog. This will open the javascript definitions for the built-in subthemes available for the current style, in this can iOS7.

    images/ls6.png
  3. Click the 'Find' button and type 'button: {'. Click enter several times until you find the JSON definition for the button control's CSS classes. You will see the current sub-themes for the button control.

    images/ls7.png
  4. Highlight and copy the JSON definition for the button property. Click OK.

    images/ls8.png
  5. In the Javascript tab add two curly brackets.

    images/ls9.png
  6. Paste the copied JSON into the curly brackets.

    images/ls10.png
  7. Delete all of the subtheme definitions except for one. If there are any trailing commas delete these as well.

    images/ls11.png
  8. Give the sub-theme a new name, in this case 'custom'

    images/ls12.png
  9. Change the CSS class name definitions in quotation marks to new CSS class names in quotation marks

    images/ls13.png
  10. Click the 'Validate Javascript' button to make sure the new JSON is valid

    images/ls14.png
  11. Copy the first of the new CSS class names that you defined.

    images/ls15.png

Defining the CSS for a Custom Subtheme

  1. Click on the CSS tab in the 'Javascript and CSS for Local Sub-theme Definitions' dialog.

    images/ls16.png
  2. Paste the CSS class name that you copied from the Javascript tab into the CSS definitions section. Place a period '.' in front of the class name to define it as a CSS class and curly brackets '{}' after the class name to add a definition.

    images/ls17.png
  3. Add any other CSS class names to the CSS tab by copying and pasting them from the Javascript tab into the CSS tab.

    images/ls18.png
  4. Click the 'Edit in CSS Builder' button.

    images/ls19.png
  5. In the CSS Editor open the 'Design' tab.

    images/ls20.png
  6. In the Design tab highlight the first CSS class name in the list on the left.

    images/ls21.png
  7. Use the properties list on the right to change the button's CSS font, background, border, text alignment, and padding.

    images/ls22.png
  8. Define the other CSS classes. Click OK and OK again.

    images/ls25.png
    If you only want to change a few CSS settings you can use the 'Code' tab to copy existing CSS settings from one class to the next.You can then return to the Design tab, where then copied definitions will be reflected, and alter .

Setting a Control to a Subtheme

  1. Open the UX Controls page and highlight the button control. In the properties list on the right click on the [...] button next to the 'Sub-theme' property in the 'Button Appearance' section.

    images/ls23.png
  2. Select the sub-theme that you defined using JSON and click OK.

    images/ls24.png
  3. Run the component in Live Preview, you should see the new subtheme.

    images/ls26.png
  4. When pressed, the button should display the CSS class for a pressed button.

    images/ls27.png