OpenLayers OpenLayers

Ticket #1632 (closed task: fixed)

Opened 2 years ago

Last modified 5 months ago

Theme LayerSwitcher with CSS

Reported by: crschmidt Assigned to:
Priority: minor Milestone: 2.9 Release
Component: Control.LayerSwitcher Version:
Keywords: Cc:
State: Complete

Description

The LayerSwitcher currently uses a lot of hardcoded styles in the code. This should change so that it uses CSS instead, in the theme/ directory. This would allow for changing styling with CSS instead of setting specific things like activeColor, fontColor, etc.

Attachments

layerswitchercss.patch (8.1 kB) - added by tmcw on 09/08/09 12:38:17.
Moves LayerSwitcher styles into style.css
patch-1632-A0.diff (9.0 kB) - added by elemoine on 10/23/09 19:43:18.
openlayers-1632.diff (10.4 kB) - added by ahocevar on 10/24/09 20:57:02.
minimize/maximizeControl now also with css
patch-1632-A1.diff (10.7 kB) - added by elemoine on 10/29/09 04:31:52.
openlayers-1632.patch (10.3 kB) - added by ahocevar on 10/29/09 09:51:18.

Change History

03/01/09 20:46:00 changed by crschmidt

  • milestone changed from 2.8 Release to 2.9 Release.

Not touched in 2.7, bumping.

09/08/09 12:38:17 changed by tmcw

  • attachment layerswitchercss.patch added.

Moves LayerSwitcher styles into style.css

09/08/09 12:39:29 changed by tmcw

  • state set to Review.

Added a patch to do this. I just pulled this out of a current project (which needed the functionality this provides), so it may have some rough edges, but this will take you 95% of the way there.

10/23/09 07:29:20 changed by rdewit

  • keywords set to foss4g09.

10/23/09 11:34:01 changed by tmcw

Note that the patch I posted has compatibility issues with IE. I should have used .className = instead of setAttribute('class', 'class'). It also preserves javascript-created styles for the minimized and maximized states intead of attaching css classes. I've made those changes, but the layerswitcher I'm using has some other stuff (notably, a legend) that breaks continuity with the old one.

Anyway... what's the status of this ticket? Is this stuff hacked together at foss4g?

10/23/09 19:43:18 changed by elemoine

  • attachment patch-1632-A0.diff added.

10/23/09 19:46:01 changed by elemoine

  • version deleted.

patch-1632-A0.diff makes use of OpenLayers.Element.addClass, keeps the rounded corners using Rico (with an option to disable it), and provides tests.

Tests pass in FF3, IE6, IE8 and Safari. The layer tree in the wms.html looks the same as before in these browsers.

I think this is ready for review.

(follow-up: ↓ 7 ) 10/23/09 20:44:09 changed by tmcw

Doesn't the most recent patch still have javascript setting the width of the maximized layerswitcher?

(in reply to: ↑ 6 ) 10/23/09 21:00:56 changed by elemoine

Replying to tmcw:

Doesn't the most recent patch still have javascript setting the width of the maximized layerswitcher?

are you referring to the maximizeControl and minimizeControl methods? Those two weren't modified in the former patch, were they?

10/23/09 21:30:55 changed by elemoine

  • owner changed from euzuro to ahocevar.

10/24/09 20:57:02 changed by ahocevar

  • attachment openlayers-1632.diff added.

minimize/maximizeControl now also with css

10/24/09 20:59:05 changed by ahocevar

  • owner deleted.
  • state changed from Review to Commit.

Hey Eric, your patch looks great! As suggested by tmcw, I also moved the minimize/MaximizeControl styles to css and modified the tests accordingly. Tests continue to pass. Please commit if you agree with my changes.

10/27/09 07:31:02 changed by elemoine

  • state changed from Commit to Needs More Work.

There are issues with the patch. The most prominent issue is a thick blue horizontal line across the map in IE. I will arrange time to work on it.

(follow-up: ↓ 12 ) 10/27/09 07:48:33 changed by aabt

Hi,

I was wondering about having Rico here just for rounded corners… Is that IE cosmetic appearance so important (There's no functional problem)? The job could easily be done in other browser with a few css lines.

What do you guys think about it?

(in reply to: ↑ 11 ; follow-up: ↓ 13 ) 10/27/09 08:16:54 changed by elemoine

Replying to aabt:

Hi, I was wondering about having Rico here just for rounded corners… Is that IE cosmetic appearance so important (There's no functional problem)? The job could easily be done in other browser with a few css lines. What do you guys think about it?

Unfortunately I think people would complain with loosing the rounded corners in IE. Andreas, any opinion on this?

(in reply to: ↑ 12 ) 10/27/09 08:52:41 changed by ahocevar

Replying to elemoine:

Unfortunately I think people would complain with loosing the rounded corners in IE. Andreas, any opinion on this?

I totally agree. We cannot just remove this, unfortunately.

10/29/09 04:31:52 changed by elemoine

  • attachment patch-1632-A1.diff added.

10/29/09 04:43:20 changed by elemoine

  • state changed from Needs More Work to Review.

patch-1632-A1.diff

  • sets the width of the control in CSS through the .olControlLayerSwitcher accessor - I don't think we need new classes ("minimized" and "maximized") for that
  • addresses the "thick horizontal line in IE" issue
  • slighly modifies the layerswitcher.html example so it looks as before

with this patch, a class must be set in the div when the layer switcher is displayed outside the map, this can be seen as an API change, but this is the price to pay if we want flexibility and styling through CSS.

tests pass in FF3, IE6, IE8, Safari and Chromium. Examples spherical-mercator.html and layerswitcher.html checked in these browsers, they look as before (they even look better in IE, where the control div spanned the entire browser window horizontally).

I think this is good to go. Please review.

10/29/09 09:51:18 changed by ahocevar

  • attachment openlayers-1632.patch added.

10/29/09 09:53:20 changed by ahocevar

  • state changed from Review to Commit.

Eric: Great work! I uploaded an alternative patch that adds the olControlLayerSwitcher class if it is not already there. This would prevent us from having to change the API. Please commit the new one if you agree, otherwise I'm also fine with your patch.

10/29/09 10:45:28 changed by elemoine

  • keywords deleted.
  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [9767]) theme LayerSwitcher with CSS, r=ahocevar, p=tmcw,me (closes #1632)