Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Brought back the customClass option

  • Loading branch information...
commit 7f9fad3db7d690c39a61a931b569c53e12df0d9c 1 parent 6ec3449
@fzero authored
View
3  README.md
@@ -96,6 +96,7 @@ All cloud-wide configurations are optional, and the full list of available optio
* **afterCloudRender** (function): A callback function to be called after the whole cloud is fully rendered.
* **delayedMode** (boolean): If true, words are rendered one after another with a tiny delay between each one. This prevents freezing of the browser when there are many words to be rendered. If false, the cloud will be rendered in one single shot. By default, delayedMode is true when there are more than 50 words.
* **shape** (string): the shape of the cloud. By default it is elliptic, but it can be set to `"rectangular"` to draw a rectangular-shaped cloud.
+* **customClass** (string): custom CSS class to be added to all words.
## Custom CSS guidelines
@@ -114,7 +115,7 @@ Please note that version 1.0 is a redesign of the API that does not maintain bac
This is a quick list of what changed in the new 1.0 API:
- * in the word object, you can now specify any html attribute for the word <span> using the `html` option (e.g.: `{title: "A Title", "class": "custom-class", data-custom: "custom data attribute"}`). Since this allows for more flexibility, `title`, `customClass` and `dataAttributes` options are superfluous and dropped in v1.0.
+ * in the word object, you can now specify any html attribute for the word <span> using the `html` option (e.g.: `{title: "A Title", "class": "custom-class", data-custom: "custom data attribute"}`). Since this allows for more flexibility, `title` and `dataAttributes` options are superfluous and dropped in v1.0.
* the `url` option was renamed `link` in v1.0, and can now be a URL string or an object. In the latter case, any html attribute for the `<a>` tag can be specified (e.g.: `{href: "http://myurl.com", title: "A Title"}`).
* the cloud options `randomClasses` and `nofollow` are dropped in v1.0. They were indended for purposes which are better achieved using the new `html` and `link` word options.
* `width` and `height` cloud options now set the width and height of the cloud container element, other than determining the aspect ratio of the cloud.
View
2  examples/rectangular.html
@@ -51,7 +51,7 @@
{text: "Sed", weight: 1}
];
$(function() {
- $("#my_favorite_latin_words").jQCloud(word_list, {shape: "rectangular"});
+ $("#my_favorite_latin_words").jQCloud(word_list, {shape: "rectangular", customClass: "tag"});
});
</script>
</head>
View
7 jqcloud/jqcloud-1.0.2.js
@@ -6,7 +6,7 @@
* Copyright 2011, Luca Ongaro
* Licensed under the MIT license.
*
- * Date: Tue Oct 09 22:08:53 +0200 2012
+ * Date: 2012-10-23 16:47:45 -0400
*/
(function( $ ) {
@@ -27,7 +27,8 @@
},
delayedMode: word_array.length > 50,
shape: false, // It defaults to elliptic shape
- encodeURI: true
+ encodeURI: true,
+ customClass: ''
};
options = $.extend(default_options, options || {});
@@ -87,7 +88,7 @@
quarter_turns = 0.0,
weight = 5,
- custom_class = "",
+ custom_class = options.customClass,
inner_html = "",
word_span = "";
View
4 jqcloud/jqcloud-1.0.2.min.js
@@ -6,6 +6,6 @@
* Copyright 2011, Luca Ongaro
* Licensed under the MIT license.
*
- * Date: Tue Oct 09 22:08:53 +0200 2012
+ * Date: 2012-10-23 16:47:45 -0400
*/
-(function(a){"use strict",a.fn.jQCloud=function(b,c){var d=this,e=d.attr("id")||Math.floor(Math.random()*1e6).toString(36),f={width:d.width(),height:d.height(),center:{x:(c&&c.width?c.width:d.width())/2,y:(c&&c.height?c.height:d.height())/2},delayedMode:b.length>50,shape:!1,encodeURI:!0};c=a.extend(f,c||{}),d.addClass("jqcloud").width(c.width).height(c.height),d.css("position")==="static"&&d.css("position","relative");var g=function(){var f=function(a,b){var c=function(a,b){return Math.abs(2*a.offsetLeft+a.offsetWidth-2*b.offsetLeft-b.offsetWidth)<a.offsetWidth+b.offsetWidth&&Math.abs(2*a.offsetTop+a.offsetHeight-2*b.offsetTop-b.offsetHeight)<a.offsetHeight+b.offsetHeight?!0:!1},d=0;for(d=0;d<b.length;d++)if(c(a,b[d]))return!0;return!1};for(var g=0;g<b.length;g++)b[g].weight=parseFloat(b[g].weight,10);b.sort(function(a,b){return a.weight<b.weight?1:a.weight>b.weight?-1:0});var h=c.shape==="rectangular"?18:2,i=[],j=c.width/c.height,k=function(g,k){var l=e+"_word_"+g,m="#"+l,n=6.28*Math.random(),o=0,p=0,q=0,r=5,s="",t="",u="";k.html=a.extend(k.html,{id:l}),k.html&&k.html["class"]&&(s=k.html["class"],delete k.html["class"]),b[0].weight>b[b.length-1].weight&&(r=Math.round((k.weight-b[b.length-1].weight)/(b[0].weight-b[b.length-1].weight)*9)+1),u=a("<span>").attr(k.html).addClass("w"+r+" "+s),k.link?(typeof k.link=="string"&&(k.link={href:k.link}),c.encodeURI&&(k.link=a.extend(k.link,{href:encodeURI(k.link.href).replace(/'/g,"%27")})),t=a("<a>").attr(k.link).text(k.text)):t=k.text,u.append(t);if(!!k.handlers)for(var v in k.handlers)k.handlers.hasOwnProperty(v)&&typeof k.handlers[v]=="function"&&a(u).bind(v,k.handlers[v]);d.append(u);var w=u.width(),x=u.height(),y=c.center.x-w/2,z=c.center.y-x/2,A=u[0].style;A.position="absolute",A.left=y+"px",A.top=z+"px";while(f(document.getElementById(l),i)){if(c.shape==="rectangular"){p++,p*h>(1+Math.floor(q/2))*h*(q%4%2===0?1:j)&&(p=0,q++);switch(q%4){case 1:y+=h*j+Math.random()*2;break;case 2:z-=h+Math.random()*2;break;case 3:y-=h*j+Math.random()*2;break;case 0:z+=h+Math.random()*2}}else o+=h,n+=(g%2===0?1:-1)*h,y=c.center.x-w/2+o*Math.cos(n)*j,z=c.center.y+o*Math.sin(n)-x/2;A.left=y+"px",A.top=z+"px"}i.push(document.getElementById(l)),a.isFunction(k.afterWordRender)&&k.afterWordRender.call(u)},l=function(e){e=e||0;if(!d.is(":visible")){setTimeout(function(){l(e)},10);return}e<b.length?(k(e,b[e]),setTimeout(function(){l(e+1)},10)):a.isFunction(c.afterCloudRender)&&c.afterCloudRender.call(d)};c.delayedMode?l():(a.each(b,k),a.isFunction(c.afterCloudRender)&&c.afterCloudRender.call(d))};return setTimeout(function(){g()},10),d}})(jQuery);
+(function(e){"use strict";e.fn.jQCloud=function(t,n){var r=this,i=r.attr("id")||Math.floor(Math.random()*1e6).toString(36),s={width:r.width(),height:r.height(),center:{x:(n&&n.width?n.width:r.width())/2,y:(n&&n.height?n.height:r.height())/2},delayedMode:t.length>50,shape:!1,encodeURI:!0,customClass:""};n=e.extend(s,n||{}),r.addClass("jqcloud").width(n.width).height(n.height),r.css("position")==="static"&&r.css("position","relative");var o=function(){var s=function(e,t){var n=function(e,t){return Math.abs(2*e.offsetLeft+e.offsetWidth-2*t.offsetLeft-t.offsetWidth)<e.offsetWidth+t.offsetWidth&&Math.abs(2*e.offsetTop+e.offsetHeight-2*t.offsetTop-t.offsetHeight)<e.offsetHeight+t.offsetHeight?!0:!1},r=0;for(r=0;r<t.length;r++)if(n(e,t[r]))return!0;return!1};for(var o=0;o<t.length;o++)t[o].weight=parseFloat(t[o].weight,10);t.sort(function(e,t){return e.weight<t.weight?1:e.weight>t.weight?-1:0});var u=n.shape==="rectangular"?18:2,a=[],f=n.width/n.height,l=function(o,l){var c=i+"_word_"+o,h="#"+c,p=6.28*Math.random(),d=0,v=0,m=0,g=5,y=n.customClass,b="",w="";l.html=e.extend(l.html,{id:c}),l.html&&l.html["class"]&&(y=l.html["class"],delete l.html["class"]),t[0].weight>t[t.length-1].weight&&(g=Math.round((l.weight-t[t.length-1].weight)/(t[0].weight-t[t.length-1].weight)*9)+1),w=e("<span>").attr(l.html).addClass("w"+g+" "+y),l.link?(typeof l.link=="string"&&(l.link={href:l.link}),n.encodeURI&&(l.link=e.extend(l.link,{href:encodeURI(l.link.href).replace(/'/g,"%27")})),b=e("<a>").attr(l.link).text(l.text)):b=l.text,w.append(b);if(!!l.handlers)for(var E in l.handlers)l.handlers.hasOwnProperty(E)&&typeof l.handlers[E]=="function"&&e(w).bind(E,l.handlers[E]);r.append(w);var S=w.width(),x=w.height(),T=n.center.x-S/2,N=n.center.y-x/2,C=w[0].style;C.position="absolute",C.left=T+"px",C.top=N+"px";while(s(document.getElementById(c),a)){if(n.shape==="rectangular"){v++,v*u>(1+Math.floor(m/2))*u*(m%4%2===0?1:f)&&(v=0,m++);switch(m%4){case 1:T+=u*f+Math.random()*2;break;case 2:N-=u+Math.random()*2;break;case 3:T-=u*f+Math.random()*2;break;case 0:N+=u+Math.random()*2}}else d+=u,p+=(o%2===0?1:-1)*u,T=n.center.x-S/2+d*Math.cos(p)*f,N=n.center.y+d*Math.sin(p)-x/2;C.left=T+"px",C.top=N+"px"}a.push(document.getElementById(c)),e.isFunction(l.afterWordRender)&&l.afterWordRender.call(w)},c=function(i){i=i||0;if(!r.is(":visible")){setTimeout(function(){c(i)},10);return}i<t.length?(l(i,t[i]),setTimeout(function(){c(i+1)},10)):e.isFunction(n.afterCloudRender)&&n.afterCloudRender.call(r)};n.delayedMode?c():(e.each(t,l),e.isFunction(n.afterCloudRender)&&n.afterCloudRender.call(r))};return setTimeout(function(){o()},10),r}})(jQuery);
View
3  src/README.md.erb
@@ -96,6 +96,7 @@ All cloud-wide configurations are optional, and the full list of available optio
* **afterCloudRender** (function): A callback function to be called after the whole cloud is fully rendered.
* **delayedMode** (boolean): If true, words are rendered one after another with a tiny delay between each one. This prevents freezing of the browser when there are many words to be rendered. If false, the cloud will be rendered in one single shot. By default, delayedMode is true when there are more than 50 words.
* **shape** (string): the shape of the cloud. By default it is elliptic, but it can be set to `"rectangular"` to draw a rectangular-shaped cloud.
+* **customClass** (string): custom CSS class to be added to all words.
## Custom CSS guidelines
@@ -114,7 +115,7 @@ Please note that version 1.0 is a redesign of the API that does not maintain bac
This is a quick list of what changed in the new 1.0 API:
- * in the word object, you can now specify any html attribute for the word <span> using the `html` option (e.g.: `{title: "A Title", "class": "custom-class", data-custom: "custom data attribute"}`). Since this allows for more flexibility, `title`, `customClass` and `dataAttributes` options are superfluous and dropped in v1.0.
+ * in the word object, you can now specify any html attribute for the word <span> using the `html` option (e.g.: `{title: "A Title", "class": "custom-class", data-custom: "custom data attribute"}`). Since this allows for more flexibility, `title` and `dataAttributes` options are superfluous and dropped in v1.0.
* the `url` option was renamed `link` in v1.0, and can now be a URL string or an object. In the latter case, any html attribute for the `<a>` tag can be specified (e.g.: `{href: "http://myurl.com", title: "A Title"}`).
* the cloud options `randomClasses` and `nofollow` are dropped in v1.0. They were indended for purposes which are better achieved using the new `html` and `link` word options.
* `width` and `height` cloud options now set the width and height of the cloud container element, other than determining the aspect ratio of the cloud.
View
2  src/examples/rectangular.html.erb
@@ -51,7 +51,7 @@
{text: "Sed", weight: 1}
];
$(function() {
- $("#my_favorite_latin_words").jQCloud(word_list, {shape: "rectangular"});
+ $("#my_favorite_latin_words").jQCloud(word_list, {shape: "rectangular", customClass: "tag"});
});
</script>
</head>
View
5 src/jqcloud/jqcloud.js.erb
@@ -27,7 +27,8 @@
},
delayedMode: word_array.length > 50,
shape: false, // It defaults to elliptic shape
- encodeURI: true
+ encodeURI: true,
+ customClass: ''
};
options = $.extend(default_options, options || {});
@@ -87,7 +88,7 @@
quarter_turns = 0.0,
weight = 5,
- custom_class = "",
+ custom_class = options.customClass,
inner_html = "",
word_span = "";
Please sign in to comment.
Something went wrong with that request. Please try again.