Code Monkey home page Code Monkey logo

jquery.soccerfield.js's Introduction

soccerfield.js

jquery plugin for soccer field display with players on their positions

Usage: For usage include jquery, plugin itself (jquery.soccerfield.js), basic stylesheet (soccerfield.css) and one of themes (soccerfield.default.css)

$(document).ready(function(){
  $("#soccerfield").soccerfield(data,options);
});

To see an example simply clone/download the repo, go to the demo folder and launch index.html

Available options (example with comments):

var options =  {
  //options for soccer field
  field: {
    //soccer field width; default: 960px
    width: "960px",
    //soccer field height; default: 600px
    height: "600px",
    //img for soccer field default: 'img/soccerfield_green.png'
    img: 'img/soccerfield_green.png',
    //load page with hidden field; default:false
    startHidden: true,
    //animate field appearance with fade; default: false
    animate: true,
    //time for fadeIn 
    fadeTime: 1000,
    //reveal field automatically on load (default:true), if set to false needs extra $selector.data("soccerfield").revealField() call
    autoReveal:true,
    //callback on soccer field reveal
    onReveal: function () {
            } 
    },
  //options for players
  players: {
    //font size for player names in pixels (default 16)
    font_size: 16,
    //reveal players or load with players not hidden; default: true
    reveal: true,
    //reveal simultaneously (default: true); if false  - players reveal one by one after selected timeout
    sim: false,
    //timeout between players reveal in sim:false mode
    timeout: 1000,
    //time for fadeIn players animation
    fadeTime: 2000,
    //player img, no img if false (default: false)
    img: 'img/soccer-player.png',
    //callback after all players revealed
    onReveal: function () {
            alert("players revealed!");
            }
  }
};

Data format requirements (example):

var data = [
  {name: 'Gianluigi Buffon', position: 'C_GK'},
  {name: 'Leonardo Bonucci', position: 'LC_B'},
  {name: 'Giorgio Chiellini', position: 'C_B'},
  {name: 'Andrea Barzagli', position: 'RC_B'},
  {name: 'Daniele De Rossi', position: 'C_DM'},
  {name: 'Alessandro Florenzi', position: 'L_M'},                
  {name: 'Emanuele Giaccherini', position: 'LC_M'},
  {name: 'Marco Parolo', position: 'RC_M'},
  {name: 'Antonio Candreva', position: 'R_M'},
  {name: 'Éder', position: 'LC_F'},
  {name: 'Lionel Messi', position: 'RC_F', img: 'img/argentina_flag.png'},
];

Possible positions Position consists of two parts, divided by underscore sign "_".

Left part id for "y" position:

  • L - Left
  • LC- Left-Center
  • C - Center
  • RC - Right-Center
  • R - Right

Right part is for "x" or "soccer" position:

  • GK - GoalKeeper
  • B - Back
  • DM - Defending Midfielder
  • M - Midfielder
  • AM - Attacking MidFielder
  • F - Forward

You can combine these positions as it is showed in example

Methods

Methods are available through $selector.data("soccerfield") attribute.

revealField() - reveals field and players

revealPlayers() - reveals hidden players

destroy() - destroys instance of plugin

Added features: Now you are able to assign picture individually for each player using img key in you data array If img is not set - the plugin will pick up one from the options.players.img

Themes:

You are free to create your own themes. For example soccerfield.default.css theme is provided

TODO:

  • Create minified version
  • Manage players's numbers
  • Manage players changes and substitutions
  • More customization and themes
  • Bower install

jquery.soccerfield.js's People

Contributors

kilroggd avatar

Watchers

Dennis Hebbeler avatar

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.