Ah, I see. I think your best bet is going to be to use the Markup Item method that Ernie suggested.
Thanks Joe - I appreciate that you cannot expose all elements so that they can be extended but a pity as I was trying to produce something that the average FW user (without resorting to markup) could utilise.
The easiest method to add the class to the label that I have found was a jQuery snippet
Ah, I see. I think your best bet is going to be to use the Markup Item method that Ernie suggested.
Thanks Joe - I appreciate that you cannot expose all elements so that they can be extended but a pity as I was trying to produce something that the average FW user (without resorting to markup) could utilise.
The easiest method to add the class to the label that I have found was a jQuery snippet
Or two lines if you just want to use plain vanilla JS;
var i=document.getElementsByTagName("label");
for (x in i){i[x].className="myclass"}
This assumes you want all of your labels to have the same class. Also remember to load the script after the elements on the page as for brevity there isn’t any error checking here.
On another note… this got me thinking that it would be cool to be able to run code like this inside Freeway without having to write a custom Action for it. Add the code to the page and Freeway adds the class to the item before it outputs the page.
Regards,
Tim.
Maybe a meta-action that could run user-provided JavaScript against the DOM as it’s being generated, and produce the output as the final stage of processing. See Grunt or other Node-based geek tools for example.
I can easily think of a way to start to do this in an Action that ran at fwAfterEndHTML() and just scraped the page into text, but how to get a real HTML DOM at that level, where you could then use the full range of DOM tree traversal tools built into JavaScript? Freeway’s Action JavaScript is based on the original Gecko JS engine (although I’m sure that’s been replaced by now, that’s what it used to be) but it doesn’t expose the entire stack, only the parts of the language that make sense for Action-writing. Without a DOM, we are stuck with bear skins and stone knives (regular expression-based text conversion).
Now if the Freeway Actions API and engine was based on Node, you would have a whole world of new tools to throw at problems. Run a local server on a high port? Go ahead. Fake-evaluate PHP or other server-side languages? Done.
If the Freeway DOM was exposed (before publishing!) as a shadow HTML DOM, and both data structures were “live” to one another, so it didn’t matter which one you used to make a change – the underlying single data “truth” would change – then you would really have something that would sit up and bark.
Walter
On Feb 25, 2014, at 12:10 PM, DeltaDave wrote:
Add the code to the page and Freeway adds the class to the item before it outputs the page.
That is what I was thinking - no js in the html. Which was the ultimate aim.