Skip to content

Commit

Permalink
travis-ify JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Budorick committed Jul 2, 2014
1 parent a8652d2 commit 8088f97
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions migrations/v3.1.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function convertLayer(layer) {

var convertHalo = function(haloWidth, textSize) {
return Number(((6 - haloWidth * 8) * textSize / 24).toFixed(2));
}
};

// convert text-halo-width to pixels
for (var classname in layer) {
if (classname.indexOf('style') == 0) {
if (classname.indexOf('style') === 0) {
var style = layer[classname];
if (style['text-halo-width']) {
// handle 3 cases: text-size as constant, text-size as #, no text-size but max-text-size
Expand All @@ -63,17 +63,21 @@ function convertLayer(layer) {
style['text-size'] :
layer.render['text-max-size']);

// handle text-size numbers and functions
if (typeof(textSize) == 'number') {
style['text-halo-width'] = convertHalo(style['text-halo-width'], textSize)
} else if (textSize && textSize['stops']) {
var stops = []
textSize['stops'].forEach(function(stop) {
stops.push([stop[0], convertHalo(style['text-halo-width'], stop[1])]);
})
style['text-halo-width'] = convertHalo(style['text-halo-width'], textSize);
} else if (textSize && textSize.stops) {
var stops = [];
for (var stop in textSize.stops) {
stops.push(
[textSize.stops[stop][0],
convertHalo(style['text-halo-width'], textSize.stops[stop][1])]
);
}
style['text-halo-width'] = {
"fn": "stops",
"stops": stops
}
};
}
}
}
Expand Down

0 comments on commit 8088f97

Please sign in to comment.