I have a question: How do you style the various components of the anchor tag? I am doing it this way: $$(''a:link,a:visited'').each(function(link){ //links link.setStyle({ color: ''#''+$F(''cp4_Hex'') }); }); $$(''a:hover'').each(function(link){ //links link.setStyle({ color: ''#''+$F(''cp5_Hex'') }); }); And it kind of works--I see a style change--but even though I declare the a:hover, a:link, or what have you, all the anchor tags are given the last color, in this case, :hover. How does one do this correctly? Amiri --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
:hover, :link and :visited pseudo classes are not supported. Why can''t you just define these rules in css? - kangax On May 30, 7:07 pm, Amiri <amiribarksd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a question: How do you style the various components of the > anchor tag? I am doing it this way: > > $$(''a:link,a:visited'').each(function(link){ //links > link.setStyle({ color: ''#''+$F(''cp4_Hex'') });}); > > $$(''a:hover'').each(function(link){ //links > link.setStyle({ color: ''#''+$F(''cp5_Hex'') }); > > }); > > And it kind of works--I see a style change--but even though I declare > the a:hover, a:link, or what have you, all the anchor tags are given > the last color, in this case, :hover. > > How does one do this correctly? > > Amiri--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I can and do define those rules in CSS, but I want to overwrite them to create a "live dynamic preview" of CSS changes, before I save those changes to CSS. So Prototype has no access to those classes. OK. Amiri On May 31, 6:47 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> :hover, :link and :visited pseudo classes are not supported. > Why can''t you just define these rules in css? > > - kangax > > On May 30, 7:07 pm, Amiri <amiribarksd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have a question: How do you style the various components of the > > anchor tag? I am doing it this way: > > > $$(''a:link,a:visited'').each(function(link){ //links > > link.setStyle({ color: ''#''+$F(''cp4_Hex'') });}); > > > $$(''a:hover'').each(function(link){ //links > > link.setStyle({ color: ''#''+$F(''cp5_Hex'') }); > > > }); > > > And it kind of works--I see a style change--but even though I declare > > the a:hover, a:link, or what have you, all the anchor tags are given > > the last color, in this case, :hover. > > > How does one do this correctly? > > > Amiri--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
":hover" behavior can be simulated easily: $$(''a.someClass'').each(function(el) { el.observe(''mouseover'', function() { this.setStyle({ color: ''#''+ $F(''cp5_Hex'') }) }); el.observe(''mouseout'', function() { this.setStyle({ color: ''#fff'' }) }) }); - kangax On May 31, 10:42 am, Amiri <amiribarksd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I can and do define those rules in CSS, but I want to overwrite them > to create a "live dynamic preview" of CSS changes, before I save those > changes to CSS. So Prototype has no access to those classes. OK. > > Amiri > > On May 31, 6:47 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > :hover, :link and :visited pseudo classes are not supported. > > Why can''t you just define these rules in css? > > > - kangax > > > On May 30, 7:07 pm, Amiri <amiribarksd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have a question: How do you style the various components of the > > > anchor tag? I am doing it this way: > > > > $$(''a:link,a:visited'').each(function(link){ //links > > > link.setStyle({ color: ''#''+$F(''cp4_Hex'') });}); > > > > $$(''a:hover'').each(function(link){ //links > > > link.setStyle({ color: ''#''+$F(''cp5_Hex'') }); > > > > }); > > > > And it kind of works--I see a style change--but even though I declare > > > the a:hover, a:link, or what have you, all the anchor tags are given > > > the last color, in this case, :hover. > > > > How does one do this correctly? > > > > Amiri--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You can access the stylesheets via document.styleSheets, and you can even manipulate through these means as well. It gets extremely clunky very fast, but it is possible. Here is an example: var hoverRule $A(document.styleSheets[0].cssRules).detect(function(rule){if (rule.selectorText == ''a:hover'') return rule;}); hoverRule.style.color = ''#0C0''; // make the hover state for all links green; If you''re just sticking to anchor pseudo classes like :hover, :active, etc... then this could be the approach you''re looking for, but if you''re looking to update arbitrary selectors things will get pretty unwieldy for you quite fast. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Justin, there''s no need to explicitly return a "rule" in this case. #detect(#find) does it automatically: $A(document.styleSheets[0].cssRules).detect( function(rule) { return rule.selectorText == ''a:hover''; }); - kangax On May 31, 1:02 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You can access the stylesheets via document.styleSheets, and you can > even manipulate through these means as well. It gets extremely clunky > very fast, but it is possible. Here is an example: > > var hoverRule > $A(document.styleSheets[0].cssRules).detect(function(rule){if > (rule.selectorText == ''a:hover'') return rule;}); > hoverRule.style.color = ''#0C0''; // make the hover state for all links green; > > If you''re just sticking to anchor pseudo classes like :hover, :active, > etc... then this could be the approach you''re looking for, but if > you''re looking to update arbitrary selectors things will get pretty > unwieldy for you quite fast. > > -justin--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sat, May 31, 2008 at 2:44 PM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Justin, > there''s no need to explicitly return a "rule" in this case. > #detect(#find) does it automatically:Thanks, that''s a lot more concise :) -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I am not doing many of those types of changes, so I think I will take this array-utility approach to the document stylesheets. Thank you! Amiri On May 31, 11:11 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sat, May 31, 2008 at 2:44 PM, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Justin, > > there''s no need to explicitly return a "rule" in this case. > > #detect(#find) does it automatically: > > Thanks, that''s a lot more concise :) > > -justin--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---