Ads

Wednesday, 13 August 2014

ProgressJs - A themeable progress bar library for everything

Download   Demo


ProgressJs is a JavaScript and CSS3 library which helps developers create and manage progress bars for any object on the page. You can design your own template for progress bars or simply customize them.


You can use ProgressJs to show the progress of loading contents (images, videos, etc.) on the page to the users. It can be used on all elements including textboxes, textareas or even the whole body.


It’s light-weight, easy to use, customizable, free and open-source.


1. INCLUDE CSS AND JS FILES


<script src="progress.js"></script>
<link href="progressjs.css" rel="stylesheet">

2. HTML


<textarea id="countTextarea" placeholder="Start typing.." rows="4"></textarea>

3. JAVASCRIPT


//to set progress-bar for whole page
progressJs().start();
//or for specific element
var prgjs = progressJs("#countTextarea").setOptions( theme: 'blackRadiusInputs' ).start();
prgjs.set(50);

4. API


progressJs([targetElm])


Creating an ProgressJS object.


Available since: v0.1.0


Parameters:


  • targetElm : String (optional) Should be defined to start progress-bar for specific element, for example: #targetElement.

Returns:


  • progressJs object.

Example:



progressJs() //without selector, set progress-bar for whole page
progressJs("#targetElement") //start progress-bar for element id='targetElement'



progressJs.start()


Start the progress-bar for defined element(s).


Available since: v0.1.0


Returns:


  • progressJs object.

Example:



progressJs().start()



progressJs.set(percent)


Set specific percentage to progress-bar


Available since: v0.1.0


Parameters:


  • percent: Number

    Set to specific percentage

Returns:


  • progressJs object.

Example:



progressJs().set(20); //set progress to 20%



progressJs.autoIncrease(size, millisecond)


Set an auto-increase timer for the progress-bar.


Available since: v0.1.0


Parameters:


  • size: Number

    The size of increment when timer elapsed

  • millisecond: Number

    Timer in milliseconds

Returns:


  • progressJs object.

Example:



progressJs().start().autoIncrease(4, 500); //every 500 milliseconds, percentage + 4



progressJs.increase([size])


Increase the progress-bar bar specified size. Default size is 1.


Available since: v0.1.0


Parameters:


  • size: Number

    The size of increment

Returns:


  • progressJs object.

Example:



progressJs().increase(); //increase one percent
progressJs().increase(2); //increase two percent



progressJs.end()


End the progress-bar and remove the elements from page.


Available since: v0.1.0


Returns:


  • progressJs object.

Example:



progressJs().start().set(20).end()



progressJs.setOption(option, value)


Set a single option to progressJs object.


Available since: v0.1.0


Parameters:


  • option : String

    Option key name.

  • value : String/Number

    Value of the option.

Returns:


  • progressJs object.

Example:



progressJs().setOption("theme", "black");



progressJs.setOptions(options)


Set a group of options to the progressJs object.


Available since: v0.1.0


Parameters:


  • options : Object

    Object that contains option keys with values.

Returns:


  • progressJs object.

Example:



progressJs().setOptions( 'theme': 'black', 'overlayMode': true );



progressJs.onbeforeend(providedCallback)


Set a callback function for before end of the progress-bar.


Available since: v0.1.0


Parameters:


  • providedCallback : Function

Returns:


  • progressJs object.

Example:



progressJs().onbeforeend(function() 
alert("before end");
);



progressJs.onbeforestart(providedCallback)


Set a callback function to call before start the progress-bar.


Available since: v0.1.0


Parameters:


  • providedCallback : Function

Returns:


  • progressJs object.

Example:



progressJs().onbeforestart(function() 
alert("before start");
);



progressJs.onprogress(providedCallback)


Set callback function to call for each change of progress-bar.


Available since: v0.1.0


Parameters:


  • providedCallback : Function

Returns:


  • progressJs object.

Example:



progressJs().onprogress(function(targetElm, percent) 
alert("progress changed to:" + percent);
);



ProgressJs - A themeable progress bar library for everything

Tuesday, 12 August 2014

Slider - A jQuery slide plugin

Download Demo


Slider is a jQuery slide plugin for creating a responsive & cross-browser image slider that supports full screen, multiple effects, navigation, autoplay, easing, change speed and trigger…


1. INCLUDE JS FILES


<script src="/path/to/jquery.js"></script><!-- jQuery is required -->
<script src="/path/to/slider.js"></script>

2. HTML


<div class="slider">
<div class="slider-content">
<div><img src="img/picture-1.jpg" alt="Picture 1"></div>
<div><img src="img/picture-2.jpg" alt="Picture 2"></div>
<div><img src="img/picture-3.jpg" alt="Picture 3"></div>
</div>
<div class="slider-nav">
<div class="slider-active"></div>
<div></div>
<div></div>
</div>
<div class="slider-prev slider-disabled">&lsaquo;</div>
<div class="slider-next">&rsaquo;</div>
</div>

3. JAVASCRIPT


$(".slider").slider(
activeClass: "slider-active",
autoplay: true,
contentClass: "slider-content",
disableClass: "slider-disabled",
duration: 5000,
effect: "fade",
easing: "swing",
navClass: "slider-nav",
nextClass: "slider-next",
prevClass: "slider-prev",
speed: 1000,
trigger: "click"
);


Slider - A jQuery slide plugin

Collections - Drag and Drop jquery collection add-on

Download   Demo


Collections is a Drag and Drop jquery collection add-on for ecommerce site.


1. INCLUDE CSS AND JS FILES


<link href="assets/css/ars_coolection.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="assets/js/vendor/jquery/dist/jquery.min.js"></script>
<script src="assets/js/vendor/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="assets/js/collection.js" type="text/javascript"></script>

2. HTML


<!--BEGIN COLLECTION DETAIL PAGE-->
<div class="ars_Collcontent">
<div class="ars_Collbody">
<div class="ars_CollMid">
<div class="ars_CollBanner">
<div class="ars_CollMainbox">
<div class="ars_Colldiv1" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item1.jpg" class="dragimg" alt="Image1" />
</div>
<div class="ars_Colldiv2" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item2.jpg" class="dragimg" alt="Image2" />
</div>
<div class="ars_Colldiv3" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item3.jpg" class="dragimg" alt="Image3" />
</div>
<div class="ars_Colldiv4" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item4.jpg" class="dragimg" alt="Image4" />
</div>
<div class="ars_Colldiv5" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item5.jpg" class="dragimg" alt="Image5" />
</div>
<div class="ars_Colldiv6" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item6.jpg" class="dragimg" alt="Image6" />
</div>
<div class="ars_Colldiv7" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item7.jpg" class="dragimg" alt="Image7" />
</div>
<div class="ars_Colldiv8" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src=" assets/images/collection_item8.jpg" class="dragimg" alt="Image8" />
</div>
<div class="ars_Colldiv9" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item9.jpg" class="dragimg" alt="Image9" />
</div>
<div class="ars_Colldiv10" id="img_div">
<div class="ars_popClose"><a href="#">CLOSE</a></div>
<img src="assets/images/collection_item10.jpg" class="dragimg" alt="Image10" />
</div>
</div>

</div>

<div class="ars_clr"></div>
</div>
</div>
</div>
<!--END COLLECTION DETAIL PAGE-->


Collections - Drag and Drop jquery collection add-on

Bootstrap Color Picker Sliders

Download   Demo


Bootstrap Color Picker Sliders is a Bootstrap 3 optimized advanced responsive color selector with color swatches and support for human perceived lightness. Works in all modern browsers and on touch devices. Bootstrap 3 optimized responsive color selector with HSV, HSL, RGB and CIE-Lch selectors and color swatches.


1. INCLUDE CSS AND JS FILES


<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all">
<link href="//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css" rel="stylesheet" type="text/css" media="all">
<link href="src/bootstrap.colorpickersliders.css" rel="stylesheet" type="text/css" media="all">

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/prettify/r298/run_prettify.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/tinycolor/0.11.1/tinycolor.min.js"></script>
<script src="src/bootstrap.colorpickersliders.js"></script>

2. HTML


<div id="hsvflat"></div>

3. JAVASCRIPT


 $("#hsvflat").ColorPickerSliders(
color: "rgb(36, 170, 242)",
flat: true,
sliders: false,
swatches: false,
hsvpanel: true
);


Bootstrap Color Picker Sliders

Monday, 11 August 2014

Fattable - Create scrollable table with infinite rows and columns

Download Demo


Fattable is a javascript Library to create table with infinite scroll, with infinite number of rows and number of columns.


Big table (more 10,000 cells) don’t do well with DOM. Your scroll will start getting choppy.


Also big tables can rapidly grow in sizes. It is not always possible to have clients download or even retain all of the table data. Fattable includes everything required to load your data asynchronously.


This library is


  • light : no library needed, smaller than 10KB)

  • fast (only visible element are in DOM, the exact same DOM element are recycled over and over, )

  • async friendly : the API makes it simple to fetch your data aysnchronously.

  • powerful and unbloated : Design is up to you. Style the table via css and use your painter to hook up events, and render your content in your cell.

1. INCLUDE CSS AND JS FILES


<link rel="stylesheet" type="text/css" href='fattable.css'>
<script src='fattable.js'></script>

2. HTML


<div id='container'></div>

3. JAVASCRIPT


var columnWidths = [
150, 120, 600, 250,
];
for (var i=columnWidths.length; i<10000; i++)
var columnWidth = (Math.random() * 100 + 100)

var painter = new fattable.Painter();
painter.fillCell = function(cellDiv, data)
cellDiv.textContent = data.content;
if (data.rowId % 2 == 0)
cellDiv.className = "even";

else
cellDiv.className = "odd";



painter.fillCellPending = function(cellDiv, data)
cellDiv.textContent = "";
cellDiv.className = "pending";



var tableData = new fattable.SyncTableModel();

var c=0;

tableData.getCellSync = function(i,j)
return
"content": "Cell " + i + "," + j+"


tableData.columnHeaders = ["Country Name", "Country Code", "Indicator Name", "Indicator Code", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013"];

tableData.getHeaderSync = function(j)
return "Column " + j;


var table = fattable(
"container": "#container",
"model": tableData,
"nbRows": 40000,
"rowHeight": 35,
"headerHeight": 40,
"painter": painter,
"columnWidths": columnWidths
);


window.onclick = function()
c += 1;
table.refreshAllContent(true);
;

window.onresize = function()
table.setup();

4. API


var table = fattable(
"painter": painter, // your painter (see below)
"model": model, // model describing your data (see below)
"nbRows": 1000000, // overall number of rows
"rowHeight": 35, // constant row height (px)
"headerHeight": 100, // height of the header (px)
"columnWidths": [300, 300, 300, 300] // array of column width (px)
)

5. PAINTER


painter is an object which role is to fill the content of your cells, and columnHeaders. It is expected to implement the following interface.


var painter = 

"setupHeader": function(headerDiv)
/* Setup method are called at the creation
of the column header. That is during
initialization and for all window resize
event. Columns are recycled. */

,
"setupCell": function(cellDiv)
/* The cell painter tells how
to fill, and style cells.
Do not set height or width.
in either fill and setup methods. */

,
"fillHeader": function(headerDiv, data)
/* Fills and style a column div.
Data is whatever the datalayer
is returning. A String, or a more
elaborate object. */
colHeaderDiv.textContent = data;

,
"fillCell": function(cellDiv, data)
/* Fills and style a cell div.
Data is whatever the datalayer
is returning. A String, or a more
elaborate object. */
cellDiv.textContent = data;

,
"fillHeaderPending": function(headerDiv)
/* Mark a column header as pending.
When using an asynchronous.
Its content is not in cache
and needs to be fetched */
cellDiv.textContent = "NA";

,
"fillCellPending": function(cellDiv)
/* Mark a cell content as pending
Its content is not in cache and
needs to be fetched */
cellDiv.textContent = "NA";

;

Actually this very simple implementation is the default. And it is available as fattable.Painter, so that you can just override it.


6. DATALAYER


Synchronous Data Layer


If your data is not too big, you probably can just fetch your data all at once, and then display the table. For this simple use case, the best is probably to extend the SyncTableData object.


You just need to extend fattable.SyncTableModel and implement the following methods



"getCellSync": function(i,j)
return "cell " + i + "," + j;
,
"getHeaderSync": function(i,j)
return "col " + j;



Asynchronous and paged async model


You probably don’t want your backend to receive one request per cell displayed. A good solution to this problem is to partition your table into pages of cells.


Queries are only sent when the user stops scrolling.


To use such a system, you just have to extend the PagedAsyncTableModelclass with the following methods. In addition, it include a simple LRU cache.



"cellPageName": function(i,j) 0;
var J = (j / 29) ,
"fetchCellPage": function(pageName, cb)
// Async method to return the page of
var coords = JSON.parse(pageName);
var I = coords[0];
var J = coords[1];
getJSON("data/page-" + I + "-" + J + ".json", function(data)
cb(function(i,j)
return
rowId: i,
content: data[i-I*128][j-J*29]
;
);
);
,
"headerCellPage" : function(j)
// Same as for cellPageName but for cells.
,
"fetchHeaderPage" : function(j)
// Same as for fetchCellPage but for headers



Custom async model


If you want to go custom, you can implement your own data model, it just has to implement the following methods :



hasCell: function(i,j)
// returns true if getting the data of the cell (i,j )
// does not require an async call false if it does need it.
,
hasHeader: function(j)
// ... same thing for column header j
,
getCell: function(i,j,cb)
// fetch data associated to cell i,j
// and call the callback method cb with it
// as argument
,
getHeader: function(j,cb)
// ... same thing for column header j



Fattable - Create scrollable table with infinite rows and columns