Git Product home page Git Product logo

jquery.gracket.js's Introduction

Gracket

A single elimation bracket built using canvas and jquery. Live demo: https://zettersten.github.com/jquery.gracket.js/

Example

HTML

<div data-gracket="[{},{},{}]">
</div>

JS

$("[data-gracket]").gracket();

CSS

.g_gracket { width: 9999px; background-color: #fff; padding: 55px 15px 5px; line-height: 100%; position: relative; overflow: hidden;}
.g_round { float: left; margin-right: 70px; }
.g_game { position: relative; margin-bottom: 15px; }
.g_gracket h3 { margin: 0; padding: 10px 8px 8px; font-size: 18px; font-weight: normal; color: #fff}
.g_team { background: #3597AE; }
.g_team:last-child {  background: #FCB821; }
.g_round:last-child { margin-right: 20px; }
.g_winner { background: #444; }
.g_winner .g_team { background: none; }
.g_current { cursor: pointer; background: #A0B43C!important; }
.g_round_label { top: -5px; font-weight: normal; color: #CCC; text-align: center; font-size: 18px; }

API Usage

/* 
* Basic usage
* @note: Assumes your data comes 
*        from the element in the 
*        form of JSON 
*/

$("selector").gracket(); 
/* 
* Custom source usage
* @note: Telling gracket to look 
*        at a local variable
*        for the JSON object 
*/

$("selector").gracket({
	src : refToMyData
});
/* 
* Alter canvas usage
* @note: Tell grackets canvas to 
*        look a little different
*/

$("selector").gracket({
	canvasLineWidth : 1,      // adjusts the thickness of a line
	canvasLineGap : 2,        // adjusts the gap between element and line
	cornerRadius : 3,         // adjusts edges of line
	canvasLineCap : "round",  // or "square"
	canvasLineColor : "white" // or #HEX
});
/* 
* Change class names and id structure
* @note: create gracket with custom  
*        classes to cater to 
*        any convention nessesary
*/

$("selector").gracket({
	gracketClass : "g_gracket",
	gameClass : "g_game",
	roundClass : "g_round",
	teamClass : "g_team",
	winnerClass : "g_winner",
	spacerClass : "g_spacer",
	currentClass : "g_current",
	canvasId : "g_canvas",
	canvasClass : "g_canvas"
});
/* 
* Create show custom labels, or hide them
* @note: create gracket with custom  
*        labels to add more instruction
*        to your bracket. 
*/

$("selector").gracket({
	roundLabels : ["1st Round", "2nd Round", "..."]
});

/* 
* @note: leaving this field 
*				 empty shows the default values.
*				 In order to hide labels, enter 
*				 one empty value.
*/

$("selector").gracket({
	roundLabels : [""]
});

What's Next?

  • Ajax : to load data from a given source and then init the bracket.
  • Tooltips : to hover and expose an element with more info from each team & round.
  • Refactor $ Usage : reduce jQuery methods in the area of "creating elements", "elements lookups", and "element inline styles".
  • Data Dive : A more in depth view at how to structure data to adequatly use gracket.

Contributors

I could not make this plugin without the advice of the following people,

  1. Andrew Miller
  2. James Coutry
  3. Voung Trinh

About

jquery.gracket.js loves all browsers

This plugin has been looked at and tested on the following browsers...

Gracket is supported in all browsers

  • IE6/5 not tested
  • IE has minor issues with hover states.

Disclaimer

This code is provided with no warranty. While I strive to maintain backwards compatibility, the code is still under active development. As this is the case, some revisions may break break compatibility with earlier versions of the library. Please keep this in mind when using jquery.gracket.js.

Copyright and Licensing

Copyright (c) 2012 Erik Zettersten, released under the MIT license.

jquery.gracket.js's People

Contributors

mark100net avatar zettersten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery.gracket.js's Issues

Bye Option

Byes option is absent in this functionality, otherwise it is a great work

Lines not visible in Safari

Hi Erik,

Not sure if you're still maintaining this, but I'm trying to use gracket for a yearly billiards tournament, and everything is OK in Firefox and IE, but not in Chrome and Safari on IOS.
The boxes with the names of the players are displayed correctly, but the lines between the boxes are not shown.
Any idea what can cause this, please ?

Regards,
Hans

Change "text" to "html" for round labels

Recommend changing "text" in this line to "html" to accomodate markup in Round labels...

for (i = 0; i < len; i++) {
left = (i === 0 ? off.padding + widthPadding : off.padding + widthPadding + (off.right * i));
$("<h5 />", {
"text" : (off.labels.length ? off.labels[i] : "Round " + (i + 1)),
"class" : off["class"]
}).css({
"position" : "absolute",
"left" : left,
"width" : offset.width
}).prependTo(container);
widthPadding += max_round_width[i]
};

Not working with jquery 1.8.2

If I take the Live Demo and attempt to run with jquery 1.8.2 I get this error:
Uncaught SyntaxError: Unexpected token o

Any plans to make it work with latest jquery?

Still supported?

Hey there,

I'm currently trying to get this to work with JQuery 1.9.1. Though, I can't get it to work sadly :( Do you know whether it's supposed to work with 1.9.1 or not?

My error is:

$("[data-gracket]").gracket();
SyntaxError: Unexpected token omessage: "Unexpected token o

Round width dynamic based upon largest team in the round

The canvas doesn't line up properly if the Player name is longer than ".g_gracket h3 { min-width ..}". I do believe I worked out a solution that fixes this issue. I can share the jquery.gracket.js file. Is there a way to upload files into the issue?

Add Score to Bracket Entry?

This plug-in would be perfect for an app I am working on - but I would need to show the score of a match on the right hand side of each bracket entry in addition to the seed on the left (also my app uses a division winner vs wildcard indicator). Any chance of adding that? Your work is much appreciated!

So - in short, change this:

{"name" : "Erik Zettersten", "id" : "erik-zettersten", "seed" : 1}

To this:

{"name" : "Erik Zettersten", "id" : "erik-zettersten", "seed" : 1, "displaySeed": "D1", "score": 47}

So it would show (for matches that are completed):

[D1] [Eric Zettersten] [47]

Fails when bracket is incomplete

I'm currently implementing this project in a gaming site where the brackets are going to be displayed DURING the tournament.

By passing an array that does not end with a single player winner, none of the lines draw, nor does any of the hover effects work.

Can someone point me in the direction of the correct way of doing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.