Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shamasis Bhattacharya committed Apr 3, 2014
2 parents c13b7e7 + adb8a43 commit 90f87be
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 78 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_modules
npm-edubg.log
dr.js
*.sublime-*
!redraphael.sublime-project
!redraphael.sublime-project

tests/spec-*.html
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ Raphael.define(
[See it in action](http://jsfiddle.net/sushantbs/khBQj/6/)


## Unreleased features and improvements

- array as multi-line text

## Guidelines for contribution

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "redraphael",
"filename": "raphael",
"version": "1.0.11",
"version": "1.1.0",
"rversion": "2.1.0",
"description": "RedRaphael",
"main": "index.js",
Expand Down
28 changes: 19 additions & 9 deletions package/raphael-fusioncharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ window.FusionCharts && window.FusionCharts.register('module', ['private', 'vendo


/**!
* RedRaphael 1.0.11 - JavaScript Vector Library
* RedRaphael 1.1.0 - JavaScript Vector Library
* Copyright (c) 2012-2013 FusionCharts Technologies <http://www.fusioncharts.com>
*
* Raphael 2.1.0
Expand Down Expand Up @@ -6820,15 +6820,17 @@ window.FusionCharts && window.FusionCharts.register('module', ['private', 'vendo

var updateGradientReference = function (element, newGradient) {
var gradient = element.gradient;

if (gradient) {
if (gradient === newGradient) {
return; // no change
}
// else gradient is specified and it is not same as newGradient, implying a dereference
gradient.refCount--;
if (!gradient.refCount) {
gradient.parentNode.removeChild(gradient);
delete element.gradient;
}
delete element.gradient;
}

if (newGradient) { // add new gradient
Expand Down Expand Up @@ -7573,7 +7575,7 @@ window.FusionCharts && window.FusionCharts.register('module', ['private', 'vendo
}
}

tuneText(o, params);
(o.type === 'text') && tuneText(o, params);
s.visibility = vis;
},
leading = 1.2,
Expand All @@ -7584,16 +7586,21 @@ window.FusionCharts && window.FusionCharts.register('module', ['private', 'vendo
return;
}
var a = el.attrs,
node = el.node,
computedStyle = node.firstChild && R._g.doc.defaultView.getComputedStyle(node.firstChild, E),
fontSize = computedStyle ? toFloat(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size")) : 10,
lineHeight = toFloat(params['line-height'] || a['line-height']) || fontSize * leading,
valign = a[has]("vertical-align") ? a["vertical-align"] : "middle";
node = el.node,
computedStyle = node.firstChild && R._g.doc.defaultView.getComputedStyle(node.firstChild, E),
fontSize = computedStyle ?
toFloat(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size")) : 10,
lineHeight = toFloat(params['line-height'] || a['line-height']) || fontSize * leading,
valign = a[has]("vertical-align") ? a["vertical-align"] : "middle";

if (isNaN(lineHeight)) {
lineHeight = fontSize * leading;
}

if (R.is(params.text, 'array')) {
params.text = params.text.join('<br>');
}

valign = valign === 'top' ? -0.5 : (valign === 'bottom' ? 0.5 : 0);

if (params[has]("text") && (params.text !== a.text || el._textdirty)) {
Expand Down Expand Up @@ -8658,7 +8665,7 @@ window.FusionCharts && window.FusionCharts.register('module', ['private', 'vendo
}
node.appendChild(fill);
var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),
newstroke = false;
newstroke = false;
!stroke && (newstroke = stroke = createNode("stroke"));
if ((params.stroke && params.stroke != "none") ||
params["stroke-width"] ||
Expand Down Expand Up @@ -9138,6 +9145,9 @@ window.FusionCharts && window.FusionCharts.register('module', ['private', 'vendo
}
// this.paper.canvas.style.display = "none";
if ('text' in params && this.type == "text") {
if (R.is(params.text, 'array')) {
params.text = params.text.join('<br>');
}
this.textpath.string = params.text.replace(/<br\s*?\/?>/ig, '\n');
}
setFillAndStroke(this, params);
Expand Down
6 changes: 3 additions & 3 deletions package/raphael-min.js

Large diffs are not rendered by default.

28 changes: 19 additions & 9 deletions package/raphael.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* RedRaphael 1.0.11 - JavaScript Vector Library
* RedRaphael 1.1.0 - JavaScript Vector Library
* Copyright (c) 2012-2013 FusionCharts Technologies <http://www.fusioncharts.com>
*
* Raphael 2.1.0
Expand Down Expand Up @@ -6803,15 +6803,17 @@

var updateGradientReference = function (element, newGradient) {
var gradient = element.gradient;

if (gradient) {
if (gradient === newGradient) {
return; // no change
}
// else gradient is specified and it is not same as newGradient, implying a dereference
gradient.refCount--;
if (!gradient.refCount) {
gradient.parentNode.removeChild(gradient);
delete element.gradient;
}
delete element.gradient;
}

if (newGradient) { // add new gradient
Expand Down Expand Up @@ -7556,7 +7558,7 @@
}
}

tuneText(o, params);
(o.type === 'text') && tuneText(o, params);
s.visibility = vis;
},
leading = 1.2,
Expand All @@ -7567,16 +7569,21 @@
return;
}
var a = el.attrs,
node = el.node,
computedStyle = node.firstChild && R._g.doc.defaultView.getComputedStyle(node.firstChild, E),
fontSize = computedStyle ? toFloat(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size")) : 10,
lineHeight = toFloat(params['line-height'] || a['line-height']) || fontSize * leading,
valign = a[has]("vertical-align") ? a["vertical-align"] : "middle";
node = el.node,
computedStyle = node.firstChild && R._g.doc.defaultView.getComputedStyle(node.firstChild, E),
fontSize = computedStyle ?
toFloat(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size")) : 10,
lineHeight = toFloat(params['line-height'] || a['line-height']) || fontSize * leading,
valign = a[has]("vertical-align") ? a["vertical-align"] : "middle";

if (isNaN(lineHeight)) {
lineHeight = fontSize * leading;
}

if (R.is(params.text, 'array')) {
params.text = params.text.join('<br>');
}

valign = valign === 'top' ? -0.5 : (valign === 'bottom' ? 0.5 : 0);

if (params[has]("text") && (params.text !== a.text || el._textdirty)) {
Expand Down Expand Up @@ -8641,7 +8648,7 @@
}
node.appendChild(fill);
var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),
newstroke = false;
newstroke = false;
!stroke && (newstroke = stroke = createNode("stroke"));
if ((params.stroke && params.stroke != "none") ||
params["stroke-width"] ||
Expand Down Expand Up @@ -9121,6 +9128,9 @@
}
// this.paper.canvas.style.display = "none";
if ('text' in params && this.type == "text") {
if (R.is(params.text, 'array')) {
params.text = params.text.join('<br>');
}
this.textpath.string = params.text.replace(/<br\s*?\/?>/ig, '\n');
}
setFillAndStroke(this, params);
Expand Down
21 changes: 14 additions & 7 deletions source/raphael.svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ window.Raphael && window.Raphael.svg && function(R) {

var updateGradientReference = function (element, newGradient) {
var gradient = element.gradient;

if (gradient) {
if (gradient === newGradient) {
return; // no change
}
// else gradient is specified and it is not same as newGradient, implying a dereference
gradient.refCount--;
if (!gradient.refCount) {
gradient.parentNode.removeChild(gradient);
delete element.gradient;
}
delete element.gradient;
}

if (newGradient) { // add new gradient
Expand Down Expand Up @@ -814,7 +816,7 @@ window.Raphael && window.Raphael.svg && function(R) {
}
}

tuneText(o, params);
(o.type === 'text') && tuneText(o, params);
s.visibility = vis;
},
leading = 1.2,
Expand All @@ -825,16 +827,21 @@ window.Raphael && window.Raphael.svg && function(R) {
return;
}
var a = el.attrs,
node = el.node,
computedStyle = node.firstChild && R._g.doc.defaultView.getComputedStyle(node.firstChild, E),
fontSize = computedStyle ? toFloat(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size")) : 10,
lineHeight = toFloat(params['line-height'] || a['line-height']) || fontSize * leading,
valign = a[has]("vertical-align") ? a["vertical-align"] : "middle";
node = el.node,
computedStyle = node.firstChild && R._g.doc.defaultView.getComputedStyle(node.firstChild, E),
fontSize = computedStyle ?
toFloat(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size")) : 10,
lineHeight = toFloat(params['line-height'] || a['line-height']) || fontSize * leading,
valign = a[has]("vertical-align") ? a["vertical-align"] : "middle";

if (isNaN(lineHeight)) {
lineHeight = fontSize * leading;
}

if (R.is(params.text, 'array')) {
params.text = params.text.join('<br>');
}

valign = valign === 'top' ? -0.5 : (valign === 'bottom' ? 0.5 : 0);

if (params[has]("text") && (params.text !== a.text || el._textdirty)) {
Expand Down
7 changes: 5 additions & 2 deletions source/raphael.vml.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ window.Raphael && window.Raphael.vml && function(R) {
}
node.appendChild(fill);
var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]),
newstroke = false;
newstroke = false;
!stroke && (newstroke = stroke = createNode("stroke"));
if ((params.stroke && params.stroke != "none") ||
params["stroke-width"] ||
Expand Down Expand Up @@ -838,6 +838,9 @@ window.Raphael && window.Raphael.vml && function(R) {
}
// this.paper.canvas.style.display = "none";
if ('text' in params && this.type == "text") {
if (R.is(params.text, 'array')) {
params.text = params.text.join('<br>');
}
this.textpath.string = params.text.replace(/<br\s*?\/?>/ig, '\n');
}
setFillAndStroke(this, params);
Expand Down Expand Up @@ -1214,4 +1217,4 @@ window.Raphael && window.Raphael.vml && function(R) {
};
})(method);
}
}(window.Raphael);
}(window.Raphael);
67 changes: 21 additions & 46 deletions tests/index.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<!-- <script type="text/javascript" src="../helper/logger.js"></script> -->
<script type="text/javascript" src="../source/eve/eve.js"></script>
<script type="text/javascript" src="../source/raphael.core.js"></script>
<script type="text/javascript" src="../source/raphael.svg.js"></script>
<script type="text/javascript" src="../source/raphael.vml.js"></script>
<script type="text/javascript">
window.onload = function () {
var clicker = function (e) {
var tgt = p.getById(e.target.raphaelid);
console.log('clicked', [tgt.type, tgt.id], arguments);
},
p = window.paper = Raphael(document.getElementById('containerDiv'), 300, 300),
r,
r2,
g;
<head>
<!-- <script type="text/javascript" src="../helper/logger.js"></script> -->
<script type="text/javascript" src="../source/eve/eve.js"></script>
<script type="text/javascript" src="../source/raphael.core.js"></script>
<script type="text/javascript" src="../source/raphael.svg.js"></script>
<script type="text/javascript" src="../source/raphael.vml.js"></script>
<script type="text/javascript">
Raphael(10, 10, 600, 400, function () {
var paper = window.pap = this;

g = p.group().click(clicker);
paper.text({
text: ['Use index.html as a template to work on temporary workspace!',
'',
'Ensure that your test files are named spec-<somename>.html'],
'text-anchor': 'left',
'vertical-align': 'top'
});
});
</script>
</head>

r = p.rect({
x: 10,
y: 10,
width: 100,
height: 100,
fill: '#ff0000'
}, g);

r2 = p.rect({
x: 110,
y: 110,
width: 100,
height: 100,
fill: '#ff0000'
}, g);

p.text({
text: 'hello world',
title: 'blah'
});

p.clear();

};
</script>
</head>
<body>
<div id='containerDiv' style='border:1px solid red;position:absolute;width:600px;height:600px;top:100px;left:100px;'></div>
</body>
<body>
</body>
</html>

0 comments on commit 90f87be

Please sign in to comment.