• Stars
    star
    183
  • Rank 210,154 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A countdown timer plugin for jQuery

Simple.Timer

A jQuery plugin that creates a countdown timer.

Usage

Set the desired duration using either data-seconds-left or data-minutes-left data attributes.

<div class='timer' data-minutes-left=3></div>
<div class='timer' data-seconds-left=180></div>

Then start the timer with:

$('.timer').startTimer();

The plugin creates <div> elements with the following CSS classes by default:

  • jst-hours
  • jst-minutes
  • jst-seconds
  • jst-clearDiv
  • jst-timeout (added only when the timer is finished)

Here's an example of the HTML of a finished timer:

<div class="timer jst-timeout" data-seconds-left="3">
  <div class="jst-hours">00:</div>
  <div class="jst-minutes">00:</div>
  <div class="jst-seconds">00</div>
  <div class="jst-clearDiv"></div>
</div>

The default CSS classes can be used to style the timer or we can specify custom classes via the classNames option. Like this:

$('.timer').startTimer({
  classNames: {
    hours: 'myClass-hours',
    minutes: 'myClass-minutes',
    seconds: 'myClass-seconds',
    clearDiv: 'myClass-clearDiv',
    timeout: 'myClass-timeout'
  }
});

Options

For more options, checkout http://csouza.me/jQuery-Simple-Timer/ and some more examples.

Install

This plugin can be installed manually from github or via npm.

Manual

Clone the repository and reference the jquery.simple.timer.js file from your html:

<script src="jquery.js"></script>
<script src="jquery.simple.timer.js"></script>

npm

To install from npm, run:

npm install jquery-simple-timer --save

jQuery is NOT installed automatically. We need to install jQuery (npm install jquery --save) and then pass it as an argument to the return value of the require() statement. Here's an example:

// file: client.js
"use strict";

let $ = require("jquery");
require("jquery-simple-timer")($); // passing jQuery as argument

$(function(){
  $('.timer').startTimer();
});

Tests

Open tests/index.html

Contributors

More Repositories

1

vim-config

My vim config
Vim Script
49
star
2

jQuery-Thumb-Preview

A jQuery plugin that provides a thumbnail preview effect.
JavaScript
7
star
3

permissive-cors

CORS for Node HTTP in the most permissive way
JavaScript
6
star
4

React-Thumb-Preview

A React component for thumbnail preview
JavaScript
5
star
5

React-QuizComponent

JavaScript
3
star
6

NodeExpress-BankingPortal

Node/Express Pluralsight Project Sample Application
JavaScript
3
star
7

Portfolio

portfolio de palestras do TaSafo
Ruby
3
star
8

datepicker-liveview

Elixir
3
star
9

ExpressDocker

Running an Express application as a docker container.
Shell
3
star
10

GitForensics

Tracks the relationships between files inside of a Git repository
Ruby
3
star
11

docker-ubuntu-for-rails-5

Docker image ready to be used with Rails 5 apps
3
star
12

budget-elixir

Elixir demo app
Elixir
2
star
13

Coffee-Script-Kata-template

JavaScript
2
star
14

CodeBaseHQ

An iOS app for CodeBaseHQ
Ruby
2
star
15

supplicant-psk

Generates hash for wpa_supplicant.conf
JavaScript
2
star
16

AirportCodesQuiz

Test your knowledge on airport codes.
JavaScript
2
star
17

rex

POC for Ouroboros networking in Elixir
Elixir
2
star
18

fifa-world-cup-api

Go
1
star
19

DSLTalk

talk on DSL
JavaScript
1
star
20

InspectorGitjet

Checks git commits for files often committed together
Ruby
1
star
21

RSpecWorkshop

Example app for RSpec workshop
Ruby
1
star
22

bolao-express

Web app for UFC picks
JavaScript
1
star
23

Metronome

Simple Metronome
CSS
1
star
24

MusicShop

Demo AngularJS app
CSS
1
star
25

ListRockers

Example Go web app deployed to Heroku which uses PostgreSQL
Go
1
star
26

react-native-amplify

JavaScript
1
star
27

ExpressGuitarStoreTDD

JavaScript
1
star
28

InstrumentStoreSelect

Elixir
1
star
29

solar-guitar-store

Elixir
1
star
30

miyagi

coding dojo sensei
Ruby
1
star
31

cluster-live

Realtime administration and statistics plugin for Cluster
JavaScript
1
star
32

watchaplain

Chrome extension that displays current track for a given last.fm user
1
star
33

wowunit

code kata done in Java and inspired by WOW
Java
1
star
34

ClojureSandbox

Clojure
1
star
35

caike

1
star