Skip to content

Commit

Permalink
correct mistake in README, and switch to markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaong committed Nov 8, 2011
1 parent 4e6e306 commit 98dd8a1
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 81 deletions.
86 changes: 48 additions & 38 deletions README.textile → README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
h1. jQCloud: beautiful word clouds with jQuery
jQCloud: beautiful word clouds with jQuery
==========================================

jQCloud is a jQuery plugin that builds neat and pure HTML + CSS word clouds and tag clouds that are actually shaped like a cloud (otherwise, why would we call them 'word clouds'?).
jQCloud is a jQuery plugin that builds neat and pure HTML + CSS word clouds and tag clouds that are actually shaped like a cloud (otherwise, why should we call them 'word clouds'?).

You can see a "demo here":http://www.lucaongaro.eu/demos/jqcloud/

h2. Installation
Installation
------------

Installing jQCloud is extremely simple:

# Make sure to import the jQuery library in your project.
# Download the jQCloud files. Place "jqcloud-0.2.6.js":https://raw.github.com/DukeLeNoir/jQCloud/master/jqcloud/jqcloud-0.2.6.js (or the minified version "jqcloud-0.2.6.min.js":https://raw.github.com/DukeLeNoir/jQCloud/master/jqcloud/jqcloud-0.2.6.min.js) and "jqcloud.css":https://raw.github.com/DukeLeNoir/jQCloud/master/jqcloud/jqcloud.css somewhere in your project and import both of them in your HTML code.
1. Make sure to import the jQuery library in your project.
2. Download the jQCloud files. Place [jqcloud-0.2.6.js](https://raw.github.com/DukeLeNoir/jQCloud/master/jqcloud/jqcloud-0.2.6.js) (or the minified version [jqcloud-0.2.6.min.js](https://raw.github.com/DukeLeNoir/jQCloud/master/jqcloud/jqcloud-0.2.6.min.js)) and [jqcloud.css](https://raw.github.com/DukeLeNoir/jQCloud/master/jqcloud/jqcloud.css) somewhere in your project and import both of them in your HTML code.

You can easily substitute jqcloud.css with a custom CSS stylesheet following the guidelines explained later.

h2. Usage
Usage
-----

Once you imported the .js and .css files, drawing a cloud is as simple as this:

bc. <!DOCTYPE html>
```javascript
<!DOCTYPE html>
<html>
<head>
<title>jQCloud Example</title>
Expand All @@ -39,6 +43,7 @@ bc. <!DOCTYPE html>
* url: a URL to which the word will be linked. It will be used as the href attribute of an HTML anchor.
* title: an HTML title for the <span> that will contain the word(s)
* callback: a function to be called after this word is rendered. Within the function, 'this' is the word element.
* handlers: an object specifying event handlers that will bind to the word (e.g.: {click: function() { alert("it works!"); } })
*/
var word_list = [
{text: "Lorem", weight: 15},
Expand All @@ -59,8 +64,10 @@ bc. <!DOCTYPE html>
<div id="example" style="width: 550px; height: 350px; position: relative;"></div>
</body>
</html>
```

h3. Options:
Options:
--------

Since version 0.2.0, jQCloud accepts an object containing configuration options as the second argument:

Expand All @@ -71,78 +78,81 @@ bc. $("#example").jQCloud(word_list, {

The full list of available options is the following:

* *width* (number): The width of the word cloud. Defaults to the width of the container element.
* *height* (number): The height of the word cloud. Defaults to the height of the container element.
* *center* (object): The x and y coordinates of the center of the word cloud (e.g.: {x: 300, y: 150}). Defaults to the center of the container element.
* *callback* (function): A callback function to be called after the cloud is fully rendered. This is different from the callbacks defined for each word in which this one is called after the whole cloud is 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.
* *randomClasses* (number or array): If it's a number and higher than 0, each word will be assigned randomly to a class of kind @r1@, @r2@, ..., @rN@ with N = randomClasses. If it is an array of classes, each word will be assigned randomly to one of the classes in the array. This random class can be used for random CSS styling of words, for example to set a random color or random orientation (see @examples/vertical_words.html@).
* *handlers* (object): an object specifying event handlers to bind to words (e.g.: {click: function() { alert("it works!"); } })
* *nofollow* (boolean): if true, all words linked to a URL will have the rel="nofollow" attribute.
* **width** (number): The width of the word cloud. Defaults to the width of the container element.
* **height** (number): The height of the word cloud. Defaults to the height of the container element.
* **center** (object): The x and y coordinates of the center of the word cloud (e.g.: {x: 300, y: 150}). Defaults to the center of the container element.
* **callback** (function): A callback function to be called after the cloud is fully rendered. This is different from the callbacks defined for each word in which this one is called after the whole cloud is 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.
* **randomClasses** (number or array): If it's a number and higher than 0, each word will be assigned randomly to a class of kind `r1`, `r2`, ..., `rN` with N = randomClasses. If it is an array of classes, each word will be assigned randomly to one of the classes in the array. This random class can be used for random CSS styling of words, for example to set a random color or random orientation (see `examples/vertical_words.html`).
* **nofollow** (boolean): if true, all words linked to a URL will have the `rel="nofollow"` attribute.

h3. Note:
### Note:

Since drawing the cloud is rather computationally intensive, cloud rendering isn't instantaneous. If you want to make sure that some code executes after the cloud is rendered, you can specify in the options a callback function:

bc. $("#example").jQCloud(word_list, {
```javascript
$("#example").jQCloud(word_list, {
callback: function() {
// This code executes after the cloud is fully rendered
}
});
```

h4. Deprecation warning:
#### Deprecation warning:

Before version 0.2.0 jQCloud used to accept a callback function as the second argument. This way of specifying the callback function is deprecated and, although version 0.2.0 maintains backward compatibility, it will be removed in newer versions. If you need a callback function, use the 'callback' configuration option instead.

h2. Custom CSS guidelines
Custom CSS guidelines
---------------------

The word cloud produced by jQCloud is made of pure HTML, so you can style it using CSS. When you call $("#example").jQCloud(...), the containing element is given a CSS class of "jqcloud", allowing for easy CSS targeting. The included CSS file jqcloud.css is intended as an example and as a base on which to develop your own custom style, defining dimensions and appearance of words in the cloud. When writing your custom CSS, just follow these guidelines:
The word cloud produced by jQCloud is made of pure HTML, so you can style it using CSS. When you call `$("#example").jQCloud(...)`, the containing element is given a CSS class of "jqcloud", allowing for easy CSS targeting. The included CSS file `jqcloud.css` is intended as an example and as a base on which to develop your own custom style, defining dimensions and appearance of words in the cloud. When writing your custom CSS, just follow these guidelines:

* Always specify the dimensions of the container element (div.jqcloud in jqcloud.css).
* The CSS attribute 'position' of the container element must be explicitly declared and different from 'static'.
* Specifying the style of the words (color, font, dimension, etc.) is super easy: words are wrapped in @<span>@ tags with ten levels of importance corresponding to the following classes (in descending order of importance): w10, w9, w8, w7, w6, w5, w4, w3, w2, w1.
* Specifying the style of the words (color, font, dimension, etc.) is super easy: words are wrapped in `<span>` tags with ten levels of importance corresponding to the following classes (in descending order of importance): w10, w9, w8, w7, w6, w5, w4, w3, w2, w1.

h2. Examples

Just have a look at the examples directory provided in the project or see a "demo here":http://www.lucaongaro.eu/demos/jqcloud/.
Just have a look at the examples directory provided in the project or see a [demo here](http://www.lucaongaro.eu/demos/jqcloud/).

If you happen to use jQCloud in your projects, you can make me know (just contact me on "my website":http://www.lucaongaro.eu) and I can add a link to your website in a 'gallery' section, so that other people can take inspiration from it.
If you happen to use jQCloud in your projects, you can make me know (just contact me on [my website](http://www.lucaongaro.eu)) and I can add a link to your website in a 'gallery' section, so that other people can take inspiration from it.

h2. Contribute
Contribute
----------

Contributes are welcome! To setup your build environment, make sure you have Ruby installed, as well as the @rake@ and @erb@ gems. Then, to build jQCloud, run:
Contributes are welcome! To setup your build environment, make sure you have Ruby installed, as well as the `rake` and `erb` gems. Then, to build jQCloud, run:

bc. rake build

The newly-built distribution files will be put in the @jqcloud@ subdirectory.
The newly-built distribution files will be put in the `jqcloud` subdirectory.

If you make changes to the JavaScript source, to the README, to examples or to tests, make them to .erb files in the @src@ subdirectory: changes will be reflected in the distribution files as soon as you build jQCloud. Also, if you send me a pull request, please don't change the version.txt file.
If you make changes to the JavaScript source, to the README, to examples or to tests, make them to .erb files in the `src` subdirectory: changes will be reflected in the distribution files as soon as you build jQCloud. Also, if you send me a pull request, please don't change the version.txt file.

h2. Changelog

0.2.6 Fix bug with handlers, add nofollow option (thanks to "strobotta":https://github.com/strobotta) and word callbacks.
0.2.6 Fix bug with handlers, add nofollow option (thanks to [strobotta](https://github.com/strobotta)) and word callbacks.

0.2.5 Add possiblity to bind event handlers to words (thanks to "astintzing":https://github.com/astintzing)
0.2.5 Add possiblity to bind event handlers to words (thanks to [astintzing](https://github.com/astintzing))

0.2.4 Option randomClasses can be an array of classes among which a random class is selected for each word

0.2.3 Add option randomClasses, allowing for random CSS styling (inspired by issue about vertical words opened by "tttp":https://github.com/tttp)
0.2.3 Add option randomClasses, allowing for random CSS styling (inspired by issue about vertical words opened by [tttp](https://github.com/tttp))

0.2.2 CSS improvements (as suggested by "NomikOS":https://github.com/NomikOS)
0.2.2 CSS improvements (as suggested by [NomikOS](https://github.com/NomikOS))

0.2.1 Optimization and performance improvements (making 0.2.1 around 25% faster than 0.2.0)

0.2.0 Add configuration options, passed as the second argument of jQCloud (include ideas proposed by "mindscratch":https://github.com/mindscratch and "aaaa0441":https://github.com/aaaa0441)
0.2.0 Add configuration options, passed as the second argument of jQCloud (include ideas proposed by [mindscratch](https://github.com/mindscratch) and [aaaa0441](https://github.com/aaaa0441))

0.1.8 Fix bug in the algorithm causing sometimes unbalanced layouts (thanks to "isamochernov":https://github.com/isamochernov)
0.1.8 Fix bug in the algorithm causing sometimes unbalanced layouts (thanks to [isamochernov](https://github.com/isamochernov))

0.1.7 Remove duplicated @</span>@ when word has an URL (thanks to "rbrancher":https://github.com/rbrancher)
0.1.7 Remove duplicated `</span>` when word has an URL (thanks to [rbrancher](https://github.com/rbrancher))

0.1.6 JavaScript-friendly URL encode 'url' option; Typecast 'weight' option to float (thanks to "nudesign":https://github.com/nudesign)
0.1.6 JavaScript-friendly URL encode 'url' option; Typecast 'weight' option to float (thanks to [nudesign](https://github.com/nudesign))

0.1.5 Apply CSS style to a "jqcloud" class, automatically added (previously an id was used. Again, thanks to "seanahrens":https://github.com/seanahrens)
0.1.5 Apply CSS style to a "jqcloud" class, automatically added (previously an id was used. Again, thanks to [seanahrens](https://github.com/seanahrens))

0.1.4 Fix bug with multiple clouds on the same page (kudos to "seanahrens":https://github.com/seanahrens)
0.1.4 Fix bug with multiple clouds on the same page (kudos to [seanahrens](https://github.com/seanahrens))

0.1.3 Added possibility to pass a callback function and to specify a custom HTML title attribute for each word in the cloud

Expand Down
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ task :compile do
f.write ERB.new(File.new(File.join("src", "jqcloud", "jqcloud.js.erb"), "r").read).result(binding)
end

puts "Compiling README.textile"
File.open("README.textile", "w") do |f|
f.write ERB.new(File.new(File.join("src", "README.textile.erb"), "r").read).result(binding)
puts "Compiling README.md"
File.open("README.md", "w") do |f|
f.write ERB.new(File.new(File.join("src", "README.md.erb"), "r").read).result(binding)
end

puts "Compiling examples"
Expand Down
2 changes: 1 addition & 1 deletion jqcloud/jqcloud-0.2.6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Copyright 2011, Luca Ongaro
* Licensed under the MIT license.
*
* Date: Mon Nov 07 21:51:42 +0100 2011
* Date: Tue Nov 08 21:29:01 +0100 2011
*/

(function( $ ) {
Expand Down
2 changes: 1 addition & 1 deletion jqcloud/jqcloud-0.2.6.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 98dd8a1

Please sign in to comment.