Adding and removing many style elements

T

Thomas 'PointedEars' Lahn

Scott said:
Thomas said:
That approach is wrong, it is not supposed to work (reliably).

Why is that? According to the CSS2 Spec [1], importance and origin
are of higher priority than than specificity.

You referred to CSS 2.1, but it was specified so in CSS 2, too. Apparently
I have overlooked/misunderstood that part of the section all the time.
Thank you.
It's not all clear to me how this is supposed to interact with ECMAScript
DOM implementations.

Interact?


PointedEars
 
D

David Mark

Thomas said:
Scott said:
Thomas said:
Scott Sauyet wrote:
Richard Cornford wrote:
Although styles applied directly to an element have the highest
specificity, and so override nearly everything else, you could
try using CSS's - !important - rule modifier in the print style
sheet. That has worked for me in similar situations.
I'm wondering if I simply didn't do this to everything that needed to
be done. I did try this, as that was the first thing to come to
mind. I'll go back and check it again.
That approach is wrong, it is not supposed to work (reliably).
Why is that? According to the CSS2 Spec [1], importance and origin
are of higher priority than than specificity.

You referred to CSS 2.1, but it was specified so in CSS 2, too. Apparently
I have overlooked/misunderstood that part of the section all the time.
Thank you.

I had my suspicions but confess to never bothering to look it up. It
just seemed crazy to me that such a strategy would not work (regardless
of what the specs said about it). That and the fact that at least a
hundred different browsers had worked fine with it over the years seemed
to confirm at least an ad hoc standard. Glad it's a "real" one after
all! :)

I just used it again in the last hour. It seems the perfect (and
perhaps intended) way to override scripted style changes (usually
visibility or display) in print media.
 
S

Scott Sauyet

David said:
Scott said:
Why is that?  According to the CSS2 Spec [1], importance and origin
are of higher priority than than specificity.  It's not all clear to
me how this is supposed to interact with ECMAScript DOM
implementations.

The !important trick, as described by Richard, works.  I've used it for
many years and though I don't know for sure if the original specs are in
agreement, I've never encountered a browser that wasn't.  If the specs
say it won't work, they are long since irrelevant in the matter (i.e. an
ad hoc standard trumps them now).  Knowing your history is sometimes as
(or more) important than knowing the specs.

I was clearly doing something else wrong. I haven't tried to get a
minimal test case as the requirements have changed on this and I went
with an entirely different solution. Somehow or another, though, even
"!important" print rules didn't seem to override the scripted ones.
We'll see if I find time to figure out why, because I know I've used
them before too. Since well before I was heavily involved with JS,
I've been a strong advocate for CSS, and I believe I know pretty well
what to expect. I'm still not sure why it didn't work in this case,
but I'm willing to bet it's a stupid error on my part.
In short, if you hide something with inline style that you want to
print, add an !important rule to your (static) print style sheet that
un-hides it.  No extra script needed.

That's what the spec says and what I believe generally works. Damn,
I'm going to have to create that test case anyway! :-(

Thanks for the responses,
 
S

Scott Sauyet

Thomas said:
"Mu" is the correct answer here.  It is unnecessary (and unwise) to "add and
remove a large number of style elements" (client-side, programmatically);
not only with regard to your problem.

Feel free to un-ask the question yourself, but I personally still find
it an interesting idea to research.

ISTM you can lose the wrapper-DIV, see <http://PointedEars.de/es-matrix>.
[ ... ]
That's one of the places I looked right away.  I seem to remember that
you until recently had a button to toggle whether the table scrolled
or the body did.

You remember correctly.
Am I imagining that?

No, given the same user agent it should still be there.  However, in
contrast to previous revisions it remains hidden (display: none) when
and while activating it would not have an effect.
I was hoping that this button simply altered class names to switch which
styles applied.

It does add/remove/modify the `class' attribute of the TBODY element withID
`scroller'.  See printScrollButton() in table.js for details.
If that worked, I assumed I could simply put one in my print-only
stylesheet and the other one on screen media.  But I don't see that button
any more.  I didn't chase it down further.

Either you did not use a user agent that supports sizeable TBODYs (which
includes Firefox/Iceweasel 3.6.3) or something is wrong with my feature-
testing that.

For me, in FF3.6.3, the TBODY is scrolling properly, and if I call

scroller.toggleScroll(true);

from the console it toggles as expected, but the button is not
visible. In other recent browsers I've tested the TBODY does not
scroll. And if I try making that call from IE8's console it returns
true, but also reports some error and does not change the scroll
behavior.


[Google's Living Stories]  An example of this is at

Perhaps I am looking into this later, but I really do not expect too muchof
client-side Google applications at this point with regard to code quality
and accessibility.

Maybe not, but it was the effect I was interested in and not the
implementation. I can't see any likely accessibility problems with
it, but it is Google, so who knows?

I'll ask two good questions by contrast to yours:

What if the window is too small?  

I don't resize the table below a certain size.

What if client-side DOM scripting is unavailable or insufficiently
supported?

Then the size of the table will not be adjusted. It will still be
visible. But that's simply out of habit. The system I'm taking over
gets all it's data through AJAX calls and displays it through DOM
manipulation. The page will not function at all with JavaScript
disabled. I disagree with this design, and will argue for change, but
that's pretty low down my list of things that need to be changed.

You don't need scripting for that, then.

Maybe not, but I think anything that would do this with straight CSS
would involve a significant change in page markup. It might be
doable, but it doesn't seem straightforward.

All this might be a case, though, of my knowing that nothing will work
without client scripting enabled and hence viewing such script as an
all-purpose hammer. I'll think about it some more.

Perhaps not.  I'm trying other techniques, [...]

Like the straightforward one, CSS?

Yes, if I can do so without entirely reworking the pages.

ISTM CSS can readily provide this.

That's easy to do if there is no fixed-size header. I'm not so sure
how to do it as it stands. But that's off-topic in cljs.

In any case, thank you very much for the advice.
 
T

Thomas 'PointedEars' Lahn

Scott said:
Thomas said:
Scott said:
Thomas 'PointedEars' Lahn wrote:
ISTM you can lose the wrapper-DIV, see
<http://PointedEars.de/es-matrix>.
[ ... ]
That's one of the places I looked right away. I seem to remember that
you until recently had a button to toggle whether the table scrolled
or the body did.

You remember correctly.
Am I imagining that?

No, given the same user agent it should still be there. However, in
contrast to previous revisions it remains hidden (display: none) when
and while activating it would not have an effect.
I was hoping that this button simply altered class names to switch which
styles applied.

It does add/remove/modify the `class' attribute of the TBODY element with
ID `scroller'. See printScrollButton() in table.js for details.
If that worked, I assumed I could simply put one in my print-only
stylesheet and the other one on screen media. But I don't see that
button any more. I didn't chase it down further.

Either you did not use a user agent that supports sizeable TBODYs (which
includes Firefox/Iceweasel 3.6.3) or something is wrong with my feature-
testing that.

For me, in FF3.6.3, the TBODY is scrolling properly, and if I call

scroller.toggleScroll(true);

from the console it toggles as expected, but the button is not
visible.

Confirmed. It works locally, though, so probably there is a remote library
version mismatch (I am currently updating those manually, while the Matrix
files get updated automatically via SVN commit). I'll look into it.
In other recent browsers I've tested the TBODY does not
scroll.

Works as designed, I suppose.
And if I try making that call from IE8's console it returns true, but
also reports some error and does not change the scroll behavior.

No error message in Wine IE 6. Before I need to switch to Windows:
With cleaned cache, what exactly is the error reported, please?
Maybe not, but I think anything that would do this with straight CSS
would involve a significant change in page markup. It might be
doable, but it doesn't seem straightforward.

I am 96% sure that the markup does not need significant change, if at all.
That's easy to do if there is no fixed-size header.

I don't see why that would be relevant.
I'm not so sure how to do it as it stands. But that's off-topic in cljs.
ACK

In any case, thank you very much for the advice.

You are welcome.


PointedEars
 
T

Thomas 'PointedEars' Lahn

Thomas said:
Scott said:
Thomas said:
Scott Sauyet wrote:
Thomas 'PointedEars' Lahn wrote:
ISTM you can lose the wrapper-DIV, see
<http://PointedEars.de/es-matrix>.
[ ... ]
If that worked, I assumed I could simply put one in my print-only
stylesheet and the other one on screen media. But I don't see that
button any more. I didn't chase it down further.

Either you did not use a user agent that supports sizeable TBODYs (which
includes Firefox/Iceweasel 3.6.3) or something is wrong with my feature-
testing that.

For me, in FF3.6.3, the TBODY is scrolling properly, and if I call

scroller.toggleScroll(true);

from the console it toggles as expected, but the button is not
visible.

Confirmed. It works locally, though, so probably there is a remote
library version mismatch (I am currently updating those manually, while
the Matrix files get updated automatically via SVN commit). I'll look
into it.

Fixed. (As I suspected, a remote library was not up-to-date. The new
dhtml.js revision 174 has dom.addClassName() return `true' on success which
is essential for the callback unhiding the button to be called in the
Matrix's table.js.)
No error message in Wine IE 6. Before I need to switch to Windows:
With cleaned cache, what exactly is the error reported, please?

I would still like to know more about this one.


PointedEars
 
S

Scott Sauyet

Thomas said:
I am 96% sure that the markup does not need significant change, if at all..

Oh, I am 100% certain that the markup does need significant change.
But perhaps not to solve this issue! :)

I don't see why that would be relevant.

It's simply that if I try to give this main table a percentage height
and combine it with the fixed height header, I would run into issues.
Perhaps putting a negative margin on the header offsetting some fixed
padding of a container holding it and the table, and making them equal
to the size of... wait a second, I'm back off cljs again. Maybe I'll
go check out ciwa.stylesheets or CSS Discuss.

Again, thanks for the help,

-- Scott
 
S

Scott Sauyet

I will try it again tomorrow when I have access to Windows.

When I load up IE8's Developer Tools, and enter
"scroller.toggleScroll(true);" in the console, it returns true, and
then shows an error icon with the text "Invalid argument". The
pointer is to "compressed_rpc.js, line 1 character 45742". I get the
same behavior if I supply "false" or supply no parameter at all.

IE 8.0.6001.18702 on Windows XP SP2.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,600
Members
45,179
Latest member
pkhumanis73
Top