kartograph / kartograph.js

UNMAINTAINED Open source JavaScript renderer for Kartograph SVG maps
http://kartograph.org
GNU Lesser General Public License v3.0
1.51k stars 228 forks source link

Add CSS parser for IE #7

Closed gka closed 12 years ago

gka commented 12 years ago

For getting IE support (#6) it is required to parse CSS in JavaScript. The following styles will be parsed and applied via Raphael's attr() method:

(more to come eventually)

To achieve styling, the Kartograph.Map constructor accepts an additional parameter which is the stylesheet for the map.

map = new kartograph.Map('#map');
map.loadStyles('mapstyles.css', callback);

For non-IE browsers, the styles are simply included via <link .. /> tag. On IE, the styles will be parsed by Kartograph and then stored for later use.

Internally, Kartograph.Map gets a new method that applies all styles:

map.applyStyles(raphaelNode)

The CSS parser comes from http://bililite.com/blog/2009/01/16/jquery-css-parser/

gka commented 12 years ago

Kartograph will look for references of "path", "circle", "rect", "ellipse" and "text" references and classes.

It will process the style in order of appearance in the CSS, so it may not reflect the way, browsers parse CSS.