|
471 | 471 | * Init zoom and panning for the map |
472 | 472 | * @param mapWidth |
473 | 473 | * @param mapHeight |
474 | | - * @param zoom_options |
| 474 | + * @param zoomOptions |
475 | 475 | */ |
476 | 476 | initZoom: function(mapWidth, mapHeight, zoomOptions) { |
477 | 477 | var self = this; |
|
1214 | 1214 | drawLegend: function (legendOptions, legendType, elems, scale, legendIndex) { |
1215 | 1215 | var self = this; |
1216 | 1216 | var $legend = {} |
1217 | | - , legend_paper = {} |
| 1217 | + , legendPaper = {} |
1218 | 1218 | , width = 0 |
1219 | 1219 | , height = 0 |
1220 | 1220 | , title = null |
|
1229 | 1229 | , length = 0; |
1230 | 1230 |
|
1231 | 1231 | $legend = $("." + legendOptions.cssClass, self.$container).empty(); |
1232 | | - legend_paper = new Raphael($legend.get(0)); |
| 1232 | + legendPaper = new Raphael($legend.get(0)); |
1233 | 1233 | height = width = 0; |
1234 | 1234 |
|
1235 | 1235 | // Set the title of the legend |
1236 | 1236 | if(legendOptions.title && legendOptions.title !== "") { |
1237 | | - title = legend_paper.text(legendOptions.marginLeftTitle, 0, legendOptions.title).attr(legendOptions.titleAttrs); |
| 1237 | + title = legendPaper.text(legendOptions.marginLeftTitle, 0, legendOptions.title).attr(legendOptions.titleAttrs); |
1238 | 1238 | title.attr({y : 0.5 * title.getBBox().height}); |
1239 | 1239 |
|
1240 | 1240 | width = legendOptions.marginLeftTitle + title.getBBox().width; |
|
1243 | 1243 |
|
1244 | 1244 | // Calculate attrs (and width, height and r (radius)) for legend elements, and yCenter for horizontal legends |
1245 | 1245 | for(i = 0, length = legendOptions.slices.length; i < length; ++i) { |
1246 | | - var current_yCenter = 0; |
| 1246 | + var yCenterCurrent = 0; |
1247 | 1247 |
|
1248 | 1248 | // Check if size is defined. If not, take defaultPlot size |
1249 | 1249 | if (legendOptions.slices[i].size === undefined) |
|
1280 | 1280 | } |
1281 | 1281 |
|
1282 | 1282 | // Compute yCenter for this legend slice |
1283 | | - current_yCenter = legendOptions.marginBottomTitle; |
| 1283 | + yCenterCurrent = legendOptions.marginBottomTitle; |
1284 | 1284 | // Add title height if it exists |
1285 | 1285 | if (title) { |
1286 | | - current_yCenter += title.getBBox().height; |
| 1286 | + yCenterCurrent += title.getBBox().height; |
1287 | 1287 | } |
1288 | 1288 | if(legendType == "plot" && (legendOptions.slices[i].type === undefined || legendOptions.slices[i].type == "circle")) { |
1289 | | - current_yCenter += scale * sliceAttrs[i].r; |
| 1289 | + yCenterCurrent += scale * sliceAttrs[i].r; |
1290 | 1290 | } else { |
1291 | | - current_yCenter += scale * sliceAttrs[i].height/2; |
| 1291 | + yCenterCurrent += scale * sliceAttrs[i].height/2; |
1292 | 1292 | } |
1293 | 1293 | // Update yCenter if current larger |
1294 | | - yCenter = Math.max(yCenter, current_yCenter); |
| 1294 | + yCenter = Math.max(yCenter, yCenterCurrent); |
1295 | 1295 | } |
1296 | 1296 |
|
1297 | 1297 | if (legendOptions.mode == "horizontal") { |
|
1310 | 1310 | y = height; |
1311 | 1311 | } |
1312 | 1312 |
|
1313 | | - elem = legend_paper.rect(x, y, scale * (sliceAttrs[i].width), scale * (sliceAttrs[i].height)); |
| 1313 | + elem = legendPaper.rect(x, y, scale * (sliceAttrs[i].width), scale * (sliceAttrs[i].height)); |
1314 | 1314 | } else if(legendOptions.slices[i].type == "square") { |
1315 | 1315 | if (legendOptions.mode == "horizontal") { |
1316 | 1316 | x = width + legendOptions.marginLeft; |
|
1320 | 1320 | y = height; |
1321 | 1321 | } |
1322 | 1322 |
|
1323 | | - elem = legend_paper.rect(x, y, scale * (sliceAttrs[i].width), scale * (sliceAttrs[i].height)); |
| 1323 | + elem = legendPaper.rect(x, y, scale * (sliceAttrs[i].width), scale * (sliceAttrs[i].height)); |
1324 | 1324 |
|
1325 | 1325 | } else if(legendOptions.slices[i].type == "image" || legendOptions.slices[i].type == "svg") { |
1326 | 1326 | if (legendOptions.mode == "horizontal") { |
|
1332 | 1332 | } |
1333 | 1333 |
|
1334 | 1334 | if (legendOptions.slices[i].type == "image") { |
1335 | | - elem = legend_paper.image( |
| 1335 | + elem = legendPaper.image( |
1336 | 1336 | legendOptions.slices[i].url, x, y, scale * sliceAttrs[i].width, scale * sliceAttrs[i].height); |
1337 | 1337 | } else { |
1338 | | - elem = legend_paper.path(legendOptions.slices[i].path); |
| 1338 | + elem = legendPaper.path(legendOptions.slices[i].path); |
1339 | 1339 | elem.transform("m"+((scale*legendOptions.slices[i].width) / elem.getBBox().width)+",0,0,"+((scale*legendOptions.slices[i].height) / elem.getBBox().height)+","+x+","+y); |
1340 | 1340 | } |
1341 | 1341 | } else { |
|
1346 | 1346 | x = legendOptions.marginLeft + scale * (sliceAttrs[i].r); |
1347 | 1347 | y = height + scale * (sliceAttrs[i].r); |
1348 | 1348 | } |
1349 | | - elem = legend_paper.circle(x, y, scale * (sliceAttrs[i].r)); |
| 1349 | + elem = legendPaper.circle(x, y, scale * (sliceAttrs[i].r)); |
1350 | 1350 | } |
1351 | 1351 |
|
1352 | 1352 | // Set attrs to the element drawn above |
|
1365 | 1365 | y = height + (elemBBox.height / 2); |
1366 | 1366 | } |
1367 | 1367 |
|
1368 | | - label = legend_paper.text(x, y, legendOptions.slices[i].label).attr(legendOptions.labelAttrs); |
| 1368 | + label = legendPaper.text(x, y, legendOptions.slices[i].label).attr(legendOptions.labelAttrs); |
1369 | 1369 |
|
1370 | 1370 | // Update the width and height for the paper |
1371 | 1371 | if (legendOptions.mode == "horizontal") { |
1372 | | - var current_height = legendOptions.marginBottom + elemBBox.height; |
| 1372 | + var currentHeight = legendOptions.marginBottom + elemBBox.height; |
1373 | 1373 | width += legendOptions.marginLeft + elemBBox.width + legendOptions.marginLeftLabel + label.getBBox().width; |
1374 | 1374 | if(legendOptions.slices[i].type != "image" && legendType != "area") { |
1375 | | - current_height += legendOptions.marginBottomTitle; |
| 1375 | + currentHeight += legendOptions.marginBottomTitle; |
1376 | 1376 | } |
1377 | 1377 | // Add title height if it exists |
1378 | 1378 | if (title) { |
1379 | | - current_height += title.getBBox().height; |
| 1379 | + currentHeight += title.getBBox().height; |
1380 | 1380 | } |
1381 | | - height = Math.max(height, current_height); |
| 1381 | + height = Math.max(height, currentHeight); |
1382 | 1382 | } else { |
1383 | 1383 | width = Math.max(width, legendOptions.marginLeft + elemBBox.width + legendOptions.marginLeftLabel + label.getBBox().width); |
1384 | 1384 | height += legendOptions.marginBottom + elemBBox.height; |
|
1406 | 1406 | if (Raphael.type != "SVG" && legendOptions.VMLWidth) |
1407 | 1407 | width = legendOptions.VMLWidth; |
1408 | 1408 |
|
1409 | | - legend_paper.setSize(width, height); |
1410 | | - return legend_paper; |
| 1409 | + legendPaper.setSize(width, height); |
| 1410 | + return legendPaper; |
1411 | 1411 | }, |
1412 | 1412 |
|
1413 | 1413 | /* |
|
1724 | 1724 | * @param w map defined width |
1725 | 1725 | * @param h map defined height |
1726 | 1726 | * @param duration defined length of time for animation |
1727 | | - * @param easying_function defined Raphael supported easing_formula to use |
| 1727 | + * @param easingFunction defined Raphael supported easing_formula to use |
1728 | 1728 | * @param callback method when animated action is complete |
1729 | 1729 | */ |
1730 | 1730 | animateViewBox: function (x, y, w, h, duration, easingFunction ) { |
|
1739 | 1739 | , dh = h - ch |
1740 | 1740 | , interval = 25 |
1741 | 1741 | , steps = duration / interval |
1742 | | - , current_step = 0 |
| 1742 | + , currentStep = 0 |
1743 | 1743 | , easingFormula; |
1744 | 1744 |
|
1745 | 1745 | easingFunction = easingFunction || "linear"; |
|
1748 | 1748 | clearInterval(self.animationIntervalID); |
1749 | 1749 |
|
1750 | 1750 | self.animationIntervalID = setInterval(function() { |
1751 | | - var ratio = current_step / steps; |
| 1751 | + var ratio = currentStep / steps; |
1752 | 1752 | self.paper.setViewBox(cx + dx * easingFormula(ratio), |
1753 | 1753 | cy + dy * easingFormula(ratio), |
1754 | 1754 | cw + dw * easingFormula(ratio), |
1755 | 1755 | ch + dh * easingFormula(ratio), false); |
1756 | | - if (current_step++ >= steps) { |
| 1756 | + if (currentStep++ >= steps) { |
1757 | 1757 | clearInterval(self.animationIntervalID); |
1758 | 1758 | clearTimeout(self.zoomTO); |
1759 | 1759 | self.zoomTO = setTimeout(function(){self.$map.trigger("afterZoom", {x1 : x, y1 : y, x2 : (x+w), y2 : (y+h)});}, 150); |
|
0 commit comments