Skip to content

Commit 045e739

Browse files
committed
Added 'open in new window or tab' option
1 parent 635231d commit 045e739

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

TODO.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
TODO:
2+
FIX: Documentation (http://www.jeroenvanwarmerdam.nl/content/resources/javascript/jscumulus/jscumulus.aspx);
3+
FIX: Convert to canvas (http://www.goat1000.com/tagcanvas.php);
24
ADD: Mouse panning, zooming;
3-
ADD: Documentation;
45
ADD: Z-sorting;
56
ADD: Slow down more on tag mouse focus;
67
ADD: Calculating the color instead using the Opacity property;
78
ADD: Touch events;
89
ADD: Always on;
9-
ADD: Specify beginning origin;
10+
ADD: Specify beginning origin;
11+
ADD: Tags from xml;

index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
<head>
44
<title>JS-Cumulus => WP-Cumulus in Javascript</title>
55

6-
<script type="text/javascript" src="js-cumulus.min.js"></script>
6+
<script type="text/javascript" src="js-cumulus.js"></script>
77

88
<script type="text/javascript">
99
//JSCumulus.noConflict();
1010

11-
/* TagCloud 1 */
1211
/* DEBUG */ window.console && console.time && console.time("TagCloud1");
12+
13+
/* TagCloud 1 */
1314
var tags = [
1415
new Tag("JS-Cumulus", 100),
15-
new Tag("WP-Cumulus", 80, "http://www.roytanck.com/2008/05/19/how-to-repurpose-my-tag-cloud-flash-movie/"),
16+
new Tag("WP-Cumulus", 80, "http://www.roytanck.com/2008/05/19/how-to-repurpose-my-tag-cloud-flash-movie/", true),
1617
new Tag("Jeroen van Warmerdam", 60, "http://www.jeroenvanwarmerdam.nl"),
1718
new Tag("Stratus", "http://student.agh.edu.pl/~fatyga/repos/stratus/example.php"),
1819
new Tag("JavaScript", {
@@ -32,6 +33,7 @@
3233
new Tag("<img src='icon-tagcloud.gif' />")
3334
];
3435
var tagCloud1 = new TagCloud(tags, 400, 400);
36+
3537
/* DEBUG */ window.console && console.time && console.timeEnd("TagCloud1");
3638
</script>
3739

@@ -134,8 +136,9 @@ <h4>Tag Cloud <small id="TagCloud2X_fps" /></h4>
134136
</div>
135137

136138
<script type="text/javascript">
137-
/* TagCloud 2 */
138139
/* DEBUG */ window.console && console.time && console.time("TagCloud2");
140+
141+
/* TagCloud 2 */
139142
var tags2 = [
140143
new Tag("JS-Cumulus", 100),
141144
new Tag("WP-Cumulus", 80, "http://www.roytanck.com/2008/05/19/how-to-repurpose-my-tag-cloud-flash-movie/"),
@@ -163,6 +166,7 @@ <h4>Tag Cloud <small id="TagCloud2X_fps" /></h4>
163166
{ overwrite: true, id: "TagCloud2X" }
164167
);
165168
tagCloud2.Animate();
169+
166170
/* DEBUG */ window.console && console.time && console.timeEnd("TagCloud2");
167171

168172

js-cumulus.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
6868
Consistent : true, // Boolean => Devide tags evenly;
6969
Rank : 30, // Integer 0-100 => Tag importance in procents;
7070
Url : "#", // String URL => Tag url;
71+
OpenInNewWindow: false, // Boolean => Open tag url in new window or tab;
7172
FontMin : 10, // Float => Font size for smallest tag in pixels;
7273
FontMax : 24, // Float => Font size for biggest tag in pixels;
7374
Depth : 150, // Integer => Perspective depth;
@@ -273,18 +274,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
273274
};
274275

275276
/** Tag Class **/
276-
var Tag = function(title, rank, url, styles){
277+
var Tag = function(title, rank, url, openInNewWindow, styles){
277278
this.id = _TagID++;
278279
this.title = title;
279280
this.rank = ((!isNaN(rank) && rank >= 0 && rank <= 100) ? rank : Defaults.Rank) / 100;
280281
this.url = url || (isNaN(rank) ? rank : false) || Defaults.Url;
281282
this.position = new Vector();
282283

283-
styles = styles || isObject(url) && url || isObject(rank) && rank || { };
284+
openInNewWindow = arguments[4] && openInNewWindow || (openInNewWindow===true ? true : false) || (arguments[2]===true ? true : false) || Defaults.OpenInNewWindow;
285+
styles = styles || isObject(arguments[3]) && arguments[3] || isObject(arguments[2]) && arguments[2] || isObject(arguments[1]) && arguments[1] || {};
284286

285287
var aa = _doc.createElement("a");
286288
aa.setAttribute("id", "jsCumulus" + this.id);
287289
aa.setAttribute("href", this.url);
290+
if(openInNewWindow){
291+
aa.setAttribute("target", "_blank");
292+
}
288293
aa.innerHTML = this.title;
289294
for(var style in styles){
290295
aa.style[style] = styles[style];

0 commit comments

Comments
 (0)