Giter Site home page Giter Site logo

movibe / loading-bar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peachananr/loading-bar

0.0 0.0 0.0 116 KB

Add a Youtube-like loading bar to all your ajax links

Home Page: http://www.thepetedesign.com/demos/youtube_loadingbar_demo.html

loading-bar's Introduction

#Loading Bar by Pete R. A little jQuery plugin that will let you add a Youtube-like loading bar to all your ajax links Created by Pete R., Founder of BucketListly

Loading Bar

Demo

View demo

Usage

To add a Youtube-like loading bar to your website, simply include the latest jQuery library found here together with jquery.loadingbar.js and loadingbar.css into your document's <head> and simply call the function as shown below:

$(".ajax-call").loadingbar({
  replaceURL: false, /* You can visibly change the URL of the browser to reflect the clicked links by toggling this to true. Default is false. May not work in old browsers. */
	target: "#loadingbar-frame", /* The container's selector where you want the ajax result to appear. Default is #loadingbar-frame */
	direction: "right", /* The direction where the the loading bar will progress. Default is right. */
	
	/* Default Ajax Parameters.  */
	async: true, 
	complete: function(xhr, text) {},
	cache: true,
	error: function(xhr, text, e) {},
	global: true,
	headers: {},
	statusCode: {},
	success: function(data, text, xhr) {},
	dataType: "html",
	done: function(data) {}
});

Note: For options listed under Default Ajax Parameters, simply refer to jQuery.ajax doc for more info.

For HTML markups, all you need is a link and a container to show the result:

<a href="YOUR-URL" class="ajax-call">..</a>
<div id="loadingbar-frame"></div>

Make sure you change the "YOUR-URL" into the URL you want the script to load.

Further Customization

Sometime you may want each links to have its own ajax command, for example one for POST and another for GET. With this script you can do this by simply following markup rules as shown in the example below:

<a href="http://api.dribbble.com/players/jackietrananh/shots?callback=?" 
data-datatype="json" data-type="GET" data-target="#frame">Click Me</a>

This example shows how I was able to call the Dribbble's API with a data markup. Simply assign data-target with a selector to define the target container, data-type to define the type of ajax call you want and data-datatype to define the type you want to receive.

Now, each individual links will perform using its own settings.

Other Resources

  • Tutorial (Coming Soon)

loading-bar's People

Contributors

peachananr 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.