Is there a way to edit a CSS rule instead of having to edit all the elements that contain the rule? So if I had a CSS class: "title" can I change title''s font-size dynamically without doing something like a getElementsByClassName loop? Thanks! Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey Daniel, Daniel Eben Elmore a écrit :> Is there a way to edit a CSS rule instead of having to edit all the elements > that contain the rule? > > So if I had a CSS class: "title" can I change title''s font-size dynamically > without doing something like a getElementsByClassName loop?DOM Level 2 CSS lets you do just that, but I believe it has pretty scarce support so far... -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 Jun 15, 6:10 pm, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey Daniel, > > Daniel Eben Elmore a écrit : > > > Is there a way to edit a CSS rule instead of having to edit all the elements > > that contain the rule? > > > So if I had a CSS class: "title" can I change title''s font-size dynamically > > without doing something like a getElementsByClassName loop? > > DOM Level 2 CSS lets you do just that, but I believe it has pretty > scarce support so far...I wouldn''t say that, CSS 2 support isn''t really the issue. Modifying stylesheets is a bit of a chore but it''s well supported (at least by browsers that Prototype.js supports) and once you have a function to do it... :-) The link below shows a specific example, the general idea is to sift through the style sheets looking for the appropriate rule, then modify it. It''s easy if you''re looking for a class or ID, tougher for pseudo- classes and other rule types. <URL: http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/ac3617de7840cdc5/737a6ebc3674a373?lnk=gst&q=stylesheets&rnum=1&hl=en#737a6ebc3674a373>Another example: <URL: http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/8099b8785bbbc188/3713059f8aa18f97?lnk=gst&q=stylesheets&rnum=9&hl=en#3713059f8aa18f97>If you have lots of individual elements to hide (say a column in a table) it is much, much faster to modify a class rule that they all share than loop over all the rows and hide cells[x] one by one. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> The link below shows a specific exampleHey thanks Rob, I''ll give it a shot. It appears that finding the specific style will be difficult. -Daniel -----Original Message----- From: rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of RobG Sent: Friday, June 15, 2007 9:03 PM To: Ruby on Rails: Spinoffs Subject: [Rails-spinoffs] Re: Edit CSS Rule? On Jun 15, 6:10 pm, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey Daniel, > > Daniel Eben Elmore a écrit : > > > Is there a way to edit a CSS rule instead of having to edit all theelements> > that contain the rule? > > > So if I had a CSS class: "title" can I change title''s font-sizedynamically> > without doing something like a getElementsByClassName loop? > > DOM Level 2 CSS lets you do just that, but I believe it has pretty > scarce support so far...I wouldn''t say that, CSS 2 support isn''t really the issue. Modifying stylesheets is a bit of a chore but it''s well supported (at least by browsers that Prototype.js supports) and once you have a function to do it... :-) The link below shows a specific example, the general idea is to sift through the style sheets looking for the appropriate rule, then modify it. It''s easy if you''re looking for a class or ID, tougher for pseudo- classes and other rule types. <URL: http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/ac3 617de7840cdc5/737a6ebc3674a373?lnk=gst&q=stylesheets&rnum=1&hl=en#737a6ebc36 74a373>Another example: <URL: http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/809 9b8785bbbc188/3713059f8aa18f97?lnk=gst&q=stylesheets&rnum=9&hl=en#3713059f8a a18f97>If you have lots of individual elements to hide (say a column in a table) it is much, much faster to modify a class rule that they all share than loop over all the rows and hide cells[x] one by one. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RobG wrote:> I wouldn''t say that, CSS 2 support isn''t really the issue. Modifying > stylesheets is a bit of a chore but it''s well supported (at least by > browsers that Prototype.js supports) and once you have a function to > do it... :-) > > The link below shows a specific example, the general idea is to sift > through the style sheets looking for the appropriate rule, then modify > it. It''s easy if you''re looking for a class or ID, tougher for pseudo- > classes and other rule types. > > <URL: > http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/ac3617de7840cdc5/737a6ebc3674a373?lnk=gst&q=stylesheets&rnum=1&hl=en#737a6ebc3674a373 > > > Another example: > > <URL: > http://groups.google.com.au/group/comp.lang.javascript/browse_frm/thread/8099b8785bbbc188/3713059f8aa18f97?lnk=gst&q=stylesheets&rnum=9&hl=en#3713059f8aa18f97 > > If you have lots of individual elements to hide (say a column in a > table) it is much, much faster to modify a class rule that they all > share than loop over all the rows and hide cells[x] one by one.Effect.morph() uses the snippet below to get css rules. Getting and setting cssRules seems quite useful. Are there any pitfalls to this approach? Is it seen as an edge case? I''ve seen no discussion from the library authors on cssRules. (see http://dev.rubyonrails.org/search?q=cssRules&wiki=on&changeset=on&ticket=on) --Ken effects.js version 1.7.1_beta3 line 939 --------------------------------------- var cssText = '''', selector = ''.'' + options.style; $A(document.styleSheets).reverse().each(function(styleSheet) { if (styleSheet.cssRules) cssRules = styleSheet.cssRules; else if (styleSheet.rules) cssRules = styleSheet.rules; $A(cssRules).reverse().each(function(rule) { if (selector == rule.selectorText) { cssText = rule.style.cssText; throw $break; } }); if (cssText) throw $break; }); this.style = cssText.parseStyle(); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---