|
Selectors in ConnectSelectors are patterns used to select one or more HTML elements. They were originally developed to be able to define the layout of web pages without touching their content, through Cascading Style Sheets (CSS). In Connect, since each section in a Connect template is in fact an HTML file (see Editing HTML), the very same selectors can be used in style sheets (see Styling templates with CSS files) and template scripts (see Personalizing Content and Writing your own scripts). Selectors can increase the speed with which a template and data are merged; see Use an ID as selector. Standard CSS selectors
These components can be combined in different ways. For example, A complete list of selectors and ways to combine them, and a tool that demonstrates their use can be found at W3Schools: http://www.w3schools.com/cssref/css_selectors.asp. A video about CSS and Script Selectors, can be found here: Connect with Evie 6 - CSS and Script Selectors. Connect classes and attributesConnect itself sometimes adds a specific class or attribute to elements in a template. Capture OnTheGo widgets, for example, have a Connect-specific classes usually are invisible in the Designer. By opening the currently selected section in your default web browser (click the Preview HTML toolbar button) and using the browser's code or source inspector you can see most of the dynamically added classes. Avoid using classes with the __ol prefix in your selectors. These dynamically added class names may change in future releases of the software.
Section selectorThe Designer writes the name of each section to the ExampleThe following rule applies formatting to <h1> elements in sections of which the name starts with ‘Letter’:
To make scripts run exclusively on certain sections, it is advised to put them in folders and set the execution scope of the scripts in a folder via the folder properties; see Execution scope.
Sheet position selectorsIn Print output, pages have a sheet position that depends on the options set in the Sheet Configuration dialog (e.g. the Duplex and Allow Content On options). Connect gives each page - or rather, the "MediaBox" div element on that page - a class depending on their sheet position:
The MediaBox contains the Master Page objects and section backgrounds. This means that these classes can only be used to format a Master Page and section background. They do not let you change the formatting of elements residing in the main text flow (e.g. a <h1> element on page 3). Conditionally formatting Master Page objectsThe following CSS rule sets the color of <h1> elements on a Master Page when that Master Page is present on the front of a sheet.
The next style rule is a bit more specific: it colors <h1> elements on a Master Page when that Master Page is applied to the front of a sheet in Section 1:
The following rule hides <h1> elements on the back of a sheet on which no content (from the main text) is allowed. .backside.nocontentpage .h1 { Print section background selectorWhen you inspect a Print section in a browser, you will see that it has a <div id="pages"> element as the first child of the <body> element. Inside this <div> there are one or more MediaBoxes: elements with the class In the MediaBox, a Print section background is an <img> element with the Placing the section background in front of the Master PageThe stacking order of elements inside each MediaBox, from bottom to top, is:
Using the
Scaling the section backgroundThe rule below downscales the section background image and keeps it in the centre of the page:
View selectorsIn the Designer, sections can be viewed on different tabs: Source, Design, Preview and - if it is a Web section - Live. In each view mode (except Source) a specific CSS class is added to the <html> element. The view-specific classes are:
.OUTPUT is used when viewing the current section on the Live tab or in an external browser, and when generating output. View selectors allow you to apply formatting to elements in a certain view, for example to highlight or show elements. The Designer itself does this, for example, to highlight all boxes in the Design view, when the Show Edges icon is clicked. Adding an outlineThe following style rule wraps every element that has the class
Adding a background patternThe Postcard template wizard (in the Basic Print templates group) uses the .DESIGN class to mark areas that are reserved for postal use and should not contain text or images. These areas were added to the Master Page as absolute positioned boxes that have been given the class
The pattern image was created on www.patternify.com and is added as a data URI (see Data URIs).
Showing hidden Foundation elementsIn Capture OnTheGo templates based on the Foundation framework the .DESIGN selector can be used to show elements that would otherwise be hidden in the Design view.
|
|