[Pro] Form labels and adding classes

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

<script type="text/javascript">
$('label').addClass('mynewclass');
</script>

Is there an equivalent 1 line protaculous version? Or for that matter one in plain JS.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You know there is!

$$('label').invoke('addClassName', 'mynewclass');

Walter

On Feb 25, 2014, at 11:33 AM, DeltaDave wrote:

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

<script type="text/javascript">
$('label').addClass('mynewclass');
</script>

Is there an equivalent 1 line protaculous version? Or for that matter one in plain JS.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Ouch!!! Knuckles severely rapped.

Its been a long week already - and its only Tuesday!

Thanks Walter.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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.

On 25 Feb 2014, at 16:37, Walter Lee Davis wrote:

$$(‘label’).invoke(‘addClassName’, ‘mynewclass’);


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

It suddenly occurred to me today that previously I had modified Walter’s AddSelector action to include Link Tags to its scope.

It was relatively straightforward to include the option to do the same for the Label Tag.

D


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options