[OpenLayers-Trac] [OpenLayers] #3630: Panel: play nicely with multiple classnames for widgets (e.g. "olControlNavigationItemActive myClass")

OpenLayers trac-20090302 at openlayers.org
Mon Mar 5 03:11:33 EST 2012


#3630: Panel: play nicely with multiple classnames for widgets (e.g.
"olControlNavigationItemActive myClass")
--------------------------------+-------------------------------------------
 Reporter:  ejn                 |       Owner:              
     Type:  feature             |      Status:  new         
 Priority:  minor               |   Milestone:  2.12 Release
Component:  Control.Panel       |     Version:  2.11        
 Keywords:  panel widget state  |       State:              
--------------------------------+-------------------------------------------
 The current redraw method for Panel (more precisely, the methods iconOn
 and iconOff) change the class name on the icon using a regular expression
 which matches ItemInactive$ or ItemActive$ - i.e. at the end of the whole
 className string.

 In cases where multiple class names are applied to the widgets this regex
 doesn't work - we need to be matching at end of word, not end of string -
 and so the widget state doesn't get updated.

 Use case is e.g. to simplify CSS I wish to add a class "navigationWidget"
 to all controls on my panel, leaving them with a className string such as
 "olControlZoomBoxItemInactive navigationControl".

 Suggested regex (unfortunately no lookbehinds in JavaScript so slightly
 clunky) which should be pretty foolproof:
 {{{
 replace(/\b(olControl[^ ]*Item)Inactive\b/, "$1Active")
 replace(/\b(olControl[^ ]*Item)Active\b/, "$1Inactive")
 }}}

 The attached patch implements this change.

-- 
Ticket URL: <http://trac.openlayers.org/ticket/3630>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list