Wednesday, 18 November 2015
Simple Tab Gallery With Pure CSS / CSS3 CODE


--------------------------------------------------------------------------------------------------------------------------
Simple Tab Gallery With Pure CSS / CSS3
COPY PASTE AND SAVE IN HTML
READ MORE
https://www.youtube.com/watch?v=Xaqt4D96SJs
http://wedesignthemes.com/blog/15-latest-prestashop-ecommerce-shopping-themes/
Carousel Specials Products
https://codecanyon.net/category/plugins/prestashop
https://codecanyon.net/item/gallery-instagram-images/19121053css list tab style vertical
https://www.google.co.uk/search?q=css+list+tab+style&rlz=1C1CHBD_en-GBGB722GB722&espv=2&biw=1280&bih=670&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjspfG57orSAhVmBMAKHXKKCEoQ_AUIBigB#tbm=isch&q=css+list+tab+style+vertical&imgrc=AGuQArT8diBTtM:
http://www.hongkiat.com/blog/50-nice-clean-css-tab-based-navigation-scripts/
http://codepen.io/tigt/pen/ZGOMxQ?css-preprocessor=none
Pure CSS Smart Tabs/Accordion Component
http://www.cssscript.com/categories/accordion/
http://www.cssscript.com/demo/pure-css-smart-tabsaccordion-component/#option1
--------------------------------------------------------------------------------------------------------------------------
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CSS Only Tab Gallery Demo</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body { height: 100%; }
body { position: relative; }
img {
max-width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}
body {
display: flex;
justify-content: center;
align-items: center;
background: #e8e8e8;
font-family: 'helvetive neue', sans-serif;
font-weight: 700;
}
.container {
width: 600px;
position: relative;
margin-top:30px;
}
.thumbnails {
list-style: none;
font-size: 0;
margin-left: -2%;
}
.thumbnails li {
display: inline-block;
width: 23%;
margin-left: 2%;
text-align: center;
vertical-align: middle;
}
.thumbnails li:hover .item-hugger { background: white; }
.thumbnails li:hover .item-hugger .title { color: #000; }
.thumbnails input[name="select"] { display: none; }
.thumbnails .item-hugger {
position: relative;
height: 140px;
margin: 20px 0;
background: #f2f2f2;
transition: all 150ms ease-in-out;
}
.thumbnails label {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
cursor: pointer;
}
.thumbnails .title {
padding: 20px 0 0;
font-size: 18px;
color: #555;
transition: all 150ms linear;
}
.thumbnails .thumb-image {
height: 100px;
padding: 20px 0;
}
.thumbnails .content {
position: absolute;
bottom: 0;
left: 0;
width: 600px;
height: 500px;
padding: 50px;
opacity: 0;
transition: all 150ms linear;
display: flex;
flex-direction: column;
justify-content: center;
}
.thumbnails .content .title {
font-size: 60px;
font-weight: 400;
display: inline-block;
color: #555;
border-bottom: 6px solid #fe7701;
padding: 50px 10px 0;
text-transform: uppercase;
}
.thumbnails input[name="select"]:checked + .item-hugger {
height: 180px;
margin: 0;
background: white;
}
.thumbnails input[name="select"]:checked ~ .content { opacity: 1; }
.white-box {
background: white;
height: 500px;
}
</style>
</head>
<body>
<div class="container">
<h1 style="margin-bottom:30px; text-align:center">CSS Only Tab Gallery Demo</h1>
<ul class="thumbnails">
<li>
<input type="radio" name="select" id="image1">
<div class="item-hugger">
<div class="title">Image 1</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=882" />
<label for="image1"></label>
</div>
<div class="content">
<div class="item-wrapper"> <img src="https://unsplash.it/1024/612?image=882" />
<div class="title">Image 1</div>
</div>
</div>
</li>
<li class="is-active">
<input type="radio" name="select" id="image2" checked>
<div class="item-hugger">
<div class="title">Image 2</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=782" />
<label for="image2"></label>
</div>
<div class="content">
<div class="item-wrapper"> <img src="https://unsplash.it/1024/612?image=782" />
<div class="title">Image 2</div>
</div>
</div>
</li>
<li>
<input type="radio" name="select" id="image3">
<div class="item-hugger">
<div class="title">Image 3</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=682" />
<label for="image3"></label>
</div>
<div class="content">
<div class="item-wrapper"> <img src="https://unsplash.it/1024/612?image=682" />
<div class="title">Image 3</div>
</div>
</div>
</li>
<li>
<input type="radio" name="select" id="image4">
<div class="item-hugger">
<div class="title">Image 4</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=582" />
<label for="image4"></label>
</div>
<div class="content">
<div class="item-wrapper"> <img src="https://unsplash.it/1024/612?image=582" />
<div class="title">Image 4</div>
</div>
</div>
</li>
</ul>
<div class="white-box"></div>
</div>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------------
How do I display a list horizontally rather than vertically?
Author: Deron Eriksson
Description: This CSS example describes how to display a list horizontally instead of vertically.
Tutorial created using: Windows XP
Read More:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
CODE:1
-----------------------------------------------------------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Style Test</title>
<style type="text/css">
.vertical {
background-color:Yellow;
}
.horizontal {
display:
inline;
background-color:Aqua;
}
</style>
</head>
<body>
<ul>
<li class="vertical">Vertical One</li>
<li class="vertical">Vertical Two</li>
<li class="vertical">Vertical Three</li>
</ul>
<!-- FOR
HORIZONTAL USE display: inline; CODE
-->
<ul>
<li class="horizontal">Horizontal One</li>
<li class="horizontal">Horizontal Two</li>
<li class="horizontal">Horizontal Three</li>
</ul>
<!-- FOR
UPDOWN AND SAPCE MAKE MORE UL -->
<ul>
<li class="horizontal">Horizontal One</li>
</ul>
<ul>
<li class="horizontal">Horizontal Two</li>
</ul>
<ul>
<li class="horizontal">Horizontal Three</li>
</ul>
</body>
</html>
-----------------------------------------------------------------------------------------------------------
CODE:2
-----------------------------------------------------------------------------------------------------------
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Style Test</title>
<style type="text/css">
.vertical {
background-color:Yellow;
}
.horizontal {
display: inline;
background-color:Aqua;
}
.headers {
list-style-type:none;
display:block;
background:url("http://www.dynamicdrive.com/eeincludes/chromebg.gif")
center center repeat-x;
border-color:#BBBBBB #BBBBBB gray;
border-image:initial;
border-style:solid;
border-width:1px;
font-size:120%;
margin-left:0;
padding:2px 0 2px 5px;
text-align:left;
width:99%;
}
</style>
</head>
<body>
<ul>
<li class="vertical">Vertical One</li>
<li class="vertical">Vertical Two</li>
<li class="vertical">Vertical Three</li>
</ul>
<!-- FOR HORIZONTAL USE display: inline;
CODE -->
<ul>
<li class="horizontal">Horizontal One</li>
<li class="horizontal">Horizontal Two</li>
<li class="horizontal">Horizontal Three</li>
</ul>
<!-- FOR UPDOWN AND SAPCE MAKE MORE UL -->
<ul>
<li class="headers">Horizontal One</li>
</ul>
<ul>
<li class="headers">Horizontal Two</li>
</ul>
<ul>
<li class="headers">Horizontal Three</li>
</ul>
</body>
</html>
-------------------------------------------------------------------------------------------------------------
ADD SLIDER IN CSS TAB LIST
-------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CSS Only Tab Gallery
Demo</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body { height: 100%; }
body { position: relative; }
img {
max-width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}
body {
display: flex;
justify-content: center;
align-items: center;
background: #e8e8e8;
font-family: 'helvetive neue',
sans-serif;
font-weight: 700;
}
.container {
width: 600px;
position: relative;
margin-top:30px;
}
.thumbnails {
list-style: none;
font-size: 0;
margin-left: -2%;
}
.thumbnails li {
display: inline-block;
width: 23%;
margin-left: 2%;
text-align: center;
vertical-align: middle;
}
.thumbnails li:hover .item-hugger {
background: white; }
.thumbnails li:hover .item-hugger
.title { color: #000; }
.thumbnails
input[name="select"] { display: none; }
.thumbnails .item-hugger {
position: relative;
height: 140px;
margin: 20px 0;
background: #f2f2f2;
transition: all 150ms ease-in-out;
}
.thumbnails label {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
cursor: pointer;
}
.thumbnails .title {
padding: 20px 0 0;
font-size: 18px;
color: #555;
transition: all 150ms linear;
}
.thumbnails .thumb-image {
height: 100px;
padding: 20px 0;
}
.thumbnails .content {
position: absolute;
bottom: 0;
left: 0;
width: 600px;
height: 500px;
padding: 50px;
opacity: 0;
transition: all 150ms linear;
display: flex;
flex-direction: column;
justify-content: center;
}
.thumbnails .content .title {
font-size: 60px;
font-weight: 400;
display: inline-block;
color: #555;
border-bottom: 6px solid #fe7701;
padding: 50px 10px 0;
text-transform: uppercase;
}
.thumbnails
input[name="select"]:checked + .item-hugger {
height: 180px;
margin: 0;
background: white;
}
.thumbnails
input[name="select"]:checked ~ .content { opacity: 1; }
.white-box {
background: white;
height: 500px;
}
</style>
</head>
<body>
<div class="container">
<h1 style="margin-bottom:30px; text-align:center">CSS Only Tab Gallery Demo</h1>
<ul class="thumbnails">
<li>
<input type="radio" name="select" id="image1">
<div class="item-hugger">
<div class="title">Image 1</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=882" />
<label for="image1"></label>
</div>
<div class="content">
<div class="item-wrapper">
<!-- ADD
HERE SLIDER CODE -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.carousel-inner
> .item > img,
.carousel-inner
> .item > a > img {
width:
70%;
margin:
auto;
}
</style>
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://www.w3schools.com/bootstrap/img_chania.jpg" alt="Chania" width="460" height="345">
</div>
<div class="item">
<img src="https://www.w3schools.com/bootstrap/img_chania2.jpg" alt="Chania" width="460" height="345">
</div>
<div class="item">
<img src="https://www.w3schools.com/bootstrap/img_flower.jpg" alt="Flower" width="460" height="345">
</div>
<div class="item">
<img src="https://www.w3schools.com/bootstrap/img_flower2.jpg" alt="Flower" width="460" height="345">
</div>
</div>
<a class="left
carousel-control"
href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon
glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right
carousel-control"
href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon
glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!-- ADD
HERE SLIDER CODE -->
</div>
</div>
</li>
<li class="is-active">
<input type="radio" name="select" id="image2" checked>
<div class="item-hugger">
<div class="title">Image 2</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=782" />
<label for="image2"></label>
</div>
<div class="content">
<div class="item-wrapper"> <img src="https://unsplash.it/1024/612?image=782" />
<div class="title">Image 2</div>
</div>
</div>
</li>
<li>
<input type="radio" name="select" id="image3">
<div class="item-hugger">
<div class="title">Image 3</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=682" />
<label for="image3"></label>
</div>
<div class="content">
<div class="item-wrapper"> <img src="https://unsplash.it/1024/612?image=682" />
<div class="title">Image 3</div>
</div>
</div>
</li>
<li>
<input type="radio" name="select" id="image4">
<div class="item-hugger">
<div class="title">Image 4</div>
<img class="thumb-image" src="https://unsplash.it/289/165?image=582" />
<label for="image4"></label>
</div>
<div class="content">
<div class="item-wrapper"> <img src="https://unsplash.it/1024/612?image=582" />
<div class="title">Image 4</div>
</div>
</div>
</li>
</ul>
<div class="white-box"></div>
</div>
</body>
</html>
--------------------------------------------------------------------------------------------------------------------
PURE CSS TAB
--------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<!--
https://css-tricks.com/functional-css-tabs-revisited/ -->
<html>
<head>
<style>
.tabs {
position: relative;
min-height: 200px; /* This part sucks
*/
clear: both;
margin: 25px 0;
}
.tab {
float: left;
}
.tab label {
background: #eee;
padding: 10px;
border: 1px solid #ccc;
margin-left: -1px;
position: relative;
left: 1px;
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: 28px;
left: 0;
background: white;
right: 0;
bottom: 0;
padding: 20px;
border: 1px solid #ccc;
}
[type=radio]:checked ~ label {
background: white;
border-bottom: 1px solid white;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content
{
z-index: 1;
}
</style>
</head>
<body>
<div class="tabs">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab One</label>
<div class="content">
<img src='http://bxslider.com/images/730_200/hill_trees.jpg' title='CaptionGoesHere'/>
</div>
</div>
<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Tab Two</label>
<div class="content">
<img src='http://bxslider.com/images/730_200/me_trees.jpg' title='CaptionGoesHere'/>
</div>
</div>
<div class="tab">
<input type="radio" id="tab-3" name="tab-group-1">
<label for="tab-3">Tab Three</label>
<div class="content">
<img src='http://bxslider.com/images/730_200/houses.jpg' title='CaptionGoesHere'/></li>
</div>
</div>
</div>
</body>
</html>
------------------------------------------------------------------------------------------------------
Pure CSS Smart Tabs/Accordion Component Code:
Read More:
------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<!--
http://www.cssscript.com/pure-css-smart-tabsaccordion-component/ -->
<html>
<head>
<style>
.tabs {
position: relative;
margin: 0;
padding: 15px;
font-size: 0;
}
.tabs li {
display: inline-block;
margin-right: 1px;
list-style-type: none;
font-size: 14px;
}
.tabs li:last-child { margin-right: 0; }
.tabs li a
{
display: block;
padding: 10px 15px;
background: rgba(219,219,219,1);
text-decoration: none;
color: #4B5056;
transition: background 0.5s ease;
}
.tabs a + div {
position: absolute;
left: 0;
height: 0;
padding: 0 15px;
overflow: hidden;
}
.tabs :target a { background: rgba(219,219,219,0); }
.tabs :target a + div {
height: 100%;
overflow: visible;
}
</style>
</head>
<body>
<ul class="tabs">
<li id="option1">
<a href="#option1">Option 1</a>
<div>
<h2>Heading 1</h2>
<p>Lorem Ipsum is simply
dummy text of the printing and typesetting industry. Lorem Ipsum has</p>
<p>Lorem Ipsum is simply
dummy text of the printing and typesetting industry. Lorem Ipsum</p>
</div>
</li>
<li id="option2">
<a href="#option2">Option 2</a>
<div>
<h2>Heading 2</h2>
<p>Contrary to popular
belief, Lorem Ipsum is not simply random text. It has roots in piece</p>
</div>
</li>
<li id="option3">
<a href="#option3">Option 3</a>
<div>
<h2>Heading 3</h2>
<p>There are many
variations of passages of Lorem Ipsum available</p>
</div>
</li>
</ul>
</body>
</html>
BX SLIDER CODE
-------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'>
</script>
<script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'>
</script>
<script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'>
<meta name="robots" content="noindex">
<link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" />
<link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" />
<link rel="canonical" href="https://codepen.io/tobydennison/pen/azZroz" />
<style class="cp-pen-styles">/**
* BxSlider v4.1.2 - Fully loaded,
responsive content slider
* http://bxslider.com
*
* Written by: Steven Wanderski, 2014
* http://stevenwanderski.com
* (while drinking Belgian ales and
listening to jazz)
*
* CEO and founder of bxCreative, LTD
* http://bxcreative.com
*/
/** RESET AND LAYOUT
===================================*/
.bx-wrapper {
position: relative;
margin: 0 auto 60px;
padding: 0;
*zoom: 1;
}
.bx-wrapper img {
max-width: 100%;
display: block;
}
/** THEME
===================================*/
/* Uncomment by Default = Border + Drop
Shadow. */
/* .bx-wrapper .bx-viewport {
-moz-box-shadow: 0 0 5px #ccc;
-webkit-box-shadow: 0 0 5px #ccc;
box-shadow: 0 0 5px #ccc;
border:
5px solid #fff;
left: -5px;
background: #fff; */
/*fix other elements on the page moving
(on Chrome)*/
-webkit-transform: translatez(0);
-moz-transform: translatez(0);
-ms-transform: translatez(0);
-o-transform: translatez(0);
transform: translatez(0);
}
.bx-wrapper .bx-pager,
.bx-wrapper .bx-controls-auto {
position: absolute;
bottom: -30px;
width: 100%;
}
/* LOADER */
.bx-wrapper .bx-loading {
min-height: 50px;
background:
url("http://bxslider.com/lib/images/bx_loader.gif") center center
no-repeat #fff;
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 2000;
}
/* PAGER */
.bx-wrapper .bx-pager {
text-align: center;
font-size: .85em;
font-family: Arial;
font-weight: bold;
color: #666;
padding-top: 20px;
}
.bx-wrapper .bx-pager .bx-pager-item,
.bx-wrapper .bx-controls-auto
.bx-controls-auto-item {
display: inline-block;
*zoom: 1;
*display: inline;
}
.bx-wrapper .bx-pager.bx-default-pager
a {
background: #666;
text-indent: -9999px;
display: block;
width: 10px;
height: 10px;
margin: 0 5px;
outline: 0;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
}
.bx-wrapper .bx-pager.bx-default-pager
a:hover,
.bx-wrapper .bx-pager.bx-default-pager
a.active {
background: #000;
}
/* DIRECTION CONTROLS (NEXT / PREV) */
.bx-wrapper .bx-prev {
left: 10px;
background: url("http://bxslider.com/lib/images/controls.png")
no-repeat 0 -32px;
}
.bx-wrapper .bx-next {
right: 10px;
background:
url("http://bxslider.com/lib/images/controls.png") no-repeat -43px
-32px;
}
.bx-wrapper .bx-prev:hover {
background-position: 0 0;
}
.bx-wrapper .bx-next:hover {
background-position: -43px 0;
}
.bx-wrapper .bx-controls-direction a {
position: absolute;
top: 50%;
margin-top: -16px;
outline: 0;
width: 32px;
height: 32px;
text-indent: -9999px;
z-index: 9999;
}
.bx-wrapper .bx-controls-direction
a.disabled {
display: none;
}
/* AUTO CONTROLS (START / STOP) */
.bx-wrapper .bx-controls-auto {
text-align: center;
}
.bx-wrapper .bx-controls-auto .bx-start
{
display: block;
text-indent: -9999px;
width: 10px;
height: 11px;
outline: 0;
background:
url("http://bxslider.com/lib/images/controls.png") -86px -11px
no-repeat;
margin: 0 3px;
}
.bx-wrapper .bx-controls-auto
.bx-start:hover,
.bx-wrapper .bx-controls-auto
.bx-start.active {
background-position: -86px 0;
}
.bx-wrapper .bx-controls-auto .bx-stop
{
display: block;
text-indent: -9999px;
width: 9px;
height: 11px;
outline: 0;
background:
url("http://bxslider.com/lib/images/controls.png") -86px -44px
no-repeat;
margin: 0 3px;
}
.bx-wrapper .bx-controls-auto .bx-stop:hover,
.bx-wrapper .bx-controls-auto
.bx-stop.active {
background-position: -86px -33px;
}
/* PAGER WITH AUTO-CONTROLS HYBRID
LAYOUT */
.bx-wrapper
.bx-controls.bx-has-controls-auto.bx-has-pager .bx-pager {
text-align: left;
width: 10%; /* DEFAULT: 80% !!! */
}
.bx-wrapper
.bx-controls.bx-has-controls-auto.bx-has-pager .bx-controls-auto {
right: 0;
width: 35px;
}
/* IMAGE CAPTIONS */
.bx-wrapper .bx-caption {
position: absolute;
bottom: 0;
left: 0;
background: #666\9;
background: rgba(80, 80, 80, 0.75);
width: 100%;
}
.bx-wrapper .bx-caption span {
color: #fff;
font-family: Arial;
display: block;
font-size: .85em;
padding: 10px;
}
/* My CSS for bxSlider */
.bx-wrapper {
width: 1199px;
margin-left: 142px;
margin-top: -24px;
padding: 0px;
}
.bx-wrapper img {
margin-top: 0px;
height: 300px;
width: 100%
}
div.bx-pager.bx-default-pager {
margin-left: 533px;
margin-bottom: -17.5px; /* Play + Pause
*/
margin-top: -12.5px; /* Play + Pause +
Dots */
}
/* My CSS for Others */
body {
background-color: #f9f9f9;
margin-top: 8px;
}
@import
url('http://fonts.googleapis.com/css?family=Open+Sans');
/*http://www.google.com/fonts/specimen/Open+Sans*/
#menu ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 150px;
height: 768px;
background-color: #033671;
margin-top: -367px;
margin-left: -8px;
padding: 17.5px 0 17.5px 0;
}
#menu > ul > li {
text-decoration: none;
color: #fff;
font-family: 'Open Sans', sans-serif;
margin-left: 32.5px;
margin-top: 10px;
}
#home-content {
margin-top: -495px;
width: 1000px;
margin-left: 205px;
}
#home-content > div > h1 {
font-family: 'Open Sans', sans-serif;
font-weight: 600; /* Open Sans
Semi-Bold */
font-size: 32px;
color: #1b1b1b;
text-align: center;
}
#home-content > div > h1 > p {
font-family: 'Open Sans', sans-serif;
font-weight: 300; /* Open Sans Light */
font-size: 24px;
color: #1b1b1b;
text-align: justify;
margin-left: 99.5px; /* (1199-1000) / 2
= 99.5 */
}</style></head><body>
<html>
<head>
<!-- jQuery library (served from
Google) -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<!-- bxSlider Javascript file -->
<script
src="/js/jquery.bxslider.min.js"></script>
<!-- bxSlider CSS file -->
<link
href="/lib/jquery.bxslider.css" rel="stylesheet"/>
</head>
<body>
<ul class="bxslider">
<li><img
src="http://i.imgur.com/tNozFm3.png"/></li>
<li><img
src="http://i.imgur.com/95kZRTk.png"/></li>
<li><img
src="http://i.imgur.com/gtH2qzj.png"/></li>
</ul>
<div id="menu">
<ul>
<li><a
href="#"></a>A Casa Mia</li>
<li><a
href="#"></a>My Work</li>
<li><a
href="#"></a>My Process</li>
<li><a
href="#"></a>About Me</li>
<li><a
href="#"></a>My Journal</li>
<li><a
href="#"></a>Contact Me</li>
</ul>
</div>
<div id="home-content">
<div class="home-text">
<h1>Welcome</hl>
<p>Hello, I'm Toby, and this is
my site. I'm currently a 16 year old student at college. I have a keen interest
for design and programming. Aside from that, I love to play the piano and
further my learning of languages: English, Spanish and Italian.</p>
</div>
</div>
</body>
</html>
<script
src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script>
<script
src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script>$(document).ready(function(){
$('.bxslider').bxSlider({
auto: true,
autoControls: true
});
});
$('button').click(function() {
var toAdd =
$("input[name=message]").val();
$('#messages').append("<p>"+toAdd+"</p>");
});
/**
* BxSlider v4.1.2 - Fully loaded,
responsive content slider
* http://bxslider.com
*
* Copyright 2014, Steven Wanderski -
http://stevenwanderski.com - http://bxcreative.com
* Written while drinking Belgian ales
and listening to jazz
*
* Released under the MIT license -
http://opensource.org/licenses/MIT
*/
;(function($){
var plugin = {};
var defaults = {
// GENERAL
mode: 'horizontal',
slideSelector: '',
infiniteLoop: true,
hideControlOnEnd: false,
speed: 500,
easing: null,
slideMargin: 0,
startSlide: 0,
randomStart: false,
captions: false,
ticker: false,
tickerHover: false,
adaptiveHeight: false,
adaptiveHeightSpeed: 500,
video: false,
useCSS: true,
preloadImages: 'visible',
responsive: true,
slideZIndex: 50,
wrapperClass: 'bx-wrapper',
// TOUCH
touchEnabled: true,
swipeThreshold: 50,
oneToOneTouch: true,
preventDefaultSwipeX: true,
preventDefaultSwipeY: false,
// PAGER
pager: true,
pagerType: 'full',
pagerShortSeparator: ' / ',
pagerSelector: null,
buildPager: null,
pagerCustom: null,
// CONTROLS
controls: true,
nextText: 'Next',
prevText: 'Prev',
nextSelector: null,
prevSelector: null,
autoControls: false,
startText: 'Start',
stopText: 'Stop',
autoControlsCombine: false,
autoControlsSelector: null,
// AUTO
auto: false,
pause: 4000,
autoStart: true,
autoDirection: 'next',
autoHover: false,
autoDelay: 0,
autoSlideForOnePage: false,
// CAROUSEL
minSlides: 1,
maxSlides: 1,
moveSlides: 0,
slideWidth: 0,
// CALLBACKS
onSliderLoad: function() {},
onSlideBefore: function() {},
onSlideAfter: function() {},
onSlideNext: function() {},
onSlidePrev: function() {},
onSliderResize: function() {}
}
$.fn.bxSlider = function(options){
if(this.length == 0) return this;
// support mutltiple elements
if(this.length > 1){
this.each(function(){$(this).bxSlider(options)});
return this;
}
// create a namespace to be used
throughout the plugin
var slider = {};
// set a reference to our slider
element
var el = this;
plugin.el = this;
/**
* Makes slideshow responsive
*/
// first get the original window dimens
(thanks alot IE)
var windowWidth = $(window).width();
var windowHeight = $(window).height();
/**
*
===================================================================================
* = PRIVATE FUNCTIONS
*
===================================================================================
*/
/**
* Initializes namespace settings to be
used throughout plugin
*/
var init = function(){
// merge user-supplied options with the
defaults
slider.settings = $.extend({},
defaults, options);
// parse slideWidth setting
slider.settings.slideWidth =
parseInt(slider.settings.slideWidth);
// store the original children
slider.children =
el.children(slider.settings.slideSelector);
// check if actual number of slides is
less than minSlides / maxSlides
if(slider.children.length <
slider.settings.minSlides) slider.settings.minSlides = slider.children.length;
if(slider.children.length <
slider.settings.maxSlides) slider.settings.maxSlides = slider.children.length;
// if random start, set the startSlide
setting to random number
if(slider.settings.randomStart)
slider.settings.startSlide = Math.floor(Math.random() *
slider.children.length);
// store active slide information
slider.active = { index:
slider.settings.startSlide }
// store if the slider is in carousel
mode (displaying / moving multiple slides)
slider.carousel =
slider.settings.minSlides > 1 || slider.settings.maxSlides > 1;
// if carousel, force preloadImages =
'all'
if(slider.carousel)
slider.settings.preloadImages = 'all';
// calculate the min / max width
thresholds based on min / max number of slides
// used to setup and update carousel
slides dimensions
slider.minThreshold =
(slider.settings.minSlides * slider.settings.slideWidth) +
((slider.settings.minSlides - 1) * slider.settings.slideMargin);
slider.maxThreshold = (slider.settings.maxSlides
* slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) *
slider.settings.slideMargin);
// store the current state of the
slider (if currently animating, working is true)
slider.working = false;
// initialize the controls object
slider.controls = {};
// initialize an auto interval
slider.interval = null;
// determine which property to use for
transitions
slider.animProp = slider.settings.mode
== 'vertical' ? 'top' : 'left';
// determine if hardware acceleration
can be used
slider.usingCSS =
slider.settings.useCSS && slider.settings.mode != 'fade' &&
(function(){
// create our test div element
var div =
document.createElement('div');
// css transition properties
var props = ['WebkitPerspective',
'MozPerspective', 'OPerspective', 'msPerspective'];
// test for each property
for(var i in props){
if(div.style[props[i]] !== undefined){
slider.cssPrefix =
props[i].replace('Perspective', '').toLowerCase();
slider.animProp = '-' +
slider.cssPrefix + '-transform';
return true;
}
}
return false;
}());
// if vertical mode always make
maxSlides and minSlides equal
if(slider.settings.mode == 'vertical')
slider.settings.maxSlides = slider.settings.minSlides;
// save original style data
el.data("origStyle",
el.attr("style"));
el.children(slider.settings.slideSelector).each(function()
{
$(this).data("origStyle",
$(this).attr("style"));
});
// perform all DOM / CSS modifications
setup();
}
/**
* Performs all DOM and CSS
modifications
*/
var setup = function(){
// wrap el in a wrapper
el.wrap('<div class="' +
slider.settings.wrapperClass + '"><div
class="bx-viewport"></div></div>');
// store a namspace reference to
.bx-viewport
slider.viewport = el.parent();
// add a loading div to display while
images are loading
slider.loader = $('<div
class="bx-loading" />');
slider.viewport.prepend(slider.loader);
// set el to a massive width, to hold
any needed slides
// also strip any margin and padding
from el
el.css({
width: slider.settings.mode ==
'horizontal' ? (slider.children.length * 100 + 215) + '%' : 'auto',
position: 'relative'
});
// if using CSS, add the easing
property
if(slider.usingCSS &&
slider.settings.easing){
el.css('-' + slider.cssPrefix +
'-transition-timing-function', slider.settings.easing);
// if not using CSS and no easing value
was supplied, use the default JS animation easing (swing)
}else if(!slider.settings.easing){
slider.settings.easing = 'swing';
}
var slidesShowing =
getNumberSlidesShowing();
// make modifications to the viewport
(.bx-viewport)
slider.viewport.css({
width: '100%',
overflow: 'hidden',
position: 'relative'
});
slider.viewport.parent().css({
maxWidth: getViewportMaxWidth()
});
// make modification to the wrapper
(.bx-wrapper)
if(!slider.settings.pager) {
slider.viewport.parent().css({
margin: '0 auto 0px'
});
}
// apply css to all slider children
slider.children.css({
'float': slider.settings.mode ==
'horizontal' ? 'left' : 'none',
listStyle: 'none',
position: 'relative'
});
// apply the calculated width after the
float is applied to prevent scrollbar interference
slider.children.css('width',
getSlideWidth());
// if slideMargin is supplied, add the
css
if(slider.settings.mode == 'horizontal'
&& slider.settings.slideMargin > 0)
slider.children.css('marginRight', slider.settings.slideMargin);
if(slider.settings.mode == 'vertical'
&& slider.settings.slideMargin > 0)
slider.children.css('marginBottom', slider.settings.slideMargin);
// if "fade" mode, add
positioning and z-index CSS
if(slider.settings.mode == 'fade'){
slider.children.css({
position: 'absolute',
zIndex: 0,
display: 'none'
});
// prepare the z-index on the showing
element
slider.children.eq(slider.settings.startSlide).css({zIndex:
slider.settings.slideZIndex, display: 'block'});
}
// create an element to contain all
slider controls (pager, start / stop, etc)
slider.controls.el = $('<div
class="bx-controls" />');
// if captions are requested, add them
if(slider.settings.captions)
appendCaptions();
// check if startSlide is last slide
slider.active.last =
slider.settings.startSlide == getPagerQty() - 1;
// if video is true, set up the fitVids
plugin
if(slider.settings.video) el.fitVids();
// set the default preload selector
(visible)
var preloadSelector =
slider.children.eq(slider.settings.startSlide);
if (slider.settings.preloadImages ==
"all") preloadSelector = slider.children;
// only check for control addition if
not in "ticker" mode
if(!slider.settings.ticker){
// if pager is requested, add it
if(slider.settings.pager) appendPager();
// if controls are requested, add them
if(slider.settings.controls)
appendControls();
// if auto is true, and auto controls
are requested, add them
if(slider.settings.auto &&
slider.settings.autoControls) appendControlsAuto();
// if any control option is requested,
add the controls wrapper
if(slider.settings.controls ||
slider.settings.autoControls || slider.settings.pager)
slider.viewport.after(slider.controls.el);
// if ticker mode, do not allow a pager
}else{
slider.settings.pager = false;
}
// preload all images, then perform
final DOM / CSS modifications that depend on images being loaded
loadElements(preloadSelector, start);
}
var loadElements = function(selector,
callback){
var total = selector.find('img,
iframe').length;
if (total == 0){
callback();
return;
}
var count = 0;
selector.find('img,
iframe').each(function(){
$(this).one('load', function() {
if(++count == total) callback();
}).each(function() {
if(this.complete) $(this).load();
});
});
}
/**
* Start the slider
*/
var start = function(){
// if infinite loop, prepare additional
slides
if(slider.settings.infiniteLoop
&& slider.settings.mode != 'fade' && !slider.settings.ticker){
var slice = slider.settings.mode ==
'vertical' ? slider.settings.minSlides : slider.settings.maxSlides;
var sliceAppend =
slider.children.slice(0, slice).clone().addClass('bx-clone');
var slicePrepend =
slider.children.slice(-slice).clone().addClass('bx-clone');
el.append(sliceAppend).prepend(slicePrepend);
}
// remove the loading DOM element
slider.loader.remove();
// set the left / top position of
"el"
setSlidePosition();
// if "vertical" mode, always
use adaptiveHeight to prevent odd behavior
if (slider.settings.mode == 'vertical')
slider.settings.adaptiveHeight = true;
// set the viewport height
slider.viewport.height(getViewportHeight());
// make sure everything is positioned
just right (same as a window resize)
el.redrawSlider();
// onSliderLoad callback
slider.settings.onSliderLoad(slider.active.index);
// slider has been fully initialized
slider.initialized = true;
// bind the resize call to the window
if (slider.settings.responsive)
$(window).bind('resize', resizeWindow);
// if auto is true and has more than 1
page, start the show
if (slider.settings.auto &&
slider.settings.autoStart && (getPagerQty() > 1 ||
slider.settings.autoSlideForOnePage)) initAuto();
// if ticker is true, start the ticker
if (slider.settings.ticker)
initTicker();
// if pager is requested, make the
appropriate pager link active
if (slider.settings.pager) updatePagerActive(slider.settings.startSlide);
// check for any updates to the
controls (like hideControlOnEnd updates)
if (slider.settings.controls)
updateDirectionControls();
// if touchEnabled is true, setup the
touch events
if (slider.settings.touchEnabled
&& !slider.settings.ticker) initTouch();
}
/**
* Returns the calculated height of the
viewport, used to determine either adaptiveHeight or the maxHeight value
*/
var getViewportHeight = function(){
var height = 0;
// first determine which children
(slides) should be used in our height calculation
var children = $();
// if mode is not "vertical"
and adaptiveHeight is false, include all children
if(slider.settings.mode != 'vertical'
&& !slider.settings.adaptiveHeight){
children = slider.children;
}else{
// if not carousel, return the single
active child
if(!slider.carousel){
children =
slider.children.eq(slider.active.index);
// if carousel, return a slice of
children
}else{
// get the individual slide index
var currentIndex =
slider.settings.moveSlides == 1 ? slider.active.index : slider.active.index *
getMoveBy();
// add the current slide to the
children
children =
slider.children.eq(currentIndex);
// cycle through the remaining
"showing" slides
for (i = 1; i <= slider.settings.maxSlides
- 1; i++){
// if looped back to the start
if(currentIndex + i >=
slider.children.length){
children =
children.add(slider.children.eq(i - 1));
}else{
children =
children.add(slider.children.eq(currentIndex + i));
}
}
}
}
// if "vertical" mode,
calculate the sum of the heights of the children
if(slider.settings.mode == 'vertical'){
children.each(function(index) {
height += $(this).outerHeight();
});
// add user-supplied margins
if(slider.settings.slideMargin > 0){
height += slider.settings.slideMargin *
(slider.settings.minSlides - 1);
}
// if not "vertical" mode,
calculate the max height of the children
}else{
height = Math.max.apply(Math,
children.map(function(){
return $(this).outerHeight(false);
}).get());
}
if(slider.viewport.css('box-sizing') ==
'border-box'){
height +=
parseFloat(slider.viewport.css('padding-top')) +
parseFloat(slider.viewport.css('padding-bottom')) +
parseFloat(slider.viewport.css('border-top-width'))
+ parseFloat(slider.viewport.css('border-bottom-width'));
}else
if(slider.viewport.css('box-sizing') == 'padding-box'){
height +=
parseFloat(slider.viewport.css('padding-top')) +
parseFloat(slider.viewport.css('padding-bottom'));
}
return height;
}
/**
* Returns the calculated width to be
used for the outer wrapper / viewport
*/
var getViewportMaxWidth = function(){
var width = '100%';
if(slider.settings.slideWidth > 0){
if(slider.settings.mode ==
'horizontal'){
width = (slider.settings.maxSlides *
slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) *
slider.settings.slideMargin);
}else{
width = slider.settings.slideWidth;
}
}
return width;
}
/**
* Returns the calculated width to be
applied to each slide
*/
var getSlideWidth = function(){
// start with any user-supplied slide
width
var newElWidth =
slider.settings.slideWidth;
// get the current viewport width
var wrapWidth =
slider.viewport.width();
// if slide width was not supplied, or
is larger than the viewport use the viewport width
if(slider.settings.slideWidth == 0 ||
(slider.settings.slideWidth >
wrapWidth && !slider.carousel) ||
slider.settings.mode == 'vertical'){
newElWidth = wrapWidth;
// if carousel, use the thresholds to
determine the width
}else if(slider.settings.maxSlides >
1 && slider.settings.mode == 'horizontal'){
if(wrapWidth > slider.maxThreshold){
// newElWidth = (wrapWidth -
(slider.settings.slideMargin * (slider.settings.maxSlides - 1))) /
slider.settings.maxSlides;
}else if(wrapWidth <
slider.minThreshold){
newElWidth = (wrapWidth -
(slider.settings.slideMargin * (slider.settings.minSlides - 1))) /
slider.settings.minSlides;
}
}
return newElWidth;
}
/**
* Returns the number of slides
currently visible in the viewport (includes partially visible slides)
*/
var getNumberSlidesShowing =
function(){
var slidesShowing = 1;
if(slider.settings.mode == 'horizontal'
&& slider.settings.slideWidth > 0){
// if viewport is smaller than
minThreshold, return minSlides
if(slider.viewport.width() <
slider.minThreshold){
slidesShowing =
slider.settings.minSlides;
// if viewport is larger than
minThreshold, return maxSlides
}else if(slider.viewport.width() >
slider.maxThreshold){
slidesShowing =
slider.settings.maxSlides;
// if viewport is between min / max
thresholds, divide viewport width by first child width
}else{
var childWidth =
slider.children.first().width() + slider.settings.slideMargin;
slidesShowing =
Math.floor((slider.viewport.width() +
slider.settings.slideMargin) /
childWidth);
}
// if "vertical" mode, slides
showing will always be minSlides
}else if(slider.settings.mode ==
'vertical'){
slidesShowing =
slider.settings.minSlides;
}
return slidesShowing;
}
/**
* Returns the number of pages (one full
viewport of slides is one "page")
*/
var getPagerQty = function(){
var pagerQty = 0;
// if moveSlides is specified by the
user
if(slider.settings.moveSlides > 0){
if(slider.settings.infiniteLoop){
pagerQty =
Math.ceil(slider.children.length / getMoveBy());
}else{
// use a while loop to determine pages
var breakPoint = 0;
var counter = 0
// when breakpoint goes above children
length, counter is the number of pages
while (breakPoint <
slider.children.length){
++pagerQty;
breakPoint = counter +
getNumberSlidesShowing();
counter += slider.settings.moveSlides
<= getNumberSlidesShowing() ? slider.settings.moveSlides :
getNumberSlidesShowing();
}
}
// if moveSlides is 0 (auto) divide
children length by sides showing, then round up
}else{
pagerQty =
Math.ceil(slider.children.length / getNumberSlidesShowing());
}
return pagerQty;
}
/**
* Returns the number of indivual slides
by which to shift the slider
*/
var getMoveBy = function(){
// if moveSlides was set by the user
and moveSlides is less than number of slides showing
if(slider.settings.moveSlides > 0
&& slider.settings.moveSlides <= getNumberSlidesShowing()){
return slider.settings.moveSlides;
}
// if moveSlides is 0 (auto)
return getNumberSlidesShowing();
}
/**
* Sets the slider's (el) left or top
position
*/
var setSlidePosition = function(){
// if last slide, not infinite loop,
and number of children is larger than specified maxSlides
if(slider.children.length >
slider.settings.maxSlides && slider.active.last &&
!slider.settings.infiniteLoop){
if (slider.settings.mode ==
'horizontal'){
// get the last child's position
var lastChild = slider.children.last();
var position = lastChild.position();
// set the left position
setPositionProperty(-(position.left -
(slider.viewport.width() - lastChild.outerWidth())), 'reset', 0);
}else if(slider.settings.mode ==
'vertical'){
// get the last showing index's
position
var lastShowingIndex =
slider.children.length - slider.settings.minSlides;
var position =
slider.children.eq(lastShowingIndex).position();
// set the top position
setPositionProperty(-position.top,
'reset', 0);
}
// if not last slide
}else{
// get the position of the first
showing slide
var position =
slider.children.eq(slider.active.index * getMoveBy()).position();
// check for last slide
if (slider.active.index ==
getPagerQty() - 1) slider.active.last = true;
// set the repective position
if (position != undefined){
if (slider.settings.mode ==
'horizontal') setPositionProperty(-position.left, 'reset', 0);
else if (slider.settings.mode ==
'vertical') setPositionProperty(-position.top, 'reset', 0);
}
}
}
/**
* Sets the el's animating property
position (which in turn will sometimes animate el).
* If using CSS, sets the transform
property. If not using CSS, sets the top / left property.
*
* @param value (int)
*
- the animating property's value
*
* @param type (string) 'slider',
'reset', 'ticker'
*
- the type of instance for which the function is being
*
* @param duration (int)
*
- the amount of time (in ms) the transition should occupy
*
* @param params (array) optional
*
- an optional parameter containing any variables that need to be passed
in
*/
var setPositionProperty =
function(value, type, duration, params){
// use CSS transform
if(slider.usingCSS){
// determine the translate3d value
var propValue = slider.settings.mode ==
'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value +
'px, 0, 0)';
// add the CSS transition-duration
el.css('-' + slider.cssPrefix +
'-transition-duration', duration / 1000 + 's');
if(type == 'slide'){
// set the property value
el.css(slider.animProp, propValue);
// bind a callback method - executes
when CSS transition completes
el.bind('transitionend
webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
// unbind the callback
el.unbind('transitionend
webkitTransitionEnd oTransitionEnd MSTransitionEnd');
updateAfterSlideTransition();
});
}else if(type == 'reset'){
el.css(slider.animProp, propValue);
}else if(type == 'ticker'){
// make the transition use 'linear'
el.css('-' + slider.cssPrefix +
'-transition-timing-function', 'linear');
el.css(slider.animProp, propValue);
// bind a callback method - executes
when CSS transition completes
el.bind('transitionend
webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
// unbind the callback
el.unbind('transitionend
webkitTransitionEnd oTransitionEnd MSTransitionEnd');
// reset the position
setPositionProperty(params['resetValue'],
'reset', 0);
// start the loop again
tickerLoop();
});
}
// use JS animate
}else{
var animateObj = {};
animateObj[slider.animProp] = value;
if(type == 'slide'){
el.animate(animateObj, duration,
slider.settings.easing, function(){
updateAfterSlideTransition();
});
}else if(type == 'reset'){
el.css(slider.animProp, value)
}else if(type == 'ticker'){
el.animate(animateObj, speed, 'linear',
function(){
setPositionProperty(params['resetValue'],
'reset', 0);
// run the recursive loop after
animation
tickerLoop();
});
}
}
}
/**
* Populates the pager with proper
amount of pages
*/
var populatePager = function(){
var pagerHtml = '';
var pagerQty = getPagerQty();
// loop through each pager item
for(var i=0; i < pagerQty; i++){
var linkContent = '';
// if a buildPager function is
supplied, use it to get pager link value, else use index + 1
if(slider.settings.buildPager
&& $.isFunction(slider.settings.buildPager)){
linkContent =
slider.settings.buildPager(i);
slider.pagerEl.addClass('bx-custom-pager');
}else{
linkContent = i + 1;
slider.pagerEl.addClass('bx-default-pager');
}
// var linkContent =
slider.settings.buildPager && $.isFunction(slider.settings.buildPager)
? slider.settings.buildPager(i) : i + 1;
// add the markup to the string
pagerHtml += '<div
class="bx-pager-item"><a href=""
data-slide-index="' + i + '" class="bx-pager-link">' +
linkContent + '</a></div>';
};
// populate the pager element with
pager links
slider.pagerEl.html(pagerHtml);
}
/**
* Appends the pager to the controls
element
*/
var appendPager = function(){
if(!slider.settings.pagerCustom){
// create the pager DOM element
slider.pagerEl = $('<div
class="bx-pager" />');
// if a pager selector was supplied,
populate it with the pager
if(slider.settings.pagerSelector){
$(slider.settings.pagerSelector).html(slider.pagerEl);
// if no pager selector was supplied,
add it after the wrapper
}else{
slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl);
}
// populate the pager
populatePager();
}else{
slider.pagerEl =
$(slider.settings.pagerCustom);
}
// assign the pager click binding
slider.pagerEl.on('click', 'a',
clickPagerBind);
}
/**
* Appends prev / next controls to the
controls element
*/
var appendControls = function(){
slider.controls.next = $('<a
class="bx-next" href="">' + slider.settings.nextText +
'</a>');
slider.controls.prev = $('<a
class="bx-prev" href="">' + slider.settings.prevText +
'</a>');
// bind click actions to the controls
slider.controls.next.bind('click',
clickNextBind);
slider.controls.prev.bind('click',
clickPrevBind);
// if nextSlector was supplied,
populate it
if(slider.settings.nextSelector){
$(slider.settings.nextSelector).append(slider.controls.next);
}
// if prevSlector was supplied,
populate it
if(slider.settings.prevSelector){
$(slider.settings.prevSelector).append(slider.controls.prev);
}
// if no custom selectors were supplied
if(!slider.settings.nextSelector
&& !slider.settings.prevSelector){
// add the controls to the DOM
slider.controls.directionEl =
$('<div class="bx-controls-direction" />');
// add the control elements to the
directionEl
slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next);
//
slider.viewport.append(slider.controls.directionEl);
slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl);
}
}
/**
* Appends start / stop auto controls to
the controls element
*/
var appendControlsAuto = function(){
slider.controls.start = $('<div
class="bx-controls-auto-item"><a class="bx-start"
href="">' + slider.settings.startText + '</a></div>');
slider.controls.stop = $('<div
class="bx-controls-auto-item"><a class="bx-stop"
href="">' + slider.settings.stopText + '</a></div>');
// add the controls to the DOM
slider.controls.autoEl = $('<div
class="bx-controls-auto" />');
// bind click actions to the controls
slider.controls.autoEl.on('click',
'.bx-start', clickStartBind);
slider.controls.autoEl.on('click',
'.bx-stop', clickStopBind);
// if autoControlsCombine, insert only
the "start" control
if(slider.settings.autoControlsCombine){
slider.controls.autoEl.append(slider.controls.start);
// if autoControlsCombine is false,
insert both controls
}else{
slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop);
}
// if auto controls selector was
supplied, populate it with the controls
if(slider.settings.autoControlsSelector){
$(slider.settings.autoControlsSelector).html(slider.controls.autoEl);
// if auto controls selector was not
supplied, add it after the wrapper
}else{
slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl);
}
// update the auto controls
updateAutoControls(slider.settings.autoStart
? 'stop' : 'start');
}
/**
* Appends image captions to the DOM
*/
var appendCaptions = function(){
// cycle through each child
slider.children.each(function(index){
// get the image title attribute
var title =
$(this).find('img:first').attr('title');
// append the caption
if (title != undefined && ('' +
title).length) {
$(this).append('<div
class="bx-caption"><span>' + title +
'</span></div>');
}
});
}
/**
* Click next binding
*
* @param e (event)
*
- DOM event object
*/
var clickNextBind = function(e){
// if auto show is running, stop it
if (slider.settings.auto)
el.stopAuto();
el.goToNextSlide();
e.preventDefault();
}
/**
* Click prev binding
*
* @param e (event)
*
- DOM event object
*/
var clickPrevBind = function(e){
// if auto show is running, stop it
if (slider.settings.auto)
el.stopAuto();
el.goToPrevSlide();
e.preventDefault();
}
/**
* Click start binding
*
* @param e (event)
*
- DOM event object
*/
var clickStartBind = function(e){
el.startAuto();
e.preventDefault();
}
/**
* Click stop binding
*
* @param e (event)
*
- DOM event object
*/
var clickStopBind = function(e){
el.stopAuto();
e.preventDefault();
}
/**
* Click pager binding
*
* @param e (event)
*
- DOM event object
*/
var clickPagerBind = function(e){
// if auto show is running, stop it
if (slider.settings.auto)
el.stopAuto();
var pagerLink = $(e.currentTarget);
if(pagerLink.attr('data-slide-index')
!== undefined){
var pagerIndex =
parseInt(pagerLink.attr('data-slide-index'));
// if clicked pager link is not active,
continue with the goToSlide call
if(pagerIndex != slider.active.index)
el.goToSlide(pagerIndex);
e.preventDefault();
}
}
/**
* Updates the pager links with an
active class
*
* @param slideIndex (int)
*
- index of slide to make active
*/
var updatePagerActive =
function(slideIndex){
// if "short" pager type
var len = slider.children.length; // nb
of children
if(slider.settings.pagerType ==
'short'){
if(slider.settings.maxSlides > 1) {
len =
Math.ceil(slider.children.length/slider.settings.maxSlides);
}
slider.pagerEl.html( (slideIndex + 1) +
slider.settings.pagerShortSeparator + len);
return;
}
// remove all pager active classes
slider.pagerEl.find('a').removeClass('active');
// apply the active class for all
pagers
slider.pagerEl.each(function(i, el) {
$(el).find('a').eq(slideIndex).addClass('active'); });
}
/**
* Performs needed actions after a slide
transition
*/
var updateAfterSlideTransition =
function(){
// if infinte loop is true
if(slider.settings.infiniteLoop){
var position = '';
// first slide
if(slider.active.index == 0){
// set the new position
position =
slider.children.eq(0).position();
// carousel, last slide
}else if(slider.active.index ==
getPagerQty() - 1 && slider.carousel){
position =
slider.children.eq((getPagerQty() - 1) * getMoveBy()).position();
// last slide
}else if(slider.active.index ==
slider.children.length - 1){
position = slider.children.eq(slider.children.length
- 1).position();
}
if(position){
if (slider.settings.mode ==
'horizontal') { setPositionProperty(-position.left, 'reset', 0); }
else if (slider.settings.mode ==
'vertical') { setPositionProperty(-position.top, 'reset', 0); }
}
}
// declare that the transition is
complete
slider.working = false;
// onSlideAfter callback
slider.settings.onSlideAfter(slider.children.eq(slider.active.index),
slider.oldIndex, slider.active.index);
}
/**
* Updates the auto controls state
(either active, or combined switch)
*
* @param state (string)
"start", "stop"
*
- the new state of the auto show
*/
var updateAutoControls =
function(state){
// if autoControlsCombine is true,
replace the current control with the new state
if(slider.settings.autoControlsCombine){
slider.controls.autoEl.html(slider.controls[state]);
// if autoControlsCombine is false,
apply the "active" class to the appropriate control
}else{
slider.controls.autoEl.find('a').removeClass('active');
slider.controls.autoEl.find('a:not(.bx-'
+ state + ')').addClass('active');
}
}
/**
* Updates the direction controls
(checks if either should be hidden)
*/
var updateDirectionControls =
function(){
if(getPagerQty() == 1){
slider.controls.prev.addClass('disabled');
slider.controls.next.addClass('disabled');
}else if(!slider.settings.infiniteLoop
&& slider.settings.hideControlOnEnd){
// if first slide
if (slider.active.index == 0){
slider.controls.prev.addClass('disabled');
slider.controls.next.removeClass('disabled');
// if last slide
}else if(slider.active.index ==
getPagerQty() - 1){
slider.controls.next.addClass('disabled');
slider.controls.prev.removeClass('disabled');
// if any slide in the middle
}else{
slider.controls.prev.removeClass('disabled');
slider.controls.next.removeClass('disabled');
}
}
}
/**
* Initialzes the auto process
*/
var initAuto = function(){
// if autoDelay was supplied, launch
the auto show using a setTimeout() call
if(slider.settings.autoDelay > 0){
var timeout = setTimeout(el.startAuto,
slider.settings.autoDelay);
// if autoDelay was not supplied, start
the auto show normally
}else{
el.startAuto();
}
// if autoHover is requested
if(slider.settings.autoHover){
// on el hover
el.hover(function(){
// if the auto show is currently
playing (has an active interval)
if(slider.interval){
// stop the auto show and pass true
agument which will prevent control update
el.stopAuto(true);
// create a new autoPaused value which
will be used by the relative "mouseout" event
slider.autoPaused = true;
}
}, function(){
// if the autoPaused value was created
be the prior "mouseover" event
if(slider.autoPaused){
// start the auto show and pass true
agument which will prevent control update
el.startAuto(true);
// reset the autoPaused value
slider.autoPaused = null;
}
});
}
}
/**
* Initialzes the ticker process
*/
var initTicker = function(){
var startPosition = 0;
// if autoDirection is
"next", append a clone of the entire slider
if(slider.settings.autoDirection ==
'next'){
el.append(slider.children.clone().addClass('bx-clone'));
// if autoDirection is
"prev", prepend a clone of the entire slider, and set the left
position
}else{
el.prepend(slider.children.clone().addClass('bx-clone'));
var position =
slider.children.first().position();
startPosition = slider.settings.mode ==
'horizontal' ? -position.left : -position.top;
}
setPositionProperty(startPosition,
'reset', 0);
// do not allow controls in ticker mode
slider.settings.pager = false;
slider.settings.controls = false;
slider.settings.autoControls = false;
// if autoHover is requested
if(slider.settings.tickerHover
&& !slider.usingCSS){
// on el hover
slider.viewport.hover(function(){
el.stop();
}, function(){
// calculate the total width of
children (used to calculate the speed ratio)
var totalDimens = 0;
slider.children.each(function(index){
totalDimens += slider.settings.mode ==
'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
});
// calculate the speed ratio (used to
determine the new speed to finish the paused animation)
var ratio = slider.settings.speed /
totalDimens;
// determine which property to use
var property = slider.settings.mode ==
'horizontal' ? 'left' : 'top';
// calculate the new speed
var newSpeed = ratio * (totalDimens -
(Math.abs(parseInt(el.css(property)))));
tickerLoop(newSpeed);
});
}
// start the ticker loop
tickerLoop();
}
/**
* Runs a continuous loop, news
ticker-style
*/
var tickerLoop = function(resumeSpeed){
speed = resumeSpeed ? resumeSpeed :
slider.settings.speed;
var position = {left: 0, top: 0};
var reset = {left: 0, top: 0};
// if "next" animate left
position to last child, then reset left to 0
if(slider.settings.autoDirection ==
'next'){
position =
el.find('.bx-clone').first().position();
// if "prev" animate left
position to 0, then reset left to first non-clone child
}else{
reset =
slider.children.first().position();
}
var animateProperty =
slider.settings.mode == 'horizontal' ? -position.left : -position.top;
var resetValue = slider.settings.mode
== 'horizontal' ? -reset.left : -reset.top;
var params = {resetValue: resetValue};
setPositionProperty(animateProperty,
'ticker', speed, params);
}
/**
* Initializes touch events
*/
var initTouch = function(){
// initialize object to contain all
touch values
slider.touch = {
start: {x: 0, y: 0},
end: {x: 0, y: 0}
}
slider.viewport.bind('touchstart',
onTouchStart);
}
/**
* Event handler for
"touchstart"
*
* @param e (event)
*
- DOM event object
*/
var onTouchStart = function(e){
if(slider.working){
e.preventDefault();
}else{
// record the original position when
touch starts
slider.touch.originalPos =
el.position();
var orig = e.originalEvent;
// record the starting touch x, y
coordinates
slider.touch.start.x =
orig.changedTouches[0].pageX;
slider.touch.start.y =
orig.changedTouches[0].pageY;
// bind a "touchmove" event
to the viewport
slider.viewport.bind('touchmove',
onTouchMove);
// bind a "touchend" event to
the viewport
slider.viewport.bind('touchend',
onTouchEnd);
}
}
/**
* Event handler for
"touchmove"
*
* @param e (event)
*
- DOM event object
*/
var onTouchMove = function(e){
var orig = e.originalEvent;
// if scrolling on y axis, do not
prevent default
var xMovement =
Math.abs(orig.changedTouches[0].pageX - slider.touch.start.x);
var yMovement =
Math.abs(orig.changedTouches[0].pageY - slider.touch.start.y);
// x axis swipe
if((xMovement * 3) > yMovement
&& slider.settings.preventDefaultSwipeX){
e.preventDefault();
// y axis swipe
}else if((yMovement * 3) > xMovement
&& slider.settings.preventDefaultSwipeY){
e.preventDefault();
}
if(slider.settings.mode != 'fade'
&& slider.settings.oneToOneTouch){
var value = 0;
// if horizontal, drag along x axis
if(slider.settings.mode ==
'horizontal'){
var change =
orig.changedTouches[0].pageX - slider.touch.start.x;
value = slider.touch.originalPos.left +
change;
// if vertical, drag along y axis
}else{
var change =
orig.changedTouches[0].pageY - slider.touch.start.y;
value = slider.touch.originalPos.top +
change;
}
setPositionProperty(value, 'reset', 0);
}
}
/**
* Event handler for
"touchend"
*
* @param e (event)
*
- DOM event object
*/
var onTouchEnd = function(e){
slider.viewport.unbind('touchmove',
onTouchMove);
var orig = e.originalEvent;
var value = 0;
// record end x, y positions
slider.touch.end.x =
orig.changedTouches[0].pageX;
slider.touch.end.y =
orig.changedTouches[0].pageY;
// if fade mode, check if absolute x
distance clears the threshold
if(slider.settings.mode == 'fade'){
var distance =
Math.abs(slider.touch.start.x - slider.touch.end.x);
if(distance >=
slider.settings.swipeThreshold){
slider.touch.start.x >
slider.touch.end.x ? el.goToNextSlide() : el.goToPrevSlide();
el.stopAuto();
}
// not fade mode
}else{
var distance = 0;
// calculate distance and el's animate
property
if(slider.settings.mode ==
'horizontal'){
distance = slider.touch.end.x -
slider.touch.start.x;
value = slider.touch.originalPos.left;
}else{
distance = slider.touch.end.y -
slider.touch.start.y;
value = slider.touch.originalPos.top;
}
// if not infinite loop and first /
last slide, do not attempt a slide transition
if(!slider.settings.infiniteLoop
&& ((slider.active.index == 0 && distance > 0) ||
(slider.active.last && distance < 0))){
setPositionProperty(value, 'reset',
200);
}else{
// check if distance clears threshold
if(Math.abs(distance) >=
slider.settings.swipeThreshold){
distance < 0 ? el.goToNextSlide() :
el.goToPrevSlide();
el.stopAuto();
}else{
// el.animate(property, 200);
setPositionProperty(value, 'reset',
200);
}
}
}
slider.viewport.unbind('touchend',
onTouchEnd);
}
/**
* Window resize event callback
*/
var resizeWindow = function(e){
// don't do anything if slider isn't
initialized.
if(!slider.initialized) return;
// get the new window dimens (again,
thank you IE)
var windowWidthNew = $(window).width();
var windowHeightNew =
$(window).height();
// make sure that it is a true window
resize
// *we must check this because our
dinosaur friend IE fires a window resize event when certain DOM elements
// are resized. Can you just die
already?*
if(windowWidth != windowWidthNew ||
windowHeight != windowHeightNew){
// set the new window dimens
windowWidth = windowWidthNew;
windowHeight = windowHeightNew;
// update all dynamic elements
el.redrawSlider();
// Call user resize handler
slider.settings.onSliderResize.call(el,
slider.active.index);
}
}
/**
*
===================================================================================
* = PUBLIC FUNCTIONS
*
===================================================================================
*/
/**
* Performs slide transition to the
specified slide
*
* @param slideIndex (int)
*
- the destination slide's index (zero-based)
*
* @param direction (string)
*
- INTERNAL USE ONLY - the direction of travel ("prev" /
"next")
*/
el.goToSlide = function(slideIndex,
direction){
// if plugin is currently in motion,
ignore request
if(slider.working ||
slider.active.index == slideIndex) return;
// declare that plugin is in motion
slider.working = true;
// store the old index
slider.oldIndex = slider.active.index;
// if slideIndex is less than zero, set
active index to last child (this happens during infinite loop)
if(slideIndex < 0){
slider.active.index = getPagerQty() -
1;
// if slideIndex is greater than
children length, set active index to 0 (this happens during infinite loop)
}else if(slideIndex >=
getPagerQty()){
slider.active.index = 0;
// set active index to requested slide
}else{
slider.active.index = slideIndex;
}
// onSlideBefore, onSlideNext,
onSlidePrev callbacks
slider.settings.onSlideBefore(slider.children.eq(slider.active.index),
slider.oldIndex, slider.active.index);
if(direction == 'next'){
slider.settings.onSlideNext(slider.children.eq(slider.active.index),
slider.oldIndex, slider.active.index);
}else if(direction == 'prev'){
slider.settings.onSlidePrev(slider.children.eq(slider.active.index),
slider.oldIndex, slider.active.index);
}
// check if last slide
slider.active.last =
slider.active.index >= getPagerQty() - 1;
// update the pager with active class
if(slider.settings.pager)
updatePagerActive(slider.active.index);
// // check for direction control
update
if(slider.settings.controls)
updateDirectionControls();
// if slider is set to mode:
"fade"
if(slider.settings.mode == 'fade'){
// if adaptiveHeight is true and next
height is different from current height, animate to the new height
if(slider.settings.adaptiveHeight
&& slider.viewport.height() != getViewportHeight()){
slider.viewport.animate({height:
getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
}
// fade out the visible child and reset
its z-index value
slider.children.filter(':visible').fadeOut(slider.settings.speed).css({zIndex:
0});
// fade in the newly requested slide
slider.children.eq(slider.active.index).css('zIndex',
slider.settings.slideZIndex+1).fadeIn(slider.settings.speed, function(){
$(this).css('zIndex',
slider.settings.slideZIndex);
updateAfterSlideTransition();
});
// slider mode is not "fade"
}else{
// if adaptiveHeight is true and next
height is different from current height, animate to the new height
if(slider.settings.adaptiveHeight
&& slider.viewport.height() != getViewportHeight()){
slider.viewport.animate({height:
getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
}
var moveBy = 0;
var position = {left: 0, top: 0};
// if carousel and not infinite loop
if(!slider.settings.infiniteLoop
&& slider.carousel && slider.active.last){
if(slider.settings.mode ==
'horizontal'){
// get the last child position
var lastChild =
slider.children.eq(slider.children.length - 1);
position = lastChild.position();
// calculate the position of the last
slide
moveBy = slider.viewport.width() -
lastChild.outerWidth();
}else{
// get last showing index position
var lastShowingIndex =
slider.children.length - slider.settings.minSlides;
position =
slider.children.eq(lastShowingIndex).position();
}
// horizontal carousel, going previous
while on first slide (infiniteLoop mode)
}else if(slider.carousel &&
slider.active.last && direction == 'prev'){
// get the last child position
var eq = slider.settings.moveSlides ==
1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) *
getMoveBy()) - (slider.children.length - slider.settings.maxSlides);
var lastChild =
el.children('.bx-clone').eq(eq);
position = lastChild.position();
// if infinite loop and
"Next" is clicked on the last slide
}else if(direction == 'next' &&
slider.active.index == 0){
// get the last clone position
position = el.find('>
.bx-clone').eq(slider.settings.maxSlides).position();
slider.active.last = false;
// normal non-zero requests
}else if(slideIndex >= 0){
var requestEl = slideIndex * getMoveBy();
position =
slider.children.eq(requestEl).position();
}
/* If the position doesn't exist
* (e.g. if you destroy the slider on a
next click),
* it doesn't throw an error.
*/
if ("undefined" !==
typeof(position)) {
var value = slider.settings.mode ==
'horizontal' ? -(position.left - moveBy) : -position.top;
// plugin values to be animated
setPositionProperty(value, 'slide',
slider.settings.speed);
}
}
}
/**
* Transitions to the next slide in the
show
*/
el.goToNextSlide = function(){
// if infiniteLoop is false and last
page is showing, disregard call
if (!slider.settings.infiniteLoop
&& slider.active.last) return;
var pagerIndex =
parseInt(slider.active.index) + 1;
el.goToSlide(pagerIndex, 'next');
}
/**
* Transitions to the prev slide in the
show
*/
el.goToPrevSlide = function(){
// if infiniteLoop is false and last
page is showing, disregard call
if (!slider.settings.infiniteLoop
&& slider.active.index == 0) return;
var pagerIndex =
parseInt(slider.active.index) - 1;
el.goToSlide(pagerIndex, 'prev');
}
/**
* Starts the auto show
*
* @param preventControlUpdate (boolean)
*
- if true, auto controls state will not be updated
*/
el.startAuto =
function(preventControlUpdate){
// if an interval already exists,
disregard call
if(slider.interval) return;
// create an interval
slider.interval =
setInterval(function(){
slider.settings.autoDirection == 'next'
? el.goToNextSlide() : el.goToPrevSlide();
}, slider.settings.pause);
// if auto controls are displayed and
preventControlUpdate is not true
if (slider.settings.autoControls
&& preventControlUpdate != true) updateAutoControls('stop');
}
/**
* Stops the auto show
*
* @param preventControlUpdate (boolean)
*
- if true, auto controls state will not be updated
*/
el.stopAuto =
function(preventControlUpdate){
// if no interval exists, disregard
call
if(!slider.interval) return;
// clear the interval
clearInterval(slider.interval);
slider.interval = null;
// if auto controls are displayed and
preventControlUpdate is not true
if (slider.settings.autoControls
&& preventControlUpdate != true) updateAutoControls('start');
}
/**
* Returns current slide index
(zero-based)
*/
el.getCurrentSlide = function(){
return slider.active.index;
}
/**
* Returns current slide element
*/
el.getCurrentSlideElement = function(){
return
slider.children.eq(slider.active.index);
}
/**
* Returns number of slides in show
*/
el.getSlideCount = function(){
return slider.children.length;
}
/**
* Update all dynamic slider elements
*/
el.redrawSlider = function(){
// resize all children in ratio to new
screen size
slider.children.add(el.find('.bx-clone')).width(getSlideWidth());
// adjust the height
slider.viewport.css('height',
getViewportHeight());
// update the slide position
if(!slider.settings.ticker)
setSlidePosition();
// if active.last was true before the
screen resize, we want
// to keep it last no matter what
screen size we end on
if (slider.active.last)
slider.active.index = getPagerQty() - 1;
// if the active index (page) no longer
exists due to the resize, simply set the index as last
if (slider.active.index >=
getPagerQty()) slider.active.last = true;
// if a pager is being displayed and a
custom pager is not being used, update it
if(slider.settings.pager &&
!slider.settings.pagerCustom){
populatePager();
updatePagerActive(slider.active.index);
}
}
/**
* Destroy the current instance of the
slider (revert everything back to original state)
*/
el.destroySlider = function(){
// don't do anything if slider has
already been destroyed
if(!slider.initialized) return;
slider.initialized = false;
$('.bx-clone', this).remove();
slider.children.each(function() {
$(this).data("origStyle") !=
undefined ? $(this).attr("style",
$(this).data("origStyle")) : $(this).removeAttr('style');
});
$(this).data("origStyle") !=
undefined ? this.attr("style", $(this).data("origStyle")) :
$(this).removeAttr('style');
$(this).unwrap().unwrap();
if(slider.controls.el)
slider.controls.el.remove();
if(slider.controls.next) slider.controls.next.remove();
if(slider.controls.prev)
slider.controls.prev.remove();
if(slider.pagerEl &&
slider.settings.controls) slider.pagerEl.remove();
$('.bx-caption', this).remove();
if(slider.controls.autoEl)
slider.controls.autoEl.remove();
clearInterval(slider.interval);
if(slider.settings.responsive)
$(window).unbind('resize', resizeWindow);
}
/**
* Reload the slider (revert all DOM
changes, and re-initialize)
*/
el.reloadSlider = function(settings){
if (settings != undefined) options =
settings;
el.destroySlider();
init();
}
init();
// returns the current jQuery object
return this;
}
})(jQuery);
//# sourceURL=pen.js
</script>
</body>
</html>
------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0047)http://ryrych.pl/rcarousel/examples/simple.html -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>rcarousel simple carousel</title>
<link type="text/css" rel="stylesheet" href="">
<style type="text/css">
#carousel {
width: 300px;
}
.ui-carousel {
height: 100px;
margin: 0;
overflow: auto;
padding: 0;
position: relative; /*for ie7 to work e.g in html carousels*/
width: 300px
}
.ui-carousel > .wrapper {
margin: 0;
padding: 0;
width: 9999px;
}
.ui-carousel > .wrapper > * {
border: 0;
display: block;
float: left;
height: 100px;
overflow: hidden;
width: 100px;
}
</style>
</head>
<body>
<div id="header">
<p>
This is an example of <em>rcarousel</em> a jQuery UI continuous carousel. Go back to the <a href="http://ryrych.github.com/rcarousel/">documentation</a>
</p>
</div>
<div id="content">
<h1>simple carousel without navigation but with Auto mode</h1>
<div id="carousel">
<img src="http://ryrych.pl/rcarousel/examples/images/001.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/002.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/003.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/004.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/005.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/006.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/007.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/008.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/009.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/010.jpg" />
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
(function ($) {
$.widget("ui.rcarousel", {
_create: function() {
var data,
$root = $( this.element ),
_self = this,
options = this.options;
// if options were default there should be no problem
// check if user set options before init: $('element').rcarousel({with: "foo", visible: 3});
// in above example exception will be thrown because 'with' should be a number!
this._checkOptionsValidity( this.options );
// for every carousel create a data object and keeps it in the element
this._createDataObject();
data = $root.data( "data" );
// create wrapper inside root element; this is needed for animating
$root
.addClass( "ui-carousel" )
.children()
.wrapAll( "<div class='wrapper'></div>" );
// save all children of root element in paths array
this._saveElements();
// make pages using paginate algorithm
this._generatePages();
this._loadElements();
this._setCarouselWidth();
this._setCarouselHeight();
// handle default event handlers
$( options.navigation.next ).click(
function( event ) {
_self.next();
event.preventDefault();
}
);
$( options.navigation.prev ).click(
function( event ) {
_self.prev();
event.preventDefault();
}
);
data.navigation.next = $( options.navigation.next );
data.navigation.prev = $( options.navigation.prev );
// stop on hover feature
$root.hover(
function() {
if ( options.auto.enabled ) {
clearInterval( data.interval );
data.hoveredOver = true;
}
},
function() {
if ( options.auto.enabled ) {
data.hoveredOver = false;
_self._autoMode( options.auto.direction );
}
}
);
this._setStep();
// if auto mode is enabled run it
if ( options.auto.enabled ) {
this._autoMode( options.auto.direction );
}
// broadcast event
this._trigger( "start" );
},
_addElement: function( jQueryElement, direction ) {
var $root = $( this.element ),
$content = $root.find( "div.wrapper" ),
options = this.options;
jQueryElement
.width( options.width )
.height( options.height );
if ( options.orientation === "horizontal" ) {
$( jQueryElement ).css( "marginRight", options.margin );
} else {
$( jQueryElement ).css({
marginBottom: options.margin,
"float": "none"
});
}
if ( direction === "prev" ) {
// clone event handlers and data as well
$content.prepend( jQueryElement.clone(true, true) );
} else {
$content.append( jQueryElement.clone(true, true) );
}
},
append: function( jqElements ) {
var $root = $( this.element ),
data = $root.data( "data" );
// add new elements
jqElements.each(
function( i, el ) {
data.paths.push( $(el) );
}
);
data.oldPage = data.pages[data.oldPageIndex].slice(0);
data.appended = true;
// rebuild pages
this._generatePages();
},
_autoMode: function( direction ) {
var options = this.options,
data = $( this.element ).data( "data" );
if ( direction === "next" ) {
data.interval = setTimeout( $.proxy(this.next, this), options.auto.interval );
} else {
data.interval = setTimeout( $.proxy(this.prev, this), options.auto.interval );
}
},
_checkOptionsValidity: function( options ) {
var i,
self = this,
_correctSteps = "";
// for every element in options object check its validity
$.each(options,
function( key, value ) {
switch ( key ) {
case "visible":
// visible should be a positive integer
if ( !value || typeof value !== "number" || value <= 0 || (Math.ceil(value) - value > 0) ) {
throw new Error( "visible should be defined as a positive integer" );
}
break;
case "step":
if ( !value || typeof value !== "number" || value <= 0 || (Math.ceil(value) - value > 0) ) {
throw new Error( "step should be defined as a positive integer" );
} else if ( value > self.options.visible ) {
// for example for visible: 3 the following array of values for 'step' is valid
// 3 <= step >= 1 by 1 ==> [1,2,3]
// output correct values
for ( i = 1; i <= Math.floor(options.visible); i++ ) {
_correctSteps += ( i < Math.floor(value) ) ? i + ", " : i;
}
throw new Error( "Only following step values are correct: " + _correctSteps );
}
break;
case "width":
// width & height is defined by default so you can omit them to some extent
if ( !value || typeof value !== "number" || value <= 0 || Math.ceil(value) - value > 0 ) {
throw new Error( "width should be defined as a positive integer" );
}
break;
case "height":
if ( !value || typeof value !== "number" || value <= 0 || Math.ceil(value) - value > 0 ) {
throw new Error("height should be defined as a positive integer");
}
break;
case "speed":
if ( !value && value !== 0 ) {
throw new Error("speed should be defined as a number or a string");
}
if ( typeof value === "number" && value < 0 ) {
throw new Error( "speed should be a positive number" );
} else if ( typeof value === "string" && !(value === "slow" || value === "normal" || value === "fast") ) {
throw new Error( 'Only "slow", "normal" and "fast" values are valid' );
}
break;
case "navigation":
if ( !value || $.isPlainObject(value) === false ) {
throw new Error( "navigation should be defined as an object with at least one of the properties: 'prev' or 'next' in it");
}
if ( value.prev && typeof value.prev !== "string" ) {
throw new Error( "navigation.prev should be defined as a string and point to '.class' or '#id' of an element" );
}
if ( value.next && typeof value.next !== "string" ) {
throw new Error(" navigation.next should be defined as a string and point to '.class' or '#id' of an element" );
}
break;
case "auto":
if ( typeof value.direction !== "string" ) {
throw new Error( "direction should be defined as a string" );
}
if ( !(value.direction === "next" || value.direction === "prev") ) {
throw new Error( "direction: only 'right' and 'left' values are valid" );
}
if ( isNaN(value.interval) || typeof value.interval !== "number" || value.interval < 0 || Math.ceil(value.interval) - value.interval > 0 ) {
throw new Error( "interval should be a positive number" );
}
break;
case "margin":
if ( isNaN(value) || typeof value !== "number" || value < 0 || Math.ceil(value) - value > 0 ) {
throw new Error( "margin should be a positive number" );
}
break;
}
}
);
},
_createDataObject: function() {
var $root = $( this.element );
$root.data("data",
{
paths: [],
pathsLen: 0,
pages: [],
lastPage: [],
oldPageIndex: 0,
pageIndex: 0,
navigation: {},
animated: false,
appended: false,
hoveredOver: false
}
);
},
_generatePages: function() {
var self = this,
options = this.options,
data = $( this.element ).data( "data" ),
_visible = options.visible,
_pathsLen = data.paths.length;
// having 10 elements: A, B, C, D, E, F, G, H, I, J the algorithm
// creates 3 pages for visible: 5 and step: 4:
// [ABCDE], [EFGHI], [FGHIJ]
function _init() {
// init creates the last page [FGHIJ] and remembers it
data.pages = [];
data.lastPage = [];
data.pages[0] = [];
// init last page
for ( var i = _pathsLen - 1; i >= _pathsLen - _visible; i-- ) {
data.lastPage.unshift( data.paths[i] );
}
// and first page
for ( var i = 0; i < _visible; i++ ) {
data.pages[0][data.pages[0].length] = data.paths[i];
}
}
function _islastPage( page ) {
var _isLast = false;
for ( var i = 0; i < data.lastPage.length; i++ ) {
if ( data.lastPage[i].get(0) === page[i].get(0) ) {
_isLast = true;
} else {
_isLast = false;
break;
}
}
return _isLast;
}
function _append( start, end, atIndex ) {
var _index = atIndex || data.pages.length;
if ( !atIndex ) {
data.pages[_index] = [];
}
for ( var i = start; i < end; i++ ) {
data.pages[_index].push( data.paths[i] );
}
return _index;
}
function _paginate() {
var _isBeginning = true,
_complement = false,
_start = options.step,
_end, _index, _oldFirstEl, _oldLastEl;
// continue until you reach the last page
// we start from the 2nd page (1st page has been already initiated)
while ( !_islastPage(data.pages[data.pages.length - 1]) || _isBeginning ) {
_isBeginning = false;
_end = _start + _visible;
// we cannot exceed _pathsLen
if ( _end > _pathsLen ) {
_end = _pathsLen;
}
// when we run ouf of elements (_end - _start < _visible) we must add the difference at the begining
// in our example the 3rd page is [FGHIJ] and J element is added in the second step
// first we add [FGHI] as old elements
// we must assure that we have always visible (5 in our example) elements
if ( _end - _start < _visible ) {
_complement = true;
} else {
_complement = false;
}
if ( _complement ) {
// first add old elemets; for 3rd page it adds [FGHI]
// remember the page we add to (_index)
_oldFirstEl = _start - ( _visible - (_end - _start) );
_oldLastEl = _oldFirstEl + ( _visible - (_end - _start) );
_index = _append( _oldFirstEl, _oldLastEl );
// then add new elements; for 3th page it is J element:
// [fghiJ]
_append( _start, _end, _index );
} else {
// normal pages like [ABCDE], [EFGHI]
_append( _start, _end );
// next step
_start += options.step;
}
}
}
// go!
_init();
_paginate();
},
getCurrentPage: function() {
var data = $( this.element ).data( "data" );
return data.pageIndex + 1;
},
getTotalPages: function() {
var data = $( this.element ).data( "data" );
return data.pages.length;
},
goToPage: function( page ) {
var _by,
data = $( this.element ).data( "data" );
if ( !data.animated && page !== data.pageIndex ) {
data.animated = true;
if ( page > data.pages.length - 1 ) {
page = data.pages.length - 1;
} else if ( page < 0 ) {
page = 0;
}
data.pageIndex = page;
_by = page - data.oldPageIndex;
if ( _by >= 0 ) {
//move by n elements from current index
this._goToNextPage( _by );
} else {
this._goToPrevPage( _by );
}
data.oldPageIndex = page;
}
},
_loadElements: function(elements, direction) {
var options = this.options,
data = $( this.element ).data( "data" ),
_dir = direction || "next",
_elem = elements || data.pages[options.startAtPage],
_start = 0,
_end = _elem.length;
if ( _dir === "next" ) {
for ( var i = _start; i < _end; i++ ) {
this._addElement( _elem[i], _dir );
}
} else {
for ( var i = _end - 1; i >= _start; i-- ) {
this._addElement( _elem[i], _dir );
}
}
},
_goToPrevPage: function( by ) {
var _page, _oldPage, _dist, _index, _animOpts, $lastEl, _unique, _pos, _theSame,
$root = $( this.element ),
self = this,
options = this.options,
data = $( this.element ).data( "data" );
// pick pages
if ( data.appended ) {
_oldPage = data.oldPage;
} else {
_oldPage = data.pages[data.oldPageIndex];
}
_index = data.oldPageIndex + by;
_page = data.pages[_index].slice( 0 );
// For example, the first time widget was initiated there were 5
// elements: A, B, C, D, E and 3 pages for visible 2 and step 2:
// AB, CD, DE. Then a user loaded next 5 elements so there were
// 10 already: A, B, C, D, E, F, G, H, I, J and 5 pages:
// AB, CD, EF, GH and IJ. If the other elemets were loaded when
// CD page was shown (from 5 elements) _theSame is true because
// we compare the same
// pages, that is, the 2nd page from 5 elements and the 2nd from
// 10 elements. Thus what we do next is to decrement the index and
// loads the first page from 10 elements.
$( _page ).each(
function( i, el ) {
if ( el.get(0) === $(_oldPage[i]).get(0) ) {
_theSame = true;
} else {
_theSame = false;
}
}
);
if ( data.appended && _theSame ) {
if ( data.pageIndex === 0 ) {
_index = data.pageIndex = data.pages.length - 1;
} else {
_index = --data.pageIndex;
}
_page = data.pages[_index].slice( 0 );
}
// check if last element from _page appears in _oldPage
// for [ABCDFGHIJ] elements there are 3 pages for visible = 6 and
// step = 2: [ABCDEF], [CDEFGH] and [EFGHIJ]; going from the 3rd
// to the 2nd page we only loads 2 elements: [CD] because all
// remaining were loaded already
$lastEl = _page[_page.length - 1].get( 0 );
for ( var i = _oldPage.length - 1; i >= 0; i-- ) {
if ( $lastEl === $(_oldPage[i]).get(0) ) {
_unique = false;
_pos = i;
break;
} else {
_unique = true;
}
}
if ( !_unique ) {
while ( _pos >= 0 ) {
if ( _page[_page.length - 1].get(0) === _oldPage[_pos].get(0) ) {
// this element is unique
_page.pop();
}
--_pos;
}
}
// load new elements
self._loadElements( _page, "prev" );
// calculate the distance
_dist = options.width * _page.length + ( options.margin * _page.length );
if (options.orientation === "horizontal") {
_animOpts = {scrollLeft: 0};
$root.scrollLeft( _dist );
} else {
_animOpts = {scrollTop: 0};
$root.scrollTop( _dist );
}
$root
.animate(_animOpts, options.speed, function () {
self._removeOldElements( "last", _page.length );
data.animated = false;
if ( !data.hoveredOver && options.auto.enabled ) {
// if autoMode is on and you change page manually
clearInterval( data.interval );
self._autoMode( options.auto.direction );
}
// scrolling is finished, send an event
self._trigger("pageLoaded", null, {page: _index});
});
// reset to deafult
data.appended = false;
},
_goToNextPage: function( by ) {
var _page, _oldPage, _dist, _index, _animOpts, $firstEl, _unique, _pos, _theSame,
$root = $( this.element ),
options = this.options,
data = $root.data( "data" ),
self = this;
// pick pages
if ( data.appended ) {
_oldPage = data.oldPage;
} else {
_oldPage = data.pages[data.oldPageIndex];
}
_index = data.oldPageIndex + by;
_page = data.pages[_index].slice( 0 );
// For example, the first time widget was initiated there were 5
// elements: A, B, C, D, E and 2 pages for visible 4 and step 3:
// ABCD and BCDE. Then a user loaded next 5 elements so there were
// 10 already: A, B, C, D, E, F, G, H, I, J and 3 pages:
// ABCD, DEFG and GHIJ. If the other elemets were loaded when
// ABCD page was shown (from 5 elements) _theSame is true because
// we compare the same
// pages, that is, the first pages from 5 elements and the first from
// 10 elements. Thus what we do next is to increment the index and
// loads the second page from 10 elements.
$( _page ).each(
function( i, el ) {
if ( el.get(0) === $(_oldPage[i]).get(0) ) {
_theSame = true;
} else {
_theSame = false;
}
}
);
if ( data.appended && _theSame ) {
_page = data.pages[++data.pageIndex].slice( 0 );
}
// check if 1st element from _page appears in _oldPage
// for [ABCDFGHIJ] elements there are 3 pages for visible = 6 and
// step = 2: [ABCDEF], [CDEFGH] and [EFGHIJ]; going from the 2nd
// to the 3rd page we only loads 2 elements: [IJ] because all
// remaining were loaded already
$firstEl = _page[0].get( 0 );
for ( var i = 0; i < _page.length; i++) {
if ( $firstEl === $(_oldPage[i]).get(0) ) {
_unique = false;
_pos = i;
break;
} else {
_unique = true;
}
}
if ( !_unique ) {
while ( _pos < _oldPage.length ) {
if ( _page[0].get(0) === _oldPage[_pos].get(0) ) {
_page.shift();
}
++_pos;
}
}
// load new elements
this._loadElements( _page, "next" );
// calculate the distance
_dist = options.width * _page.length + ( options.margin * _page.length );
if ( options.orientation === "horizontal" ) {
_animOpts = {scrollLeft: "+=" + _dist};
} else {
_animOpts = {scrollTop: "+=" + _dist};
}
$root
.animate(_animOpts, options.speed, function() {
self._removeOldElements( "first", _page.length );
if ( options.orientation === "horizontal" ) {
$root.scrollLeft( 0 );
} else {
$root.scrollTop( 0 );
}
data.animated = false;
if ( !data.hoveredOver && options.auto.enabled ) {
// if autoMode is on and you change page manually
clearInterval( data.interval );
self._autoMode( options.auto.direction );
}
// scrolling is finished, send an event
self._trigger( "pageLoaded", null, {page: _index});
});
// reset to deafult
data.appended = false;
},
next: function() {
var options = this.options,
data = $( this.element ).data( "data" );
if ( !data.animated ) {
data.animated = true;
if ( !data.appended ) {
++data.pageIndex;
}
if ( data.pageIndex > data.pages.length - 1 ) {
data.pageIndex = 0;
}
// move by one element from current index
this._goToNextPage( data.pageIndex - data.oldPageIndex );
data.oldPageIndex = data.pageIndex;
}
},
prev: function() {
var options = this.options,
data = $( this.element ).data( "data" );
if ( !data.animated ) {
data.animated = true;
if ( !data.appended ) {
--data.pageIndex;
}
if ( data.pageIndex < 0 ) {
data.pageIndex = data.pages.length - 1;
}
// move left by one element from current index
this._goToPrevPage( data.pageIndex - data.oldPageIndex );
data.oldPageIndex = data.pageIndex;
}
},
_removeOldElements: function(position, length) {
// remove 'step' elements
var $root = $( this.element );
for ( var i = 0; i < length; i++ ) {
if ( position === "first" ) {
$root
.find( "div.wrapper" )
.children()
.first()
.remove();
} else {
$root
.find( "div.wrapper" )
.children()
.last()
.remove();
}
}
},
_saveElements: function() {
var $el,
$root = $( this.element ),
$elements = $root.find( "div.wrapper" ).children(),
data = $root.data( "data" );
$elements.each(
function( i, el ) {
$el = $( el );
// keep elements data and events
data.paths.push( $el.clone(true, true) );
$el.remove();
}
);
},
_setOption: function( key, value ) {
var _newOptions,
options = this.options,
data = $( this.element ).data( "data" );
switch (key) {
case "speed":
this._checkOptionsValidity({speed: value});
options.speed = value;
$.Widget.prototype._setOption.apply( this, arguments );
break;
case "auto":
_newOptions = $.extend( options.auto, value );
this._checkOptionsValidity({auto: _newOptions});
if ( options.auto.enabled ) {
this._autoMode( options.auto.direction );
}
}
},
_setStep: function(s) {
// calculate a step
var _step,
options = this.options,
data = $( this.element ).data( "data" );
_step = s || options.step;
options.step = _step;
data.step = options.width * _step;
},
_setCarouselHeight: function() {
var _newHeight,
$root = $( this.element ),
data = $( this.element ).data( "data" ),
options = this.options;
if ( options.orientation === "vertical" ) {
_newHeight = options.visible * options.height + options.margin * (options.visible - 1);
} else {
_newHeight = options.height;
}
$root.height(_newHeight);
},
_setCarouselWidth: function() {
var _newWidth,
$root = $( this.element ),
options = this.options,
data = $( this.element ).data( "data" );
if ( options.orientation === "horizontal" ) {
_newWidth = options.visible * options.width + options.margin * (options.visible - 1);
} else {
_newWidth = options.width;
}
// set carousel width and disable overflow: auto
$root.css({
width: _newWidth,
overflow: "hidden"
});
},
options: {
visible: 3,
step: 3,
width: 100,
height: 100,
speed: 1000,
margin: 0,
orientation: "horizontal",
auto: {
enabled: false,
direction: "next",
interval: 5000
},
startAtPage: 0,
navigation: {
next: "#ui-carousel-next",
prev: "#ui-carousel-prev"
}
}
});
}(jQuery));
</script>
<script type="text/javascript">
jQuery(function($) {
$("#carousel").rcarousel({
auto: {enabled: true}
});
});
</script>
</body>
</html>
------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0047)http://ryrych.pl/rcarousel/examples/simple.html -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>rcarousel simple carousel</title>
<link type="text/css" rel="stylesheet" href="">
<style type="text/css">
#carousel {
width: 300px;
}
.ui-carousel {
height: 100px;
margin: 0;
overflow: auto;
padding: 0;
position: relative; /*for ie7 to work e.g in html carousels*/
width: 300px
}
.ui-carousel > .wrapper {
margin: 0;
padding: 0;
width: 9999px;
}
.ui-carousel > .wrapper > * {
border: 0;
display: block;
float: left;
height: 100px;
overflow: hidden;
width: 100px;
}
</style>
</head>
<body>
<div id="header">
<p>
This is an example of <em>rcarousel</em> a jQuery UI continuous carousel. Go back to the <a href="http://ryrych.github.com/rcarousel/">documentation</a>
</p>
</div>
<div id="content">
<h1>simple carousel without navigation but with Auto mode</h1>
<div id="carousel">
<img src="http://ryrych.pl/rcarousel/examples/images/001.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/002.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/003.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/004.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/005.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/006.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/007.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/008.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/009.jpg" />
<img src="http://ryrych.pl/rcarousel/examples/images/010.jpg" />
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
(function ($) {
$.widget("ui.rcarousel", {
_create: function() {
var data,
$root = $( this.element ),
_self = this,
options = this.options;
// if options were default there should be no problem
// check if user set options before init: $('element').rcarousel({with: "foo", visible: 3});
// in above example exception will be thrown because 'with' should be a number!
this._checkOptionsValidity( this.options );
// for every carousel create a data object and keeps it in the element
this._createDataObject();
data = $root.data( "data" );
// create wrapper inside root element; this is needed for animating
$root
.addClass( "ui-carousel" )
.children()
.wrapAll( "<div class='wrapper'></div>" );
// save all children of root element in paths array
this._saveElements();
// make pages using paginate algorithm
this._generatePages();
this._loadElements();
this._setCarouselWidth();
this._setCarouselHeight();
// handle default event handlers
$( options.navigation.next ).click(
function( event ) {
_self.next();
event.preventDefault();
}
);
$( options.navigation.prev ).click(
function( event ) {
_self.prev();
event.preventDefault();
}
);
data.navigation.next = $( options.navigation.next );
data.navigation.prev = $( options.navigation.prev );
// stop on hover feature
$root.hover(
function() {
if ( options.auto.enabled ) {
clearInterval( data.interval );
data.hoveredOver = true;
}
},
function() {
if ( options.auto.enabled ) {
data.hoveredOver = false;
_self._autoMode( options.auto.direction );
}
}
);
this._setStep();
// if auto mode is enabled run it
if ( options.auto.enabled ) {
this._autoMode( options.auto.direction );
}
// broadcast event
this._trigger( "start" );
},
_addElement: function( jQueryElement, direction ) {
var $root = $( this.element ),
$content = $root.find( "div.wrapper" ),
options = this.options;
jQueryElement
.width( options.width )
.height( options.height );
if ( options.orientation === "horizontal" ) {
$( jQueryElement ).css( "marginRight", options.margin );
} else {
$( jQueryElement ).css({
marginBottom: options.margin,
"float": "none"
});
}
if ( direction === "prev" ) {
// clone event handlers and data as well
$content.prepend( jQueryElement.clone(true, true) );
} else {
$content.append( jQueryElement.clone(true, true) );
}
},
append: function( jqElements ) {
var $root = $( this.element ),
data = $root.data( "data" );
// add new elements
jqElements.each(
function( i, el ) {
data.paths.push( $(el) );
}
);
data.oldPage = data.pages[data.oldPageIndex].slice(0);
data.appended = true;
// rebuild pages
this._generatePages();
},
_autoMode: function( direction ) {
var options = this.options,
data = $( this.element ).data( "data" );
if ( direction === "next" ) {
data.interval = setTimeout( $.proxy(this.next, this), options.auto.interval );
} else {
data.interval = setTimeout( $.proxy(this.prev, this), options.auto.interval );
}
},
_checkOptionsValidity: function( options ) {
var i,
self = this,
_correctSteps = "";
// for every element in options object check its validity
$.each(options,
function( key, value ) {
switch ( key ) {
case "visible":
// visible should be a positive integer
if ( !value || typeof value !== "number" || value <= 0 || (Math.ceil(value) - value > 0) ) {
throw new Error( "visible should be defined as a positive integer" );
}
break;
case "step":
if ( !value || typeof value !== "number" || value <= 0 || (Math.ceil(value) - value > 0) ) {
throw new Error( "step should be defined as a positive integer" );
} else if ( value > self.options.visible ) {
// for example for visible: 3 the following array of values for 'step' is valid
// 3 <= step >= 1 by 1 ==> [1,2,3]
// output correct values
for ( i = 1; i <= Math.floor(options.visible); i++ ) {
_correctSteps += ( i < Math.floor(value) ) ? i + ", " : i;
}
throw new Error( "Only following step values are correct: " + _correctSteps );
}
break;
case "width":
// width & height is defined by default so you can omit them to some extent
if ( !value || typeof value !== "number" || value <= 0 || Math.ceil(value) - value > 0 ) {
throw new Error( "width should be defined as a positive integer" );
}
break;
case "height":
if ( !value || typeof value !== "number" || value <= 0 || Math.ceil(value) - value > 0 ) {
throw new Error("height should be defined as a positive integer");
}
break;
case "speed":
if ( !value && value !== 0 ) {
throw new Error("speed should be defined as a number or a string");
}
if ( typeof value === "number" && value < 0 ) {
throw new Error( "speed should be a positive number" );
} else if ( typeof value === "string" && !(value === "slow" || value === "normal" || value === "fast") ) {
throw new Error( 'Only "slow", "normal" and "fast" values are valid' );
}
break;
case "navigation":
if ( !value || $.isPlainObject(value) === false ) {
throw new Error( "navigation should be defined as an object with at least one of the properties: 'prev' or 'next' in it");
}
if ( value.prev && typeof value.prev !== "string" ) {
throw new Error( "navigation.prev should be defined as a string and point to '.class' or '#id' of an element" );
}
if ( value.next && typeof value.next !== "string" ) {
throw new Error(" navigation.next should be defined as a string and point to '.class' or '#id' of an element" );
}
break;
case "auto":
if ( typeof value.direction !== "string" ) {
throw new Error( "direction should be defined as a string" );
}
if ( !(value.direction === "next" || value.direction === "prev") ) {
throw new Error( "direction: only 'right' and 'left' values are valid" );
}
if ( isNaN(value.interval) || typeof value.interval !== "number" || value.interval < 0 || Math.ceil(value.interval) - value.interval > 0 ) {
throw new Error( "interval should be a positive number" );
}
break;
case "margin":
if ( isNaN(value) || typeof value !== "number" || value < 0 || Math.ceil(value) - value > 0 ) {
throw new Error( "margin should be a positive number" );
}
break;
}
}
);
},
_createDataObject: function() {
var $root = $( this.element );
$root.data("data",
{
paths: [],
pathsLen: 0,
pages: [],
lastPage: [],
oldPageIndex: 0,
pageIndex: 0,
navigation: {},
animated: false,
appended: false,
hoveredOver: false
}
);
},
_generatePages: function() {
var self = this,
options = this.options,
data = $( this.element ).data( "data" ),
_visible = options.visible,
_pathsLen = data.paths.length;
// having 10 elements: A, B, C, D, E, F, G, H, I, J the algorithm
// creates 3 pages for visible: 5 and step: 4:
// [ABCDE], [EFGHI], [FGHIJ]
function _init() {
// init creates the last page [FGHIJ] and remembers it
data.pages = [];
data.lastPage = [];
data.pages[0] = [];
// init last page
for ( var i = _pathsLen - 1; i >= _pathsLen - _visible; i-- ) {
data.lastPage.unshift( data.paths[i] );
}
// and first page
for ( var i = 0; i < _visible; i++ ) {
data.pages[0][data.pages[0].length] = data.paths[i];
}
}
function _islastPage( page ) {
var _isLast = false;
for ( var i = 0; i < data.lastPage.length; i++ ) {
if ( data.lastPage[i].get(0) === page[i].get(0) ) {
_isLast = true;
} else {
_isLast = false;
break;
}
}
return _isLast;
}
function _append( start, end, atIndex ) {
var _index = atIndex || data.pages.length;
if ( !atIndex ) {
data.pages[_index] = [];
}
for ( var i = start; i < end; i++ ) {
data.pages[_index].push( data.paths[i] );
}
return _index;
}
function _paginate() {
var _isBeginning = true,
_complement = false,
_start = options.step,
_end, _index, _oldFirstEl, _oldLastEl;
// continue until you reach the last page
// we start from the 2nd page (1st page has been already initiated)
while ( !_islastPage(data.pages[data.pages.length - 1]) || _isBeginning ) {
_isBeginning = false;
_end = _start + _visible;
// we cannot exceed _pathsLen
if ( _end > _pathsLen ) {
_end = _pathsLen;
}
// when we run ouf of elements (_end - _start < _visible) we must add the difference at the begining
// in our example the 3rd page is [FGHIJ] and J element is added in the second step
// first we add [FGHI] as old elements
// we must assure that we have always visible (5 in our example) elements
if ( _end - _start < _visible ) {
_complement = true;
} else {
_complement = false;
}
if ( _complement ) {
// first add old elemets; for 3rd page it adds [FGHI]
// remember the page we add to (_index)
_oldFirstEl = _start - ( _visible - (_end - _start) );
_oldLastEl = _oldFirstEl + ( _visible - (_end - _start) );
_index = _append( _oldFirstEl, _oldLastEl );
// then add new elements; for 3th page it is J element:
// [fghiJ]
_append( _start, _end, _index );
} else {
// normal pages like [ABCDE], [EFGHI]
_append( _start, _end );
// next step
_start += options.step;
}
}
}
// go!
_init();
_paginate();
},
getCurrentPage: function() {
var data = $( this.element ).data( "data" );
return data.pageIndex + 1;
},
getTotalPages: function() {
var data = $( this.element ).data( "data" );
return data.pages.length;
},
goToPage: function( page ) {
var _by,
data = $( this.element ).data( "data" );
if ( !data.animated && page !== data.pageIndex ) {
data.animated = true;
if ( page > data.pages.length - 1 ) {
page = data.pages.length - 1;
} else if ( page < 0 ) {
page = 0;
}
data.pageIndex = page;
_by = page - data.oldPageIndex;
if ( _by >= 0 ) {
//move by n elements from current index
this._goToNextPage( _by );
} else {
this._goToPrevPage( _by );
}
data.oldPageIndex = page;
}
},
_loadElements: function(elements, direction) {
var options = this.options,
data = $( this.element ).data( "data" ),
_dir = direction || "next",
_elem = elements || data.pages[options.startAtPage],
_start = 0,
_end = _elem.length;
if ( _dir === "next" ) {
for ( var i = _start; i < _end; i++ ) {
this._addElement( _elem[i], _dir );
}
} else {
for ( var i = _end - 1; i >= _start; i-- ) {
this._addElement( _elem[i], _dir );
}
}
},
_goToPrevPage: function( by ) {
var _page, _oldPage, _dist, _index, _animOpts, $lastEl, _unique, _pos, _theSame,
$root = $( this.element ),
self = this,
options = this.options,
data = $( this.element ).data( "data" );
// pick pages
if ( data.appended ) {
_oldPage = data.oldPage;
} else {
_oldPage = data.pages[data.oldPageIndex];
}
_index = data.oldPageIndex + by;
_page = data.pages[_index].slice( 0 );
// For example, the first time widget was initiated there were 5
// elements: A, B, C, D, E and 3 pages for visible 2 and step 2:
// AB, CD, DE. Then a user loaded next 5 elements so there were
// 10 already: A, B, C, D, E, F, G, H, I, J and 5 pages:
// AB, CD, EF, GH and IJ. If the other elemets were loaded when
// CD page was shown (from 5 elements) _theSame is true because
// we compare the same
// pages, that is, the 2nd page from 5 elements and the 2nd from
// 10 elements. Thus what we do next is to decrement the index and
// loads the first page from 10 elements.
$( _page ).each(
function( i, el ) {
if ( el.get(0) === $(_oldPage[i]).get(0) ) {
_theSame = true;
} else {
_theSame = false;
}
}
);
if ( data.appended && _theSame ) {
if ( data.pageIndex === 0 ) {
_index = data.pageIndex = data.pages.length - 1;
} else {
_index = --data.pageIndex;
}
_page = data.pages[_index].slice( 0 );
}
// check if last element from _page appears in _oldPage
// for [ABCDFGHIJ] elements there are 3 pages for visible = 6 and
// step = 2: [ABCDEF], [CDEFGH] and [EFGHIJ]; going from the 3rd
// to the 2nd page we only loads 2 elements: [CD] because all
// remaining were loaded already
$lastEl = _page[_page.length - 1].get( 0 );
for ( var i = _oldPage.length - 1; i >= 0; i-- ) {
if ( $lastEl === $(_oldPage[i]).get(0) ) {
_unique = false;
_pos = i;
break;
} else {
_unique = true;
}
}
if ( !_unique ) {
while ( _pos >= 0 ) {
if ( _page[_page.length - 1].get(0) === _oldPage[_pos].get(0) ) {
// this element is unique
_page.pop();
}
--_pos;
}
}
// load new elements
self._loadElements( _page, "prev" );
// calculate the distance
_dist = options.width * _page.length + ( options.margin * _page.length );
if (options.orientation === "horizontal") {
_animOpts = {scrollLeft: 0};
$root.scrollLeft( _dist );
} else {
_animOpts = {scrollTop: 0};
$root.scrollTop( _dist );
}
$root
.animate(_animOpts, options.speed, function () {
self._removeOldElements( "last", _page.length );
data.animated = false;
if ( !data.hoveredOver && options.auto.enabled ) {
// if autoMode is on and you change page manually
clearInterval( data.interval );
self._autoMode( options.auto.direction );
}
// scrolling is finished, send an event
self._trigger("pageLoaded", null, {page: _index});
});
// reset to deafult
data.appended = false;
},
_goToNextPage: function( by ) {
var _page, _oldPage, _dist, _index, _animOpts, $firstEl, _unique, _pos, _theSame,
$root = $( this.element ),
options = this.options,
data = $root.data( "data" ),
self = this;
// pick pages
if ( data.appended ) {
_oldPage = data.oldPage;
} else {
_oldPage = data.pages[data.oldPageIndex];
}
_index = data.oldPageIndex + by;
_page = data.pages[_index].slice( 0 );
// For example, the first time widget was initiated there were 5
// elements: A, B, C, D, E and 2 pages for visible 4 and step 3:
// ABCD and BCDE. Then a user loaded next 5 elements so there were
// 10 already: A, B, C, D, E, F, G, H, I, J and 3 pages:
// ABCD, DEFG and GHIJ. If the other elemets were loaded when
// ABCD page was shown (from 5 elements) _theSame is true because
// we compare the same
// pages, that is, the first pages from 5 elements and the first from
// 10 elements. Thus what we do next is to increment the index and
// loads the second page from 10 elements.
$( _page ).each(
function( i, el ) {
if ( el.get(0) === $(_oldPage[i]).get(0) ) {
_theSame = true;
} else {
_theSame = false;
}
}
);
if ( data.appended && _theSame ) {
_page = data.pages[++data.pageIndex].slice( 0 );
}
// check if 1st element from _page appears in _oldPage
// for [ABCDFGHIJ] elements there are 3 pages for visible = 6 and
// step = 2: [ABCDEF], [CDEFGH] and [EFGHIJ]; going from the 2nd
// to the 3rd page we only loads 2 elements: [IJ] because all
// remaining were loaded already
$firstEl = _page[0].get( 0 );
for ( var i = 0; i < _page.length; i++) {
if ( $firstEl === $(_oldPage[i]).get(0) ) {
_unique = false;
_pos = i;
break;
} else {
_unique = true;
}
}
if ( !_unique ) {
while ( _pos < _oldPage.length ) {
if ( _page[0].get(0) === _oldPage[_pos].get(0) ) {
_page.shift();
}
++_pos;
}
}
// load new elements
this._loadElements( _page, "next" );
// calculate the distance
_dist = options.width * _page.length + ( options.margin * _page.length );
if ( options.orientation === "horizontal" ) {
_animOpts = {scrollLeft: "+=" + _dist};
} else {
_animOpts = {scrollTop: "+=" + _dist};
}
$root
.animate(_animOpts, options.speed, function() {
self._removeOldElements( "first", _page.length );
if ( options.orientation === "horizontal" ) {
$root.scrollLeft( 0 );
} else {
$root.scrollTop( 0 );
}
data.animated = false;
if ( !data.hoveredOver && options.auto.enabled ) {
// if autoMode is on and you change page manually
clearInterval( data.interval );
self._autoMode( options.auto.direction );
}
// scrolling is finished, send an event
self._trigger( "pageLoaded", null, {page: _index});
});
// reset to deafult
data.appended = false;
},
next: function() {
var options = this.options,
data = $( this.element ).data( "data" );
if ( !data.animated ) {
data.animated = true;
if ( !data.appended ) {
++data.pageIndex;
}
if ( data.pageIndex > data.pages.length - 1 ) {
data.pageIndex = 0;
}
// move by one element from current index
this._goToNextPage( data.pageIndex - data.oldPageIndex );
data.oldPageIndex = data.pageIndex;
}
},
prev: function() {
var options = this.options,
data = $( this.element ).data( "data" );
if ( !data.animated ) {
data.animated = true;
if ( !data.appended ) {
--data.pageIndex;
}
if ( data.pageIndex < 0 ) {
data.pageIndex = data.pages.length - 1;
}
// move left by one element from current index
this._goToPrevPage( data.pageIndex - data.oldPageIndex );
data.oldPageIndex = data.pageIndex;
}
},
_removeOldElements: function(position, length) {
// remove 'step' elements
var $root = $( this.element );
for ( var i = 0; i < length; i++ ) {
if ( position === "first" ) {
$root
.find( "div.wrapper" )
.children()
.first()
.remove();
} else {
$root
.find( "div.wrapper" )
.children()
.last()
.remove();
}
}
},
_saveElements: function() {
var $el,
$root = $( this.element ),
$elements = $root.find( "div.wrapper" ).children(),
data = $root.data( "data" );
$elements.each(
function( i, el ) {
$el = $( el );
// keep elements data and events
data.paths.push( $el.clone(true, true) );
$el.remove();
}
);
},
_setOption: function( key, value ) {
var _newOptions,
options = this.options,
data = $( this.element ).data( "data" );
switch (key) {
case "speed":
this._checkOptionsValidity({speed: value});
options.speed = value;
$.Widget.prototype._setOption.apply( this, arguments );
break;
case "auto":
_newOptions = $.extend( options.auto, value );
this._checkOptionsValidity({auto: _newOptions});
if ( options.auto.enabled ) {
this._autoMode( options.auto.direction );
}
}
},
_setStep: function(s) {
// calculate a step
var _step,
options = this.options,
data = $( this.element ).data( "data" );
_step = s || options.step;
options.step = _step;
data.step = options.width * _step;
},
_setCarouselHeight: function() {
var _newHeight,
$root = $( this.element ),
data = $( this.element ).data( "data" ),
options = this.options;
if ( options.orientation === "vertical" ) {
_newHeight = options.visible * options.height + options.margin * (options.visible - 1);
} else {
_newHeight = options.height;
}
$root.height(_newHeight);
},
_setCarouselWidth: function() {
var _newWidth,
$root = $( this.element ),
options = this.options,
data = $( this.element ).data( "data" );
if ( options.orientation === "horizontal" ) {
_newWidth = options.visible * options.width + options.margin * (options.visible - 1);
} else {
_newWidth = options.width;
}
// set carousel width and disable overflow: auto
$root.css({
width: _newWidth,
overflow: "hidden"
});
},
options: {
visible: 3,
step: 3,
width: 100,
height: 100,
speed: 1000,
margin: 0,
orientation: "horizontal",
auto: {
enabled: false,
direction: "next",
interval: 5000
},
startAtPage: 0,
navigation: {
next: "#ui-carousel-next",
prev: "#ui-carousel-prev"
}
}
});
}(jQuery));
</script>
<script type="text/javascript">
jQuery(function($) {
$("#carousel").rcarousel({
auto: {enabled: true}
});
});
</script>
</body>
</html>
Related movie you might like to see :

GOOGLE CONSOLE

GOOGLE CHROME EXTENSION FILE SAVE O...

OPEN DESKTOP TEXT FILE BY COMMAND P...

RELATED POST WIDGET LIST WITHOUT TH...

FLASH PLAYER SWF FILE DOWNLOAD ARCH...

WHACK A RAT CSS GAME

GOOGLE FILTER BUTTON IN IMAGE SEARC...

CSS SLIDER WITHOUT JS

FLICKITY SLIDER SCROLL WITH RADIO N...

FLICKITY JS CSS SLIDER

RADIO BUTTON SLIDER TO KEY FRAME SL...

BUTTON PADDING CHANGE HEIGHT WIDTH

SHOPIFY FANCY BOX

BASIC ELEVATE ZOOM PLUS

ELEVATE ZOOM JAVA SCRIPT WITH ONE I...

SHOPIFY THEME SLIDER EDIT

INPUT BUTTON VALUE SWAP

CSS SYNTAX HIGHLIGHT CHANGE IN NOT...
?
+
X
Recommended for you
Loading..
Related Post for Simple Tab Gallery With Pure CSS / CSS3 CODE
IMAGE SRC ARRAY IN JAVA SCRIPT --------------------------------------------------------------------------------------------------------------- CODE:1 http://fbgadgets.blogspot.co.uk/2017/07/java-script-arra…
HTML CODE EDITOR <form name="K"> <p style="margin-top: 0px; margin-bottom: 0px;"> <textarea name="ta1" rows="15" cols="50"> //PASTE CODE BETWEEN TEXT AREA HERE </textarea&…
AUTO CSS JS SLIDER WITH ARROW BULLET ------------------------------------------------------------------------------------------------------- BX SLIDER CODE: READ MORE: BX SLIDER IN BLOGGER TEMPALTE - You…
BUTTON CHANGE INTO DROPDOWN MENU ----------------------------------------------------------------------------------------------------------------- DIV TAG DROPDOWN MENU https://www.youtube.com/watc…
CSS SLIDER WITHOUT JS ----------------------------------------------------------------------------------------------------------- ReadMore: http://cssslider.com/non-jquery-carousel-7.html SAVE …
BUTTON PADDING CHANGE HEIGHT WIDTH ------------------------------------------------------------------------------------------------------------ PADDING BUTTON CHANGE INTO WIDTH AND HEIGHTEMOJI SITEShttps://yayte…
Labels:
HTML TUTORIALS,
W
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.