├── .travis.yml ├── .gitignore ├── example ├── img │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 1@2x.jpg │ ├── 2@2x.jpg │ ├── 3@2x.jpg │ └── 4@2x.jpg ├── index.html ├── bullet-nav.html ├── captions.html └── css │ └── normalize.css ├── tests ├── img │ └── base.jpg ├── index.html ├── bind.polyfill.js └── tests.js ├── bower.json ├── extensions ├── bullet-nav │ ├── README.md │ └── iis-bullet-nav.js └── captions │ ├── iis-captions.js │ └── README.md ├── package.json ├── CHANGELOG.md ├── Gruntfile.js ├── ideal-image-slider.css ├── themes └── default │ └── default.css ├── README.md ├── ideal-image-slider.min.js ├── ideal-image-slider.js └── LICENSE /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | before_script: 3 | - npm install -g grunt-cli -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.sass-cache 2 | /node_modules 3 | /_sass 4 | /_site 5 | *.lock 6 | *.pages 7 | *.pdf 8 | -------------------------------------------------------------------------------- /example/img/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/1.jpg -------------------------------------------------------------------------------- /example/img/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/2.jpg -------------------------------------------------------------------------------- /example/img/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/3.jpg -------------------------------------------------------------------------------- /example/img/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/4.jpg -------------------------------------------------------------------------------- /tests/img/base.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/tests/img/base.jpg -------------------------------------------------------------------------------- /example/img/1@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/1@2x.jpg -------------------------------------------------------------------------------- /example/img/2@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/2@2x.jpg -------------------------------------------------------------------------------- /example/img/3@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/3@2x.jpg -------------------------------------------------------------------------------- /example/img/4@2x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Codeinwp/Ideal-Image-Slider-JS/HEAD/example/img/4@2x.jpg -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ideal-image-slider", 3 | "main": "ideal-image-slider.js", 4 | "homepage": "https://github.com/gilbitron/Ideal-Image-Slider", 5 | "authors": [ 6 | "Gilbert Pellegrom " 7 | ], 8 | "description": "Quite simply the ideal Image Slider in vanilla JS", 9 | "keywords": [ 10 | "image", 11 | "slider", 12 | "javascript", 13 | "vanilla" 14 | ], 15 | "license": "GPL-3.0", 16 | "ignore": [ 17 | "**/.*", 18 | "node_modules", 19 | "bower_components", 20 | "tests" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /extensions/bullet-nav/README.md: -------------------------------------------------------------------------------- 1 | # Ideal Image Slider - Bullet Navigation Extension 2 | 3 | Adds bullet navigation to the Ideal Image Slider. 4 | 5 | ## Requirements 6 | 7 | * [Ideal Image Slider](https://github.com/gilbitron/Ideal-Image-Slider) v1.2.0+ 8 | 9 | ## Usage 10 | 11 | The `iis-bullet-nav.js` must be included after `ideal-image-slider.js`. The styles for the bullet navigation 12 | extension are included in the theme CSS. 13 | 14 | ```html 15 | 16 | 17 | 22 | ``` 23 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ideal Image Slider Tests - QUnit 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 |
19 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 | -------------------------------------------------------------------------------- /tests/bind.polyfill.js: -------------------------------------------------------------------------------- 1 | if (!Function.prototype.bind) { 2 | Function.prototype.bind = function(oThis) { 3 | if (typeof this !== 'function') { 4 | // closest thing possible to the ECMAScript 5 5 | // internal IsCallable function 6 | throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); 7 | } 8 | 9 | var aArgs = Array.prototype.slice.call(arguments, 1), 10 | fToBind = this, 11 | fNOP = function() {}, 12 | fBound = function() { 13 | return fToBind.apply(this instanceof fNOP ? this : oThis, 14 | aArgs.concat(Array.prototype.slice.call(arguments))); 15 | }; 16 | 17 | if (this.prototype) { 18 | // native functions don't have a prototype 19 | fNOP.prototype = this.prototype; 20 | } 21 | fBound.prototype = new fNOP(); 22 | 23 | return fBound; 24 | }; 25 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ideal-image-slider", 3 | "version": "1.5.1", 4 | "description": "Quite simply the ideal Image Slider in vanilla JS.", 5 | "keywords": [ 6 | "ideal", 7 | "image", 8 | "slider" 9 | ], 10 | "author": "Gilbert Pellegrom", 11 | "license": "GPL-3.0", 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/gilbitron/Ideal-Image-Slider.git" 15 | }, 16 | "scripts": { 17 | "test": "grunt test" 18 | }, 19 | "devDependencies": { 20 | "grunt": "^0.4.5", 21 | "grunt-contrib-jshint": "^0.10.0", 22 | "grunt-contrib-uglify": "^0.5.1", 23 | "grunt-contrib-watch": "^0.6.1", 24 | "grunt-string-replace": "^0.2.7", 25 | "jshint-stylish": "^0.4.0", 26 | "load-grunt-tasks": "^0.6.0", 27 | "grunt-contrib-qunit": "~0.7.0", 28 | "qunitjs": "~1.19.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ideal Image Slider Example 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | 20 |
21 | Slide 1 22 | Slide 2 23 | Slide 3 24 | Slide 4 25 |
26 | 27 | 28 | 32 | 33 | -------------------------------------------------------------------------------- /example/bullet-nav.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Bullet Navigation - Ideal Image Slider Example 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | 20 |
21 | Slide 1 22 | Slide 2 23 | Slide 3 24 | Slide 4 25 |
26 | 27 | 28 | 29 | 34 | 35 | -------------------------------------------------------------------------------- /extensions/captions/iis-captions.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Ideal Image Slider: Captions Extension v1.0.1 3 | * 4 | * By Gilbert Pellegrom 5 | * http://gilbert.pellegrom.me 6 | * 7 | * Copyright (C) 2014 Dev7studios 8 | * https://raw.githubusercontent.com/gilbitron/Ideal-Image-Slider/master/LICENSE 9 | */ 10 | 11 | (function(IIS) { 12 | "use strict"; 13 | 14 | IIS.Slider.prototype.addCaptions = function() { 15 | IIS._addClass(this._attributes.container, 'iis-has-captions'); 16 | 17 | Array.prototype.forEach.call(this._attributes.slides, function(slide, i) { 18 | var caption = document.createElement('div'); 19 | IIS._addClass(caption, 'iis-caption'); 20 | 21 | var captionContent = ''; 22 | if (slide.getAttribute('title')) { 23 | captionContent += '
' + slide.getAttribute('title') + '
'; 24 | } 25 | if (slide.getAttribute('data-caption')) { 26 | var dataCaption = slide.getAttribute('data-caption'); 27 | if (dataCaption.substring(0, 1) == '#' || dataCaption.substring(0, 1) == '.') { 28 | var external = document.querySelector(dataCaption); 29 | if (external) { 30 | captionContent += '
' + external.innerHTML + '
'; 31 | } 32 | } else { 33 | captionContent += '
' + slide.getAttribute('data-caption') + '
'; 34 | } 35 | } else { 36 | if (slide.innerHTML) { 37 | captionContent += '
' + slide.innerHTML + '
'; 38 | } 39 | } 40 | 41 | slide.innerHTML = ''; 42 | if (captionContent) { 43 | caption.innerHTML = captionContent; 44 | slide.appendChild(caption); 45 | } 46 | }.bind(this)); 47 | }; 48 | 49 | return IIS; 50 | 51 | })(IdealImageSlider); -------------------------------------------------------------------------------- /example/captions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Captions - Ideal Image Slider Example 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | 20 |
21 | This is the caption content 22 | Captions <em>can</em> contain <strong>HTML</strong> 23 | This will be overridden 24 | 25 | A really really really really really really really really really really really really really really really really really really really really really really really really really long caption 26 |
27 | 28 | 32 | 33 | 34 | 35 | 40 | 41 | -------------------------------------------------------------------------------- /extensions/captions/README.md: -------------------------------------------------------------------------------- 1 | # Ideal Image Slider - Captions Extension 2 | 3 | Adds captions support to the Ideal Image Slider. 4 | 5 | ## Requirements 6 | 7 | * [Ideal Image Slider](https://github.com/gilbitron/Ideal-Image-Slider) v1.3.0+ 8 | 9 | ## Usage 10 | 11 | Captions are taken from the `alt` attribute of the image tag or, if defined, the `data-caption` 12 | attribute. The `data-caption` attribute will override the `alt` attribute. You can add an optional 13 | title to your caption which is taken from the `title` attribute of the image tag. 14 | 15 | While you can put HTML in the `alt` attribute it is better to create an external caption in a separate 16 | div and put the selector in the `data-caption` attribute (e.g. `data-caption="#my-caption"`). Make sure 17 | and hide the external caption container so it is not visible on the page. 18 | 19 | ```html 20 |
21 | This is the caption content 22 | Captions <em>can</em> contain <strong>HTML</strong> 23 | This will be overridden 24 | 25 |
26 | 27 | 31 | ``` 32 | 33 | The `iis-captions.js` must be included after `ideal-image-slider.js`. The styles for the captions 34 | extension are included in the theme CSS. 35 | 36 | ```html 37 | 38 | 39 | 44 | ``` 45 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Ideal Image Slider Changelog 2 | 3 | Version 1.5.1 - 2016.02.06 4 | -------------------------- 5 | * [Changed] Small changes and update package.json 6 | 7 | Version 1.5.0 - 2015.09.23 8 | -------------------------- 9 | * [New] Responsive height! The height of the slider now changes correctly in "auto" and aspect ratio mode 10 | * [New] Height can now be an aspect ratio (e.g. "16:9") 11 | * [New] initialHeight and maxHeight settings 12 | * [Changed] Default height value is now "auto" 13 | * [Fixed] _deepExtend() function 14 | * [Fixed] Code formatting 15 | 16 | Version 1.4.0 - 2014.09.22 17 | -------------------------- 18 | * [Changed] Removed outdated CSS vender prefixes 19 | * [Changed] Changed license to GPL 20 | 21 | Version 1.3.0 - 2014.09.17 22 | -------------------------- 23 | * [New] Added Captions extension 24 | 25 | Version 1.2.2 - 2014.09.12 26 | -------------------------- 27 | * [Fixed] Links z-index bug 28 | 29 | Version 1.2.1 - 2014.09.12 30 | -------------------------- 31 | * [Fixed] Single slide bug 32 | * [Fixed] "slide" transitions don't work on mobile 33 | 34 | Version 1.2.0 - 2014.09.10 35 | -------------------------- 36 | * [New] Added Bullet Navigation extension 37 | * [Changed] Added Bullet Navigation styles to Default theme 38 | * [Changed] gotoSlide() now adds directional classes 39 | * [Fixed] Transform property typo 40 | 41 | Version 1.1.0 - 2014.09.08 42 | -------------------------- 43 | * [New] Added keyboard navigation 44 | * [Changed] Implemented better touch navigation 45 | * [Changed] Changed ARIA listbox to tabpanel 46 | 47 | Version 1.0.2 - 2014.09.04 48 | -------------------------- 49 | * [New] Added minified script 50 | * [New] Added Grunt build script 51 | 52 | Version 1.0.1 - 2014.09.03 53 | -------------------------- 54 | * [New] Added loading spinner to default theme 55 | * [Changed] Stop slider if the window is blurred 56 | * [Fixed] Disable navigation while animating 57 | 58 | Version 1.0.0 - 2014.09.02 59 | -------------------------- 60 | * Initial release 61 | -------------------------------------------------------------------------------- /extensions/bullet-nav/iis-bullet-nav.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Ideal Image Slider: Bullet Navigation Extension v1.0.2 3 | * 4 | * By Gilbert Pellegrom 5 | * http://gilbert.pellegrom.me 6 | * 7 | * Copyright (C) 2014 Dev7studios 8 | * https://raw.githubusercontent.com/gilbitron/Ideal-Image-Slider/master/LICENSE 9 | */ 10 | 11 | (function(IIS) { 12 | "use strict"; 13 | 14 | var _updateActiveBullet = function(slider, activeIndex) { 15 | var bullets = slider._attributes.bulletNav.querySelectorAll('a'); 16 | if (!bullets) return; 17 | 18 | Array.prototype.forEach.call(bullets, function(bullet, i) { 19 | IIS._removeClass(bullet, 'iis-bullet-active'); 20 | bullet.setAttribute('aria-selected', 'false'); 21 | if (i === activeIndex) { 22 | IIS._addClass(bullet, 'iis-bullet-active'); 23 | bullet.setAttribute('aria-selected', 'true'); 24 | } 25 | }.bind(this)); 26 | }; 27 | 28 | IIS.Slider.prototype.addBulletNav = function() { 29 | IIS._addClass(this._attributes.container, 'iis-has-bullet-nav'); 30 | 31 | // Create bullet nav 32 | var bulletNav = document.createElement('div'); 33 | IIS._addClass(bulletNav, 'iis-bullet-nav'); 34 | bulletNav.setAttribute('role', 'tablist'); 35 | 36 | // Create bullets 37 | Array.prototype.forEach.call(this._attributes.slides, function(slide, i) { 38 | var bullet = document.createElement('a'); 39 | bullet.innerHTML = i + 1; 40 | bullet.setAttribute('role', 'tab'); 41 | 42 | bullet.addEventListener('click', function() { 43 | if (IIS._hasClass(this._attributes.container, this.settings.classes.animating)) return false; 44 | this.stop(); 45 | this.gotoSlide(i + 1); 46 | }.bind(this)); 47 | 48 | bulletNav.appendChild(bullet); 49 | }.bind(this)); 50 | 51 | this._attributes.bulletNav = bulletNav; 52 | this._attributes.container.appendChild(bulletNav); 53 | _updateActiveBullet(this, 0); 54 | 55 | // Hook up to afterChange events 56 | var origAfterChange = this.settings.afterChange; 57 | var afterChange = function() { 58 | var slides = this._attributes.slides, 59 | index = slides.indexOf(this._attributes.currentSlide); 60 | _updateActiveBullet(this, index); 61 | return origAfterChange(); 62 | }.bind(this); 63 | this.settings.afterChange = afterChange; 64 | }; 65 | 66 | return IIS; 67 | 68 | })(IdealImageSlider); -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | // Config 4 | grunt.initConfig({ 5 | pkg: grunt.file.readJSON('package.json'), 6 | 7 | jshint: { 8 | options: { 9 | reporter: require('jshint-stylish') 10 | }, 11 | dist: { 12 | files: { 13 | src: ['ideal-image-slider.js'] 14 | } 15 | }, 16 | extensions: { 17 | files: { 18 | src: ['extensions/**/*.js'] 19 | } 20 | } 21 | }, 22 | 23 | uglify: { 24 | options: { 25 | banner: '/*! Ideal Image Slider v<%= pkg.version %> */\n' 26 | }, 27 | dist: { 28 | files: { 29 | 'ideal-image-slider.min.js': 'ideal-image-slider.js' 30 | } 31 | } 32 | }, 33 | 34 | 'string-replace': { 35 | version: { 36 | options: { 37 | replacements: [{ 38 | pattern: /(v\d+.\d+.\d+)/, 39 | replacement: 'v<%= pkg.version %>' 40 | }] 41 | }, 42 | files: { 43 | 'ideal-image-slider.js': 'ideal-image-slider.js', 44 | 'ideal-image-slider.css': 'ideal-image-slider.css' 45 | } 46 | } 47 | }, 48 | 49 | qunit: { 50 | all: ['tests/**/*.html'] 51 | }, 52 | 53 | watch: { 54 | options: { 55 | livereload: true 56 | }, 57 | dist: { 58 | files: ['ideal-image-slider.js'], 59 | tasks: ['jshint:dist','uglify','string-replace'], 60 | options: { 61 | spawn: false, 62 | } 63 | }, 64 | extensions: { 65 | files: ['extensions/**/*.js'], 66 | tasks: ['jshint:extensions'], 67 | options: { 68 | spawn: false, 69 | } 70 | } 71 | } 72 | 73 | }); 74 | 75 | // Plugins 76 | require('load-grunt-tasks')(grunt); 77 | grunt.registerTask('forceOn', 'turns the --force option ON', function(){ 78 | if ( !grunt.option( 'force' ) ) { 79 | grunt.config.set('forceStatus', true); 80 | grunt.option( 'force', true ); 81 | } 82 | }); 83 | grunt.registerTask('forceOff', 'turns the --force option OFF', function(){ 84 | if ( grunt.config.get('forceStatus') ) { 85 | grunt.config.set('forceStatus', false); 86 | grunt.option( 'force', false ); 87 | } 88 | }); 89 | 90 | // Tasks 91 | grunt.registerTask('default', [ 92 | 'jshint', 93 | 'uglify', 94 | 'string-replace', 95 | 'watch' 96 | ]); 97 | 98 | grunt.registerTask('test', ['qunit']); 99 | 100 | }; 101 | -------------------------------------------------------------------------------- /ideal-image-slider.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Ideal Image Slider v1.5.1 3 | * 4 | * By Gilbert Pellegrom 5 | * http://gilbert.pellegrom.me 6 | * 7 | * Copyright (C) 2014 Dev7studios 8 | * https://raw.githubusercontent.com/gilbitron/Ideal-Image-Slider/master/LICENSE 9 | */ 10 | 11 | .ideal-image-slider { 12 | position: relative; 13 | overflow: hidden; 14 | } 15 | .iis-slide { 16 | display: block; 17 | bottom: 0; 18 | text-decoration: none; 19 | position: absolute; 20 | top: 0; 21 | left: 0; 22 | width: 100%; 23 | height: 100%; 24 | background-repeat: no-repeat; 25 | background-position: 50% 50%; 26 | background-size: cover; 27 | text-indent: -9999px; 28 | } 29 | 30 | /* Slide effect */ 31 | .iis-effect-slide .iis-slide { 32 | opacity: 0; 33 | -webkit-transition-property: -webkit-transform; 34 | -moz-transition-property: -moz-transform; 35 | -o-transition-property: -o-transform; 36 | transition-property: transform; 37 | -webkit-transition-timing-function: ease-out; 38 | -moz-transition-timing-function: ease-out; 39 | -o-transition-timing-function: ease-out; 40 | transition-timing-function: ease-out; 41 | -webkit-transform: translateX(0%); 42 | -ms-transform: translateX(0%); 43 | transform: translateX(0%); 44 | } 45 | .iis-effect-slide .iis-current-slide { 46 | opacity: 1; 47 | z-index: 1; 48 | } 49 | .iis-effect-slide .iis-previous-slide { 50 | -webkit-transform: translateX(-100%); 51 | -ms-transform: translateX(-100%); 52 | transform: translateX(-100%); 53 | } 54 | .iis-effect-slide .iis-next-slide { 55 | -webkit-transform: translateX(100%); 56 | -ms-transform: translateX(100%); 57 | transform: translateX(100%); 58 | } 59 | .iis-effect-slide.iis-direction-next .iis-previous-slide, 60 | .iis-effect-slide.iis-direction-previous .iis-next-slide { opacity: 1; } 61 | 62 | /* Touch styles */ 63 | .iis-touch-enabled .iis-slide { z-index: 1; } 64 | .iis-touch-enabled .iis-current-slide { z-index: 2; } 65 | .iis-touch-enabled.iis-is-touching .iis-previous-slide, 66 | .iis-touch-enabled.iis-is-touching .iis-next-slide { opacity: 1; } 67 | 68 | /* Fade effect */ 69 | .iis-effect-fade .iis-slide { 70 | -webkit-transition-property: opacity; 71 | -moz-transition-property: opacity; 72 | -o-transition-property: opacity; 73 | transition-property: opacity; 74 | -webkit-transition-timing-function: ease-in; 75 | -moz-transition-timing-function: ease-in; 76 | -o-transition-timing-function: ease-in; 77 | transition-timing-function: ease-in; 78 | opacity: 0; 79 | } 80 | .iis-effect-fade .iis-current-slide { 81 | opacity: 1; 82 | z-index: 1; 83 | } 84 | -------------------------------------------------------------------------------- /tests/tests.js: -------------------------------------------------------------------------------- 1 | QUnit.test('Slider.get', function(assert){ 2 | var slider = new IdealImageSlider.Slider('.slider-default'); 3 | assert.ok(slider.get('currentSlide'), 'Get existing value'); 4 | assert.equal(slider.get('nonExistingValue'), null, 'Get non-existing value'); 5 | }); 6 | 7 | QUnit.test('Slider.set', function(assert){ 8 | var slider = new IdealImageSlider.Slider('.slider-default'); 9 | slider.set('someValue', '123'); 10 | assert.equal(slider.get('someValue'), '123', 'Set value'); 11 | }); 12 | 13 | QUnit.test('Slider.previousSlide', function(assert){ 14 | var slider = new IdealImageSlider.Slider('.slider-default'); 15 | slider.previousSlide(); 16 | assert.equal(slider.get('previousSlide').dataset.index, 3, 'Previous slide URL index is 3'); 17 | assert.equal(slider.get('currentSlide').dataset.index, 4, 'Current slide URL index is 4'); 18 | assert.equal(slider.get('nextSlide').dataset.index, 1, 'Next slide URL index is 1'); 19 | slider.previousSlide(); 20 | slider.previousSlide(); 21 | assert.equal(slider.get('previousSlide').dataset.index, 1, 'Previous slide URL index is 1'); 22 | assert.equal(slider.get('currentSlide').dataset.index, 2, 'Current slide URL index is 2'); 23 | assert.equal(slider.get('nextSlide').dataset.index, 3, 'Next slide URL index is 3'); 24 | slider.previousSlide(); 25 | assert.equal(slider.get('previousSlide').dataset.index, 4, 'Previous slide URL index is 4'); 26 | assert.equal(slider.get('currentSlide').dataset.index, 1, 'Current slide URL index is 1'); 27 | assert.equal(slider.get('nextSlide').dataset.index, 2, 'Next slide URL index is 2'); 28 | }); 29 | 30 | QUnit.test('Slider.nextSlide', function(assert){ 31 | var slider = new IdealImageSlider.Slider('.slider-default'); 32 | slider.nextSlide(); 33 | assert.equal(slider.get('previousSlide').dataset.index, 1, 'Previous slide URL index is 1'); 34 | assert.equal(slider.get('currentSlide').dataset.index, 2, 'Current slide URL index is 2'); 35 | assert.equal(slider.get('nextSlide').dataset.index, 3, 'Next slide URL index is 3'); 36 | slider.nextSlide(); 37 | slider.nextSlide(); 38 | assert.equal(slider.get('previousSlide').dataset.index, 3, 'Previous slide URL index is 3'); 39 | assert.equal(slider.get('currentSlide').dataset.index, 4, 'Current slide URL index is 4'); 40 | assert.equal(slider.get('nextSlide').dataset.index, 1, 'Next slide URL index is 1'); 41 | slider.nextSlide(); 42 | assert.equal(slider.get('previousSlide').dataset.index, 4, 'Previous slide URL index is 4'); 43 | assert.equal(slider.get('currentSlide').dataset.index, 1, 'Current slide URL index is 1'); 44 | assert.equal(slider.get('nextSlide').dataset.index, 2, 'Next slide URL index is 2'); 45 | }); 46 | 47 | QUnit.test('Slider.gotoSlide', function(assert){ 48 | var slider = new IdealImageSlider.Slider('.slider-default'); 49 | slider.gotoSlide(2); 50 | assert.equal(slider.get('previousSlide').dataset.index, 1, 'Previous slide URL index is 1'); 51 | assert.equal(slider.get('currentSlide').dataset.index, 2, 'Current slide URL index is 2'); 52 | assert.equal(slider.get('nextSlide').dataset.index, 3, 'Next slide URL index is 3'); 53 | slider.gotoSlide(1); 54 | assert.equal(slider.get('previousSlide').dataset.index, 4, 'Previous slide URL index is 4'); 55 | assert.equal(slider.get('currentSlide').dataset.index, 1, 'Current slide URL index is 1'); 56 | assert.equal(slider.get('nextSlide').dataset.index, 2, 'Next slide URL index is 2'); 57 | slider.gotoSlide(4); 58 | assert.equal(slider.get('previousSlide').dataset.index, 3, 'Previous slide URL index is 3'); 59 | assert.equal(slider.get('currentSlide').dataset.index, 4, 'Current slide URL index is 4'); 60 | assert.equal(slider.get('nextSlide').dataset.index, 1, 'Next slide URL index is 1'); 61 | }); 62 | 63 | QUnit.test('Slider.destroy', function(assert){ 64 | var slider = new IdealImageSlider.Slider('.slider-default'); 65 | slider.destroy(); 66 | assert.ok((slider.get('container').className.indexOf('slider-default') > -1), 'Slider is destroyed'); 67 | }); 68 | 69 | QUnit.asyncTest('Slider.start', function(assert){ 70 | var slider = new IdealImageSlider.Slider({ 71 | selector: '.slider-default', 72 | interval: 600 73 | }); 74 | slider.start(); 75 | 76 | setTimeout(function() { 77 | assert.equal(slider.get('currentSlide').dataset.index, 2, 'Current slide is correct'); 78 | QUnit.start(); 79 | }, 1000); 80 | }); 81 | 82 | QUnit.asyncTest('Slider.stop', function(assert){ 83 | var slider = new IdealImageSlider.Slider({ 84 | selector: '.slider-default', 85 | interval: 600 86 | }); 87 | slider.start(); 88 | 89 | setTimeout(function() { 90 | slider.stop(); 91 | assert.equal(slider.get('currentSlide').dataset.index, 2, 'Current slide is correct'); 92 | QUnit.start(); 93 | }, 1000); 94 | }); 95 | -------------------------------------------------------------------------------- /themes/default/default.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Ideal Image Slider Default Theme 3 | * Version: 1.2.0 4 | */ 5 | 6 | .ideal-image-slider { 7 | background-color: #fff; 8 | background-image: url("data:image/gif;base64,R0lGODlhIAAgAPMAAP///wAAAMbGxoSEhLa2tpqamjY2NlZWVtjY2OTk5Ly8vB4eHgQEBAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHRLYKhKP1oZmADdEAAAh+QQACgABACwAAAAAIAAgAAAE6hDISWlZpOrNp1lGNRSdRpDUolIGw5RUYhhHukqFu8DsrEyqnWThGvAmhVlteBvojpTDDBUEIFwMFBRAmBkSgOrBFZogCASwBDEY/CZSg7GSE0gSCjQBMVG023xWBhklAnoEdhQEfyNqMIcKjhRsjEdnezB+A4k8gTwJhFuiW4dokXiloUepBAp5qaKpp6+Ho7aWW54wl7obvEe0kRuoplCGepwSx2jJvqHEmGt6whJpGpfJCHmOoNHKaHx61WiSR92E4lbFoq+B6QDtuetcaBPnW6+O7wDHpIiK9SaVK5GgV543tzjgGcghAgAh+QQACgACACwAAAAAIAAgAAAE7hDISSkxpOrN5zFHNWRdhSiVoVLHspRUMoyUakyEe8PTPCATW9A14E0UvuAKMNAZKYUZCiBMuBakSQKG8G2FzUWox2AUtAQFcBKlVQoLgQReZhQlCIJesQXI5B0CBnUMOxMCenoCfTCEWBsJColTMANldx15BGs8B5wlCZ9Po6OJkwmRpnqkqnuSrayqfKmqpLajoiW5HJq7FL1Gr2mMMcKUMIiJgIemy7xZtJsTmsM4xHiKv5KMCXqfyUCJEonXPN2rAOIAmsfB3uPoAK++G+w48edZPK+M6hLJpQg484enXIdQFSS1u6UhksENEQAAIfkEAAoAAwAsAAAAACAAIAAABOcQyEmpGKLqzWcZRVUQnZYg1aBSh2GUVEIQ2aQOE+G+cD4ntpWkZQj1JIiZIogDFFyHI0UxQwFugMSOFIPJftfVAEoZLBbcLEFhlQiqGp1Vd140AUklUN3eCA51C1EWMzMCezCBBmkxVIVHBWd3HHl9JQOIJSdSnJ0TDKChCwUJjoWMPaGqDKannasMo6WnM562R5YluZRwur0wpgqZE7NKUm+FNRPIhjBJxKZteWuIBMN4zRMIVIhffcgojwCF117i4nlLnY5ztRLsnOk+aV+oJY7V7m76PdkS4trKcdg0Zc0tTcKkRAAAIfkEAAoABAAsAAAAACAAIAAABO4QyEkpKqjqzScpRaVkXZWQEximw1BSCUEIlDohrft6cpKCk5xid5MNJTaAIkekKGQkWyKHkvhKsR7ARmitkAYDYRIbUQRQjWBwJRzChi9CRlBcY1UN4g0/VNB0AlcvcAYHRyZPdEQFYV8ccwR5HWxEJ02YmRMLnJ1xCYp0Y5idpQuhopmmC2KgojKasUQDk5BNAwwMOh2RtRq5uQuPZKGIJQIGwAwGf6I0JXMpC8C7kXWDBINFMxS4DKMAWVWAGYsAdNqW5uaRxkSKJOZKaU3tPOBZ4DuK2LATgJhkPJMgTwKCdFjyPHEnKxFCDhEAACH5BAAKAAUALAAAAAAgACAAAATzEMhJaVKp6s2nIkolIJ2WkBShpkVRWqqQrhLSEu9MZJKK9y1ZrqYK9WiClmvoUaF8gIQSNeF1Er4MNFn4SRSDARWroAIETg1iVwuHjYB1kYc1mwruwXKC9gmsJXliGxc+XiUCby9ydh1sOSdMkpMTBpaXBzsfhoc5l58Gm5yToAaZhaOUqjkDgCWNHAULCwOLaTmzswadEqggQwgHuQsHIoZCHQMMQgQGubVEcxOPFAcMDAYUA85eWARmfSRQCdcMe0zeP1AAygwLlJtPNAAL19DARdPzBOWSm1brJBi45soRAWQAAkrQIykShQ9wVhHCwCQCACH5BAAKAAYALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiRMDjI0Fd30/iI2UA5GSS5UDj2l6NoqgOgN4gksEBgYFf0FDqKgHnyZ9OX8HrgYHdHpcHQULXAS2qKpENRg7eAMLC7kTBaixUYFkKAzWAAnLC7FLVxLWDBLKCwaKTULgEwbLA4hJtOkSBNqITT3xEgfLpBtzE/jiuL04RGEBgwWhShRgQExHBAAh+QQACgAHACwAAAAAIAAgAAAE7xDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfZiCqGk5dTESJeaOAlClzsJsqwiJwiqnFrb2nS9kmIcgEsjQydLiIlHehhpejaIjzh9eomSjZR+ipslWIRLAgMDOR2DOqKogTB9pCUJBagDBXR6XB0EBkIIsaRsGGMMAxoDBgYHTKJiUYEGDAzHC9EACcUGkIgFzgwZ0QsSBcXHiQvOwgDdEwfFs0sDzt4S6BK4xYjkDOzn0unFeBzOBijIm1Dgmg5YFQwsCMjp1oJ8LyIAACH5BAAKAAgALAAAAAAgACAAAATwEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GGl6NoiPOH16iZKNlH6KmyWFOggHhEEvAwwMA0N9GBsEC6amhnVcEwavDAazGwIDaH1ipaYLBUTCGgQDA8NdHz0FpqgTBwsLqAbWAAnIA4FWKdMLGdYGEgraigbT0OITBcg5QwPT4xLrROZL6AuQAPUS7bxLpoWidY0JtxLHKhwwMJBTHgPKdEQAACH5BAAKAAkALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq+E71SRQeyqUToLA7VxF0JDyIQh/MVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GAULDJCRiXo1CpGXDJOUjY+Yip9DhToJA4RBLwMLCwVDfRgbBAaqqoZ1XBMHswsHtxtFaH1iqaoGNgAIxRpbFAgfPQSqpbgGBqUD1wBXeCYp1AYZ19JJOYgH1KwA4UBvQwXUBxPqVD9L3sbp2BNk2xvvFPJd+MFCN6HAAIKgNggY0KtEBAAh+QQACgAKACwAAAAAIAAgAAAE6BDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfYIDMaAFdTESJeaEDAIMxYFqrOUaNW4E4ObYcCXaiBVEgULe0NJaxxtYksjh2NLkZISgDgJhHthkpU4mW6blRiYmZOlh4JWkDqILwUGBnE6TYEbCgevr0N1gH4At7gHiRpFaLNrrq8HNgAJA70AWxQIH1+vsYMDAzZQPC9VCNkDWUhGkuE5PxJNwiUK4UfLzOlD4WvzAHaoG9nxPi5d+jYUqfAhhykOFwJWiAAAIfkEAAoACwAsAAAAACAAIAAABPAQyElpUqnqzaciSoVkXVUMFaFSwlpOCcMYlErAavhOMnNLNo8KsZsMZItJEIDIFSkLGQoQTNhIsFehRww2CQLKF0tYGKYSg+ygsZIuNqJksKgbfgIGepNo2cIUB3V1B3IvNiBYNQaDSTtfhhx0CwVPI0UJe0+bm4g5VgcGoqOcnjmjqDSdnhgEoamcsZuXO1aWQy8KAwOAuTYYGwi7w5h+Kr0SJ8MFihpNbx+4Erq7BYBuzsdiH1jCAzoSfl0rVirNbRXlBBlLX+BP0XJLAPGzTkAuAOqb0WT5AH7OcdCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA=="); 9 | background-repeat: no-repeat; 10 | background-position: 50% 50%; 11 | background-size: 32px 32px; 12 | } 13 | 14 | /* Navigation */ 15 | .iis-previous-nav, 16 | .iis-next-nav { 17 | position: absolute; 18 | top: 50%; 19 | z-index: 20; 20 | display: block; 21 | width: 60px; 22 | height: 60px; 23 | text-indent: -9999px; 24 | background-repeat: no-repeat; 25 | background-color: rgba(0,0,0,0.5); 26 | border-radius: 50px; 27 | background-size: 48px 48px; 28 | cursor: pointer; 29 | opacity: 0; 30 | -webkit-transform: translateY(-50%); 31 | -ms-transform: translateY(-50%); 32 | transform: translateY(-50%); 33 | -webkit-transition: 0.3s ease-out; 34 | -moz-transition: 0.3s ease-out; 35 | -o-transition: 0.3s ease-out; 36 | transition: 0.3s ease-out; 37 | } 38 | .iis-previous-nav { 39 | left: 5%; 40 | background-position: 35% 50%; 41 | background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUxMiIgaGVpZ2h0PSI1MTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHBvbHlnb24gZmlsbD0iI2ZmZmZmZiIgaWQ9InN2Z18xIiBwb2ludHM9IjM1MiwxMTUuNCAzMzEuMyw5NiAxNjAsMjU2IDMzMS4zLDQxNiAzNTIsMzk2LjcgMjAxLjUsMjU2ICIvPgogPC9nPgo8L3N2Zz4="); 42 | } 43 | .iis-next-nav { 44 | right: 5%; 45 | background-position: 65% 50%; 46 | background-image: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIj8+Cjxzdmcgd2lkdGg9IjUxMiIgaGVpZ2h0PSI1MTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHBvbHlnb24gZmlsbD0iI2ZmZmZmZiIgaWQ9InN2Z18xIiBwb2ludHM9IjE2MCwxMTUuNCAxODAuNyw5NiAzNTIsMjU2IDE4MC43LDQxNiAxNjAsMzk2LjcgMzEwLjUsMjU2ICIvPgogPC9nPgo8L3N2Zz4="); 47 | } 48 | .ideal-image-slider:hover .iis-previous-nav, 49 | .ideal-image-slider:hover .iis-next-nav { opacity: 0.5; } 50 | .ideal-image-slider:hover .iis-previous-nav:hover, 51 | .ideal-image-slider:hover .iis-next-nav:hover { opacity: 1.0; } 52 | 53 | /* Bullet Navigation */ 54 | .iis-bullet-nav { 55 | position: absolute; 56 | bottom: 5%; 57 | right: 5%; 58 | z-index: 15; 59 | width: 90%; 60 | text-align: right; 61 | opacity: 0.4; 62 | -webkit-transition: 0.3s ease-out; 63 | -moz-transition: 0.3s ease-out; 64 | -o-transition: 0.3s ease-out; 65 | transition: 0.3s ease-out; 66 | } 67 | .iis-has-captions .iis-bullet-nav { max-width: 42%; } 68 | .iis-bullet-nav a { 69 | display: inline-block; 70 | width: 10px; 71 | height: 10px; 72 | background: transparent; 73 | text-indent: 9999px; 74 | margin: 0 5px; 75 | border: 3px solid rgba(0,0,0,0.5); 76 | border-radius: 10px; 77 | cursor: pointer; 78 | -webkit-transition: 0.3s ease-out; 79 | -moz-transition: 0.3s ease-out; 80 | -o-transition: 0.3s ease-out; 81 | transition: 0.3s ease-out; 82 | } 83 | .iis-bullet-nav a.iis-bullet-active, 84 | .iis-bullet-nav a:hover { background: #fff; } 85 | .ideal-image-slider:hover .iis-bullet-nav { opacity: 0.7; } 86 | .ideal-image-slider:hover .iis-bullet-nav:hover { opacity: 1.0; } 87 | 88 | /* Captions */ 89 | .iis-has-captions .iis-slide { text-indent: 0; } 90 | .iis-caption { 91 | position: absolute; 92 | left: 5%; 93 | bottom: 5%; 94 | max-width: 90%; 95 | z-index: 10; 96 | background: #000; 97 | background: rgba(0,0,0,0.5); 98 | padding: 5px 15px; 99 | border-radius: 10px; 100 | font: 14px/1.6em "Helvetica Neue", Helvetica, Arial, sans-serif; 101 | color: #fff; 102 | -webkit-box-sizing: border-box; 103 | -moz-box-sizing: border-box; 104 | box-sizing: border-box; 105 | } 106 | .iis-has-bullet-nav .iis-caption { max-width: 42%; } 107 | .iis-caption .iis-caption-title { font-weight: bold; } 108 | .iis-caption .iis-caption-content { 109 | font-size: 13px; 110 | line-height: 1.6em; 111 | color: #eee; 112 | } 113 | .iis-caption .iis-caption-content a, 114 | .iis-caption .iis-caption-content a:visited { 115 | color: #eee; 116 | text-decoration: underline; 117 | border: 0; 118 | } 119 | .iis-caption .iis-caption-content a:hover, 120 | .iis-caption .iis-caption-content a:active { 121 | color: #fff; 122 | } 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ideal Image Slider 2 | 3 | The aim behind the Ideal Image Slider is to create a slider which has just the right amount of features, 4 | with no bloat and be easy to extend so that more features can be added as "extensions". Here are the ideals 5 | and core features I wanted to include: 6 | 7 | * HTML5 (SEO optimised) 8 | * CSS3 transitions (a few simple transitions like slide/fade) 9 | * Left/Right navigation (including touch/swipe support) 10 | * Responsive 11 | * HiDPI (retina) support 12 | * ARIA support 13 | * Extremely simple to setup (no dependencies) 14 | * Very extensible 15 | * Uses progressive enhancement 16 | * Open source (goes without saying) 17 | 18 | And, as an example, here are some features that *should not* be in the core and could be optional extensions: 19 | 20 | * Themes or skins 21 | * More transitions 22 | * Bullet navigation 23 | * Thumbnail navigation 24 | * Full screen slider 25 | * Video/Audio support 26 | * etc... 27 | 28 | [Read the original blog post →](http://gilbert.pellegrom.me/the-ideal-image-slider) 29 | 30 | ## Demos 31 | 32 | * [Standard Slider](http://idealimageslider.com/demo/standard-slider.html) 33 | * [With Links](http://idealimageslider.com/demo/links.html) 34 | * [Using the API](http://idealimageslider.com/demo/using-the-api.html) 35 | * [Using Events](http://idealimageslider.com/demo/using-events.html) 36 | * [Multiple Sliders](http://idealimageslider.com/demo/multiple-sliders.html) 37 | 38 | ## Extensions 39 | 40 | * [Bullet Navigation](https://github.com/gilbitron/Ideal-Image-Slider/tree/master/extensions/bullet-nav) 41 | * [Captions](https://github.com/gilbitron/Ideal-Image-Slider/tree/master/extensions/captions) 42 | * [Third Party Extensions](https://github.com/gilbitron/Ideal-Image-Slider/wiki/Third-Party-Extensions) 43 | 44 | ## Requirements 45 | 46 | * **None** 47 | 48 | Ideal Image Slider is written in vanilla JS and has no dependancies. 49 | 50 | ## Getting Started 51 | 52 | To install the slider you can either manually download this repository or you can use [Bower](http://bower.io) 53 | and run the following command: 54 | 55 | ``` 56 | bower install ideal-image-slider --save 57 | ``` 58 | 59 | Next you need to include the CSS file in the `` section of your HTML and you need to include the script 60 | before the `` tag in your HTML. Note you can optionally include a theme CSS file in the `` too. 61 | 62 | ```html 63 | 64 | 65 | ... 66 | 67 | 68 | ... 69 | 70 | 71 | ... 72 | 73 | 74 | 75 | ``` 76 | 77 | Next you need to set up your slider HTML where you want it to appear in your page. It should look something 78 | like this: 79 | 80 | ```html 81 |
82 | Minimum required attributes 83 | Use data-src for on-demand loading 84 | Use data-src-2x for HiDPI devices 85 | Links work too 86 | ... 87 |
88 | ``` 89 | 90 | There a few things to note about the structure of the images in your slider: 91 | 92 | * This is an image slider, so only images are supported. Any other content will be removed. 93 | * You can use the `data-src` attribute to load your images "on-demand" (i.e. images are not loaded until they are required). 94 | * The first image should not use `data-src` so it is loaded if no JS is detected. 95 | * If you specify a `data-src-2x` image, it will be used on devices that support HiDPI (such as Apple's retina devices). 96 | 97 | Finally you can create your slider by using the following Javascript: 98 | 99 | ```js 100 | new IdealImageSlider.Slider('#slider'); 101 | ``` 102 | 103 | If you want to tweak the settings or use the slider API it would look more like: 104 | 105 | ```js 106 | var slider = new IdealImageSlider.Slider({ 107 | selector: '#slider', 108 | height: 400, // Required but can be set by CSS 109 | interval: 4000 110 | }); 111 | slider.start(); 112 | ``` 113 | 114 | Note: If you don't pass a `height` to the Javascript constructor you **must** set it 115 | in your CSS. 116 | 117 | ## Settings 118 | 119 | |Setting|Default Value|Description| 120 | |---|---|---| 121 | |selector|`''`|CSS selector for the slider| 122 | |height|`'auto'`|Height of the slider. Can be `'auto'` (height changes depending on the height of the slide), a fixed px value (e.g. `400`) or an aspect ratio (e.g. `'16:9'`)| 123 | |initialHeight|`400`|If height is `'auto'` or an aspect ratio this is the height of the slider while the first image is loading| 124 | |maxHeight|`null`|If height is `'auto'` or an aspect ratio this is an optional max height in px for the slider (e.g. `800`)| 125 | |interval|`4000`|Time (in ms) to wait before changing to the next slide| 126 | |transitionDuration|`700`|Duration (in ms) of animated transition| 127 | |effect|`'slide'`|Transition effect (slide/fade by default)| 128 | |disableNav|`false`|Toggle the previous/next navigation (also disables touch and keyboard navigation)| 129 | |keyboardNav|`true`|Toggle keyboard navigation| 130 | |previousNavSelector|`''`|Selector for custom previous nav element| 131 | |nextNavSelector|`''`|Selector for custom next nav element| 132 | |classes|`{...}`|List of classes to be used by slider. Probably shouldn't be changed| 133 | 134 | ## Events 135 | 136 | Event callback functions can be passed in with the settings. For example: 137 | 138 | ```js 139 | new IdealImageSlider.Slider({ 140 | selector: '#slider', 141 | onStart: function(){ 142 | console.log('onStart'); 143 | } 144 | }); 145 | ``` 146 | 147 | |Event|Description| 148 | |---|---| 149 | |onInit|Callback that fires when slider and first image have loaded| 150 | |onStart|Callback that fires when slider has started playing| 151 | |onStop|Callback that fires when slider has stopped playing| 152 | |onDestroy|Callback that fires when slider is destroyed| 153 | |beforeChange|Callback that fires before a slide has changed| 154 | |afterChange|Callback that fires after a slide has changed| 155 | 156 | ## API 157 | 158 | To use the API methods you must store the slider object. For example: 159 | 160 | ```js 161 | var slider = new IdealImageSlider.Slider('#slider'); 162 | slider.start(); 163 | ``` 164 | 165 | |Method|Description| 166 | |---|---| 167 | |start()|Start the slider. Note the slider will automatically be stopped when navigation is used| 168 | |stop()|Stop the slider| 169 | |previousSlide()|Change to the previous slide| 170 | |nextSlide()|Change to the next slide| 171 | |gotoSlide(index)|Change to a specific slide (1 indexed)| 172 | |destroy()|Destroy the slider| 173 | |get(attribute)|Get an attribute value (attributes are mostly used internally)| 174 | |set(attribute, value)|Set an attribute. Can be useful for storing custom data| 175 | 176 | ## Browsers 177 | 178 | Ideal Image Slider has been tested on: 179 | 180 | * Chrome 181 | * Firefox 182 | * Safari (Desktop + Mobile) 183 | * Opera 184 | * IE9+ 185 | 186 | ## Contribute 187 | 188 | So you want to help out? That's awesome. Here is how you can do it: 189 | 190 | * [Report a bug](https://github.com/gilbitron/Ideal-Image-Slider/labels/bug) 191 | * [Ask for a feature](https://github.com/gilbitron/Ideal-Image-Slider/labels/enhancement) 192 | * [Submit a pull request](https://github.com/gilbitron/Ideal-Image-Slider/pulls) 193 | 194 | If you are submitting a pull request please adhere to the existing coding standards used throughout the code 195 | and only submit **1 feature/fix per pull request**. Pull requests containing multiple changes will be rejected. 196 | 197 | Note that if you submit a pull request you are aware that you are contributing to both the free (open source) version 198 | and the proprietary (commercial) version of the codebase and that your work may make money for Dev7studios. 199 | 200 | ## Credits 201 | 202 | Ideal Image Slider was created by [Gilbert Pellegrom](http://gilbert.pellegrom.me) from 203 | [Dev7studios](http://dev7studios.com). Released under the [GPL license](https://raw.githubusercontent.com/gilbitron/Ideal-Image-Slider/master/LICENSE). 204 | 205 | ## Other Projects 206 | 207 | Check-out other stuff that we are working on : 208 | 209 | * [ThemeIsle](https://themeisle.com) 210 | * [Codeinwp](https://codeinwp.com/blog/) 211 | * [Revive.social](https://revive.social) 212 | * [FinMasters](https://finmasters.com) 213 | 214 | -------------------------------------------------------------------------------- /example/css/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.1 | MIT License | git.io/normalize */ 2 | 3 | /** 4 | * 1. Set default font family to sans-serif. 5 | * 2. Prevent iOS text size adjust after orientation change, without disabling 6 | * user zoom. 7 | */ 8 | 9 | html { 10 | font-family: sans-serif; /* 1 */ 11 | -ms-text-size-adjust: 100%; /* 2 */ 12 | -webkit-text-size-adjust: 100%; /* 2 */ 13 | } 14 | 15 | /** 16 | * Remove default margin. 17 | */ 18 | 19 | body { 20 | margin: 0; 21 | } 22 | 23 | /* HTML5 display definitions 24 | ========================================================================== */ 25 | 26 | /** 27 | * Correct `block` display not defined for any HTML5 element in IE 8/9. 28 | * Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. 29 | * Correct `block` display not defined for `main` in IE 11. 30 | */ 31 | 32 | article, 33 | aside, 34 | details, 35 | figcaption, 36 | figure, 37 | footer, 38 | header, 39 | hgroup, 40 | main, 41 | nav, 42 | section, 43 | summary { 44 | display: block; 45 | } 46 | 47 | /** 48 | * 1. Correct `inline-block` display not defined in IE 8/9. 49 | * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. 50 | */ 51 | 52 | audio, 53 | canvas, 54 | progress, 55 | video { 56 | display: inline-block; /* 1 */ 57 | vertical-align: baseline; /* 2 */ 58 | } 59 | 60 | /** 61 | * Prevent modern browsers from displaying `audio` without controls. 62 | * Remove excess height in iOS 5 devices. 63 | */ 64 | 65 | audio:not([controls]) { 66 | display: none; 67 | height: 0; 68 | } 69 | 70 | /** 71 | * Address `[hidden]` styling not present in IE 8/9/10. 72 | * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. 73 | */ 74 | 75 | [hidden], 76 | template { 77 | display: none; 78 | } 79 | 80 | /* Links 81 | ========================================================================== */ 82 | 83 | /** 84 | * Remove the gray background color from active links in IE 10. 85 | */ 86 | 87 | a { 88 | background: transparent; 89 | } 90 | 91 | /** 92 | * Improve readability when focused and also mouse hovered in all browsers. 93 | */ 94 | 95 | a:active, 96 | a:hover { 97 | outline: 0; 98 | } 99 | 100 | /* Text-level semantics 101 | ========================================================================== */ 102 | 103 | /** 104 | * Address styling not present in IE 8/9/10/11, Safari, and Chrome. 105 | */ 106 | 107 | abbr[title] { 108 | border-bottom: 1px dotted; 109 | } 110 | 111 | /** 112 | * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. 113 | */ 114 | 115 | b, 116 | strong { 117 | font-weight: bold; 118 | } 119 | 120 | /** 121 | * Address styling not present in Safari and Chrome. 122 | */ 123 | 124 | dfn { 125 | font-style: italic; 126 | } 127 | 128 | /** 129 | * Address variable `h1` font-size and margin within `section` and `article` 130 | * contexts in Firefox 4+, Safari, and Chrome. 131 | */ 132 | 133 | h1 { 134 | font-size: 2em; 135 | margin: 0.67em 0; 136 | } 137 | 138 | /** 139 | * Address styling not present in IE 8/9. 140 | */ 141 | 142 | mark { 143 | background: #ff0; 144 | color: #000; 145 | } 146 | 147 | /** 148 | * Address inconsistent and variable font size in all browsers. 149 | */ 150 | 151 | small { 152 | font-size: 80%; 153 | } 154 | 155 | /** 156 | * Prevent `sub` and `sup` affecting `line-height` in all browsers. 157 | */ 158 | 159 | sub, 160 | sup { 161 | font-size: 75%; 162 | line-height: 0; 163 | position: relative; 164 | vertical-align: baseline; 165 | } 166 | 167 | sup { 168 | top: -0.5em; 169 | } 170 | 171 | sub { 172 | bottom: -0.25em; 173 | } 174 | 175 | /* Embedded content 176 | ========================================================================== */ 177 | 178 | /** 179 | * Remove border when inside `a` element in IE 8/9/10. 180 | */ 181 | 182 | img { 183 | border: 0; 184 | } 185 | 186 | /** 187 | * Correct overflow not hidden in IE 9/10/11. 188 | */ 189 | 190 | svg:not(:root) { 191 | overflow: hidden; 192 | } 193 | 194 | /* Grouping content 195 | ========================================================================== */ 196 | 197 | /** 198 | * Address margin not present in IE 8/9 and Safari. 199 | */ 200 | 201 | figure { 202 | margin: 1em 40px; 203 | } 204 | 205 | /** 206 | * Address differences between Firefox and other browsers. 207 | */ 208 | 209 | hr { 210 | -moz-box-sizing: content-box; 211 | box-sizing: content-box; 212 | height: 0; 213 | } 214 | 215 | /** 216 | * Contain overflow in all browsers. 217 | */ 218 | 219 | pre { 220 | overflow: auto; 221 | } 222 | 223 | /** 224 | * Address odd `em`-unit font size rendering in all browsers. 225 | */ 226 | 227 | code, 228 | kbd, 229 | pre, 230 | samp { 231 | font-family: monospace, monospace; 232 | font-size: 1em; 233 | } 234 | 235 | /* Forms 236 | ========================================================================== */ 237 | 238 | /** 239 | * Known limitation: by default, Chrome and Safari on OS X allow very limited 240 | * styling of `select`, unless a `border` property is set. 241 | */ 242 | 243 | /** 244 | * 1. Correct color not being inherited. 245 | * Known issue: affects color of disabled elements. 246 | * 2. Correct font properties not being inherited. 247 | * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. 248 | */ 249 | 250 | button, 251 | input, 252 | optgroup, 253 | select, 254 | textarea { 255 | color: inherit; /* 1 */ 256 | font: inherit; /* 2 */ 257 | margin: 0; /* 3 */ 258 | } 259 | 260 | /** 261 | * Address `overflow` set to `hidden` in IE 8/9/10/11. 262 | */ 263 | 264 | button { 265 | overflow: visible; 266 | } 267 | 268 | /** 269 | * Address inconsistent `text-transform` inheritance for `button` and `select`. 270 | * All other form control elements do not inherit `text-transform` values. 271 | * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. 272 | * Correct `select` style inheritance in Firefox. 273 | */ 274 | 275 | button, 276 | select { 277 | text-transform: none; 278 | } 279 | 280 | /** 281 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` 282 | * and `video` controls. 283 | * 2. Correct inability to style clickable `input` types in iOS. 284 | * 3. Improve usability and consistency of cursor style between image-type 285 | * `input` and others. 286 | */ 287 | 288 | button, 289 | html input[type="button"], /* 1 */ 290 | input[type="reset"], 291 | input[type="submit"] { 292 | -webkit-appearance: button; /* 2 */ 293 | cursor: pointer; /* 3 */ 294 | } 295 | 296 | /** 297 | * Re-set default cursor for disabled elements. 298 | */ 299 | 300 | button[disabled], 301 | html input[disabled] { 302 | cursor: default; 303 | } 304 | 305 | /** 306 | * Remove inner padding and border in Firefox 4+. 307 | */ 308 | 309 | button::-moz-focus-inner, 310 | input::-moz-focus-inner { 311 | border: 0; 312 | padding: 0; 313 | } 314 | 315 | /** 316 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in 317 | * the UA stylesheet. 318 | */ 319 | 320 | input { 321 | line-height: normal; 322 | } 323 | 324 | /** 325 | * It's recommended that you don't attempt to style these elements. 326 | * Firefox's implementation doesn't respect box-sizing, padding, or width. 327 | * 328 | * 1. Address box sizing set to `content-box` in IE 8/9/10. 329 | * 2. Remove excess padding in IE 8/9/10. 330 | */ 331 | 332 | input[type="checkbox"], 333 | input[type="radio"] { 334 | box-sizing: border-box; /* 1 */ 335 | padding: 0; /* 2 */ 336 | } 337 | 338 | /** 339 | * Fix the cursor style for Chrome's increment/decrement buttons. For certain 340 | * `font-size` values of the `input`, it causes the cursor style of the 341 | * decrement button to change from `default` to `text`. 342 | */ 343 | 344 | input[type="number"]::-webkit-inner-spin-button, 345 | input[type="number"]::-webkit-outer-spin-button { 346 | height: auto; 347 | } 348 | 349 | /** 350 | * 1. Address `appearance` set to `searchfield` in Safari and Chrome. 351 | * 2. Address `box-sizing` set to `border-box` in Safari and Chrome 352 | * (include `-moz` to future-proof). 353 | */ 354 | 355 | input[type="search"] { 356 | -webkit-appearance: textfield; /* 1 */ 357 | -moz-box-sizing: content-box; 358 | -webkit-box-sizing: content-box; /* 2 */ 359 | box-sizing: content-box; 360 | } 361 | 362 | /** 363 | * Remove inner padding and search cancel button in Safari and Chrome on OS X. 364 | * Safari (but not Chrome) clips the cancel button when the search input has 365 | * padding (and `textfield` appearance). 366 | */ 367 | 368 | input[type="search"]::-webkit-search-cancel-button, 369 | input[type="search"]::-webkit-search-decoration { 370 | -webkit-appearance: none; 371 | } 372 | 373 | /** 374 | * Define consistent border, margin, and padding. 375 | */ 376 | 377 | fieldset { 378 | border: 1px solid #c0c0c0; 379 | margin: 0 2px; 380 | padding: 0.35em 0.625em 0.75em; 381 | } 382 | 383 | /** 384 | * 1. Correct `color` not being inherited in IE 8/9/10/11. 385 | * 2. Remove padding so people aren't caught out if they zero out fieldsets. 386 | */ 387 | 388 | legend { 389 | border: 0; /* 1 */ 390 | padding: 0; /* 2 */ 391 | } 392 | 393 | /** 394 | * Remove default vertical scrollbar in IE 8/9/10/11. 395 | */ 396 | 397 | textarea { 398 | overflow: auto; 399 | } 400 | 401 | /** 402 | * Don't inherit the `font-weight` (applied by a rule above). 403 | * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. 404 | */ 405 | 406 | optgroup { 407 | font-weight: bold; 408 | } 409 | 410 | /* Tables 411 | ========================================================================== */ 412 | 413 | /** 414 | * Remove most spacing between table cells. 415 | */ 416 | 417 | table { 418 | border-collapse: collapse; 419 | border-spacing: 0; 420 | } 421 | 422 | td, 423 | th { 424 | padding: 0; 425 | } 426 | -------------------------------------------------------------------------------- /ideal-image-slider.min.js: -------------------------------------------------------------------------------- 1 | /*! Ideal Image Slider v1.5.1 */ 2 | var IdealImageSlider=function(){"use strict";var a=function(a,b){return a["r"+b]||a["webkitR"+b]||a["mozR"+b]||a["msR"+b]||function(a){setTimeout(a,1e3/60)}}(window,"equestAnimationFrame"),b=function(b,c){function d(){var g=(new Date).getTime(),h=g-e;h>=c?b.call():f.value=a(d)}var e=(new Date).getTime(),f={};return f.value=a(d),f},c=function(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return void 0!==b&&null!==b&&c===a},d=function(a){return Math.round(a)===a},e=function(a){a=a||{};for(var b=1;b1?!0:window.matchMedia&&window.matchMedia(a).matches?!0:!1},m=function(a,b,c){a.style.webkitTransitionDuration=a.style.MozTransitionDuration=a.style.msTransitionDuration=a.style.OTransitionDuration=a.style.transitionDuration=c+"ms",a.style.webkitTransform=a.style.MozTransform=a.style.msTransform=a.style.OTransform="translateX("+b+"px)"},n=function(a){a.style.removeProperty("-webkit-transition-duration"),a.style.removeProperty("transition-duration"),a.style.removeProperty("-webkit-transform"),a.style.removeProperty("-ms-transform"),a.style.removeProperty("transform")},o=function(b){var c=b.time,d=+new Date+c,e=function(){var f=+new Date,g=d-f;if(60>g)return void b.run(1);var h=1-g/c;b.run(h),a(e)};e()},p=function(a,b){if("undefined"==typeof b&&(b=!0),!d(a.settings.height)){var c=Math.round(a._attributes.container.offsetHeight),e=c;if(a._attributes.aspectWidth&&a._attributes.aspectHeight)e=a._attributes.aspectHeight/a._attributes.aspectWidth*a._attributes.container.offsetWidth;else{var f=a._attributes.currentSlide.getAttribute("data-actual-width"),g=a._attributes.currentSlide.getAttribute("data-actual-height");f&&g&&(e=g/f*a._attributes.container.offsetWidth)}var h=parseInt(a.settings.maxHeight,10);h&&e>h&&(e=h),e=Math.round(e),e!==c&&(b?o({time:a.settings.transitionDuration,run:function(b){a._attributes.container.style.height=Math.round(b*(e-c)+c)+"px"}}):a._attributes.container.style.height=e+"px")}},q={vars:{start:{},delta:{},isScrolling:void 0,direction:null},start:function(a){if(!f(this._attributes.container,this.settings.classes.animating)){var b=a.touches[0];q.vars.start={x:b.pageX,y:b.pageY,time:+new Date},q.vars.delta={},q.vars.isScrolling=void 0,q.vars.direction=null,this.stop(),this.settings.beforeChange.apply(this),g(this._attributes.container,this.settings.classes.touching)}},move:function(a){if(!f(this._attributes.container,this.settings.classes.animating)&&!(a.touches.length>1||a.scale&&1!==a.scale)){var b=a.touches[0];q.vars.delta={x:b.pageX-q.vars.start.x,y:b.pageY-q.vars.start.y},"undefined"==typeof q.vars.isScrolling&&(q.vars.isScrolling=!!(q.vars.isScrolling||Math.abs(q.vars.delta.x)20||Math.abs(q.vars.delta.x)>this._attributes.currentSlide.offsetWidth/2,e=q.vars.delta.x<0?"next":"previous",i=this.settings.transitionDuration?this.settings.transitionDuration/2:0;q.vars.isScrolling||(d?(q.vars.direction=e,"next"==q.vars.direction?(m(this._attributes.currentSlide,-this._attributes.currentSlide.offsetWidth,i),m(this._attributes.nextSlide,0,i)):(m(this._attributes.previousSlide,0,i),m(this._attributes.currentSlide,this._attributes.currentSlide.offsetWidth,i)),b(q.transitionEnd.bind(this),i)):"next"==e?(m(this._attributes.currentSlide,0,i),m(this._attributes.nextSlide,this._attributes.currentSlide.offsetWidth,i)):(m(this._attributes.previousSlide,-this._attributes.previousSlide.offsetWidth,i),m(this._attributes.currentSlide,0,i)),i&&(g(this._attributes.container,this.settings.classes.animating),b(function(){h(this._attributes.container,this.settings.classes.animating)}.bind(this),i)))}},transitionEnd:function(a){if(q.vars.direction){n(this._attributes.previousSlide),n(this._attributes.currentSlide),n(this._attributes.nextSlide),h(this._attributes.container,this.settings.classes.touching),h(this._attributes.previousSlide,this.settings.classes.previousSlide),h(this._attributes.currentSlide,this.settings.classes.currentSlide),h(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true");var b=this._attributes.slides,c=b.indexOf(this._attributes.currentSlide);"next"==q.vars.direction?(this._attributes.previousSlide=this._attributes.currentSlide,this._attributes.currentSlide=b[c+1],this._attributes.nextSlide=b[c+2],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.nextSlide?(this._attributes.currentSlide=b[0],this._attributes.nextSlide=b[1]):"undefined"==typeof this._attributes.nextSlide&&(this._attributes.nextSlide=b[0]),k(this._attributes.nextSlide)):(this._attributes.nextSlide=this._attributes.currentSlide,this._attributes.previousSlide=b[c-2],this._attributes.currentSlide=b[c-1],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.previousSlide?(this._attributes.currentSlide=b[b.length-1],this._attributes.previousSlide=b[b.length-2]):"undefined"==typeof this._attributes.previousSlide&&(this._attributes.previousSlide=b[b.length-1]),k(this._attributes.previousSlide)),g(this._attributes.previousSlide,this.settings.classes.previousSlide),g(this._attributes.currentSlide,this.settings.classes.currentSlide),g(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),p(this),this.settings.afterChange.apply(this)}}},r=function(a){this.settings={selector:"",height:"auto",initialHeight:400,maxHeight:null,interval:4e3,transitionDuration:700,effect:"slide",disableNav:!1,keyboardNav:!0,previousNavSelector:"",nextNavSelector:"",classes:{container:"ideal-image-slider",slide:"iis-slide",previousSlide:"iis-previous-slide",currentSlide:"iis-current-slide",nextSlide:"iis-next-slide",previousNav:"iis-previous-nav",nextNav:"iis-next-nav",animating:"iis-is-animating",touchEnabled:"iis-touch-enabled",touching:"iis-is-touching",directionPrevious:"iis-direction-previous",directionNext:"iis-direction-next"},onInit:function(){},onStart:function(){},onStop:function(){},onDestroy:function(){},beforeChange:function(){},afterChange:function(){}},"string"==typeof a?this.settings.selector=a:"object"==typeof a&&e(this.settings,a);var b=document.querySelector(this.settings.selector);if(!b)return null;var c=i(b.children),h=[];b.innerHTML="",Array.prototype.forEach.call(c,function(a,c){if(a instanceof HTMLImageElement||a instanceof HTMLAnchorElement){var d=document.createElement("a"),f="",i="";if(a instanceof HTMLAnchorElement){f=a.getAttribute("href"),i=a.getAttribute("target");var j=a.querySelector("img");if(null===j)return;a=j}"undefined"!=typeof a.dataset?(e(d.dataset,a.dataset),a.dataset.src?d.dataset.src=a.dataset.src:d.dataset.src=a.src,l()&&a.dataset["src-2x"]&&(d.dataset.src=a.dataset["src-2x"])):a.getAttribute("data-src")?d.setAttribute("data-src",a.getAttribute("data-src")):d.setAttribute("data-src",a.getAttribute("src")),f&&d.setAttribute("href",f),i&&d.setAttribute("target",i),a.getAttribute("className")&&g(d,a.getAttribute("className")),a.getAttribute("id")&&d.setAttribute("id",a.getAttribute("id")),a.getAttribute("title")&&d.setAttribute("title",a.getAttribute("title")),a.getAttribute("alt")&&(d.innerHTML=a.getAttribute("alt")),d.setAttribute("role","tabpanel"),d.setAttribute("aria-hidden","true"),d.style.cssText+="-webkit-transition-duration:"+this.settings.transitionDuration+"ms;-moz-transition-duration:"+this.settings.transitionDuration+"ms;-o-transition-duration:"+this.settings.transitionDuration+"ms;transition-duration:"+this.settings.transitionDuration+"ms;",b.appendChild(d),h.push(d)}}.bind(this));var m=h;if(m.length<=1)return b.innerHTML="",Array.prototype.forEach.call(c,function(a,c){b.appendChild(a)}),null;if(!this.settings.disableNav){var n,o;this.settings.previousNavSelector?n=document.querySelector(this.settings.previousNavSelector):(n=document.createElement("a"),b.appendChild(n)),this.settings.nextNavSelector?o=document.querySelector(this.settings.nextNavSelector):(o=document.createElement("a"),b.appendChild(o)),g(n,this.settings.classes.previousNav),g(o,this.settings.classes.nextNav),j(n,"click",function(){return f(this._attributes.container,this.settings.classes.animating)?!1:(this.stop(),void this.previousSlide())}.bind(this)),j(o,"click",function(){return f(this._attributes.container,this.settings.classes.animating)?!1:(this.stop(),void this.nextSlide())}.bind(this)),("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)&&(this.settings.effect="slide",n.style.display="none",o.style.display="none",g(b,this.settings.classes.touchEnabled),j(b,"touchstart",q.start.bind(this),!1),j(b,"touchmove",q.move.bind(this),!1),j(b,"touchend",q.end.bind(this),!1)),this.settings.keyboardNav&&j(document,"keyup",function(a){a=a||window.event;var b="number"==typeof a.which?a.which:a.keyCode;if(37==b){if(f(this._attributes.container,this.settings.classes.animating))return!1;this.stop(),this.previousSlide()}else if(39==b){if(f(this._attributes.container,this.settings.classes.animating))return!1;this.stop(),this.nextSlide()}}.bind(this))}if(this._attributes={container:b,slides:m,previousSlide:"undefined"!=typeof m[m.length-1]?m[m.length-1]:m[0],currentSlide:m[0],nextSlide:"undefined"!=typeof m[1]?m[1]:m[0],timerId:0,origChildren:c,aspectWidth:0,aspectHeight:0},d(this.settings.height))this._attributes.container.style.height=this.settings.height+"px";else{if(d(this.settings.initialHeight)&&(this._attributes.container.style.height=this.settings.initialHeight+"px"),this.settings.height.indexOf(":")>-1){var r=this.settings.height.split(":");2==r.length&&d(parseInt(r[0],10))&&d(parseInt(r[1],10))&&(this._attributes.aspectWidth=parseInt(r[0],10),this._attributes.aspectHeight=parseInt(r[1],10))}j(window,"resize",function(){p(this,!1)}.bind(this))}g(b,this.settings.classes.container),g(b,"iis-effect-"+this.settings.effect),Array.prototype.forEach.call(this._attributes.slides,function(a,b){g(a,this.settings.classes.slide)}.bind(this)),g(this._attributes.previousSlide,this.settings.classes.previousSlide),g(this._attributes.currentSlide,this.settings.classes.currentSlide),g(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),k(this._attributes.currentSlide,function(){this.settings.onInit.apply(this),p(this,!1)}.bind(this)),k(this._attributes.previousSlide),k(this._attributes.nextSlide)};return r.prototype.get=function(a){return this._attributes?this._attributes.hasOwnProperty(a)?this._attributes[a]:void 0:null},r.prototype.set=function(a,b){return this._attributes?this._attributes[a]=b:null},r.prototype.start=function(){this._attributes&&(this._attributes.timerId=setInterval(this.nextSlide.bind(this),this.settings.interval),this.settings.onStart.apply(this),window.onblur=function(){this.stop()}.bind(this))},r.prototype.stop=function(){this._attributes&&(clearInterval(this._attributes.timerId),this._attributes.timerId=0,this.settings.onStop.apply(this))},r.prototype.previousSlide=function(){this.settings.beforeChange.apply(this),h(this._attributes.previousSlide,this.settings.classes.previousSlide),h(this._attributes.currentSlide,this.settings.classes.currentSlide),h(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true");var a=this._attributes.slides,c=a.indexOf(this._attributes.currentSlide);this._attributes.nextSlide=this._attributes.currentSlide,this._attributes.previousSlide=a[c-2],this._attributes.currentSlide=a[c-1],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.previousSlide?(this._attributes.currentSlide=a[a.length-1],this._attributes.previousSlide=a[a.length-2]):"undefined"==typeof this._attributes.previousSlide&&(this._attributes.previousSlide=a[a.length-1]),k(this._attributes.previousSlide),g(this._attributes.previousSlide,this.settings.classes.previousSlide),g(this._attributes.currentSlide,this.settings.classes.currentSlide),g(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),g(this._attributes.container,this.settings.classes.directionPrevious),b(function(){h(this._attributes.container,this.settings.classes.directionPrevious)}.bind(this),this.settings.transitionDuration),this.settings.transitionDuration&&(g(this._attributes.container,this.settings.classes.animating),b(function(){h(this._attributes.container,this.settings.classes.animating)}.bind(this),this.settings.transitionDuration)),p(this),this.settings.afterChange.apply(this)},r.prototype.nextSlide=function(){this.settings.beforeChange.apply(this),h(this._attributes.previousSlide,this.settings.classes.previousSlide),h(this._attributes.currentSlide,this.settings.classes.currentSlide),h(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true");var a=this._attributes.slides,c=a.indexOf(this._attributes.currentSlide);this._attributes.previousSlide=this._attributes.currentSlide,this._attributes.currentSlide=a[c+1],this._attributes.nextSlide=a[c+2],"undefined"==typeof this._attributes.currentSlide&&"undefined"==typeof this._attributes.nextSlide?(this._attributes.currentSlide=a[0],this._attributes.nextSlide=a[1]):"undefined"==typeof this._attributes.nextSlide&&(this._attributes.nextSlide=a[0]),k(this._attributes.nextSlide),g(this._attributes.previousSlide,this.settings.classes.previousSlide),g(this._attributes.currentSlide,this.settings.classes.currentSlide),g(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),g(this._attributes.container,this.settings.classes.directionNext),b(function(){h(this._attributes.container,this.settings.classes.directionNext)}.bind(this),this.settings.transitionDuration),this.settings.transitionDuration&&(g(this._attributes.container,this.settings.classes.animating),b(function(){h(this._attributes.container,this.settings.classes.animating)}.bind(this),this.settings.transitionDuration)),p(this),this.settings.afterChange.apply(this)},r.prototype.gotoSlide=function(a){this.settings.beforeChange.apply(this),this.stop(),h(this._attributes.previousSlide,this.settings.classes.previousSlide),h(this._attributes.currentSlide,this.settings.classes.currentSlide),h(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","true"),a--;var c=this._attributes.slides,d=c.indexOf(this._attributes.currentSlide);this._attributes.previousSlide=c[a-1],this._attributes.currentSlide=c[a],this._attributes.nextSlide=c[a+1],"undefined"==typeof this._attributes.previousSlide&&(this._attributes.previousSlide=c[c.length-1]),"undefined"==typeof this._attributes.nextSlide&&(this._attributes.nextSlide=c[0]),k(this._attributes.previousSlide),k(this._attributes.currentSlide),k(this._attributes.nextSlide),g(this._attributes.previousSlide,this.settings.classes.previousSlide),g(this._attributes.currentSlide,this.settings.classes.currentSlide),g(this._attributes.nextSlide,this.settings.classes.nextSlide),this._attributes.currentSlide.setAttribute("aria-hidden","false"),d>a?(g(this._attributes.container,this.settings.classes.directionPrevious),b(function(){h(this._attributes.container,this.settings.classes.directionPrevious)}.bind(this),this.settings.transitionDuration)):(g(this._attributes.container,this.settings.classes.directionNext),b(function(){h(this._attributes.container,this.settings.classes.directionNext)}.bind(this),this.settings.transitionDuration)),this.settings.transitionDuration&&(g(this._attributes.container,this.settings.classes.animating),b(function(){h(this._attributes.container,this.settings.classes.animating)}.bind(this),this.settings.transitionDuration)),p(this),this.settings.afterChange.apply(this)},r.prototype.destroy=function(){clearInterval(this._attributes.timerId),this._attributes.timerId=0,this._attributes.container.innerHTML="",Array.prototype.forEach.call(this._attributes.origChildren,function(a,b){this._attributes.container.appendChild(a)}.bind(this)),h(this._attributes.container,this.settings.classes.container),h(this._attributes.container,"iis-effect-"+this.settings.effect),this._attributes.container.style.height="",this.settings.onDestroy.apply(this)},{_hasClass:f,_addClass:g,_removeClass:h,Slider:r}}(); -------------------------------------------------------------------------------- /ideal-image-slider.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Ideal Image Slider v1.5.1 3 | * 4 | * By Gilbert Pellegrom 5 | * http://gilbert.pellegrom.me 6 | * 7 | * Copyright (C) 2014 Dev7studios 8 | * https://raw.githubusercontent.com/gilbitron/Ideal-Image-Slider/master/LICENSE 9 | */ 10 | 11 | var IdealImageSlider = (function() { 12 | "use strict"; 13 | 14 | /* 15 | * requestAnimationFrame polyfill 16 | */ 17 | var _requestAnimationFrame = function(win, t) { 18 | return win["r" + t] || win["webkitR" + t] || win["mozR" + t] || win["msR" + t] || function(fn) { 19 | setTimeout(fn, 1000 / 60); 20 | }; 21 | }(window, 'equestAnimationFrame'); 22 | 23 | /** 24 | * Behaves the same as setTimeout except uses requestAnimationFrame() where possible for better performance 25 | * @param {function} fn The callback function 26 | * @param {int} delay The delay in milliseconds 27 | */ 28 | var _requestTimeout = function(fn, delay) { 29 | var start = new Date().getTime(), 30 | handle = {}; 31 | 32 | function loop() { 33 | var current = new Date().getTime(), 34 | delta = current - start; 35 | 36 | if (delta >= delay) { 37 | fn.call(); 38 | } else { 39 | handle.value = _requestAnimationFrame(loop); 40 | } 41 | } 42 | 43 | handle.value = _requestAnimationFrame(loop); 44 | return handle; 45 | }; 46 | 47 | /* 48 | * Helper functions 49 | */ 50 | var _isType = function(type, obj) { 51 | var _class = Object.prototype.toString.call(obj).slice(8, -1); 52 | return obj !== undefined && obj !== null && _class === type; 53 | }; 54 | 55 | var _isInteger = function(x) { 56 | return Math.round(x) === x; 57 | }; 58 | 59 | var _deepExtend = function(out) { 60 | out = out || {}; 61 | for (var i = 1; i < arguments.length; i++) { 62 | var obj = arguments[i]; 63 | if (!obj) 64 | continue; 65 | for (var key in obj) { 66 | if (obj.hasOwnProperty(key)) { 67 | if (_isType('Object', obj[key]) && obj[key] !== null) 68 | _deepExtend(out[key], obj[key]); 69 | else 70 | out[key] = obj[key]; 71 | } 72 | } 73 | } 74 | return out; 75 | }; 76 | 77 | var _hasClass = function(el, className) { 78 | if (!className) return false; 79 | if (el.classList) { 80 | return el.classList.contains(className); 81 | } else { 82 | return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className); 83 | } 84 | }; 85 | 86 | var _addClass = function(el, className) { 87 | if (!className) return; 88 | if (el.classList) { 89 | el.classList.add(className); 90 | } else { 91 | el.className += ' ' + className; 92 | } 93 | }; 94 | 95 | var _removeClass = function(el, className) { 96 | if (!className) return; 97 | if (el.classList) { 98 | el.classList.remove(className); 99 | } else { 100 | el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); 101 | } 102 | }; 103 | 104 | var _toArray = function(obj) { 105 | return Array.prototype.slice.call(obj); 106 | }; 107 | 108 | var _arrayRemove = function(array, from, to) { 109 | var rest = array.slice((to || from) + 1 || array.length); 110 | array.length = from < 0 ? array.length + from : from; 111 | return array.push.apply(array, rest); 112 | }; 113 | 114 | var _addEvent = function(object, type, callback) { 115 | if (object === null || typeof(object) === 'undefined') return; 116 | 117 | if (object.addEventListener) { 118 | object.addEventListener(type, callback, false); 119 | } else if (object.attachEvent) { 120 | object.attachEvent("on" + type, callback); 121 | } else { 122 | object["on" + type] = callback; 123 | } 124 | }; 125 | 126 | var _loadImg = function(slide, callback) { 127 | if (!slide.style.backgroundImage) { 128 | var img = new Image(); 129 | img.setAttribute('src', slide.getAttribute('data-src')); 130 | img.onload = function() { 131 | slide.style.backgroundImage = 'url(' + slide.getAttribute('data-src') + ')'; 132 | slide.setAttribute('data-actual-width', this.naturalWidth); 133 | slide.setAttribute('data-actual-height', this.naturalHeight); 134 | if (typeof(callback) === 'function') callback(this); 135 | }; 136 | } 137 | }; 138 | 139 | var _isHighDPI = function() { 140 | var mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5),(min--moz-device-pixel-ratio: 1.5),(-o-min-device-pixel-ratio: 3/2),(min-resolution: 1.5dppx)"; 141 | if (window.devicePixelRatio > 1) 142 | return true; 143 | if (window.matchMedia && window.matchMedia(mediaQuery).matches) 144 | return true; 145 | return false; 146 | }; 147 | 148 | var _translate = function(slide, dist, speed) { 149 | slide.style.webkitTransitionDuration = 150 | slide.style.MozTransitionDuration = 151 | slide.style.msTransitionDuration = 152 | slide.style.OTransitionDuration = 153 | slide.style.transitionDuration = speed + 'ms'; 154 | 155 | slide.style.webkitTransform = 156 | slide.style.MozTransform = 157 | slide.style.msTransform = 158 | slide.style.OTransform = 'translateX(' + dist + 'px)'; 159 | }; 160 | 161 | var _unTranslate = function(slide) { 162 | slide.style.removeProperty('-webkit-transition-duration'); 163 | slide.style.removeProperty('transition-duration'); 164 | 165 | slide.style.removeProperty('-webkit-transform'); 166 | slide.style.removeProperty('-ms-transform'); 167 | slide.style.removeProperty('transform'); 168 | }; 169 | 170 | var _animate = function(item) { 171 | var duration = item.time, 172 | end = +new Date() + duration; 173 | 174 | var step = function() { 175 | var current = +new Date(), 176 | remaining = end - current; 177 | 178 | if (remaining < 60) { 179 | item.run(1); //1 = progress is at 100% 180 | return; 181 | } else { 182 | var progress = 1 - remaining / duration; 183 | item.run(progress); 184 | } 185 | 186 | _requestAnimationFrame(step); 187 | }; 188 | step(); 189 | }; 190 | 191 | var _setContainerHeight = function(slider, shouldAnimate) { 192 | if (typeof shouldAnimate === 'undefined') { 193 | shouldAnimate = true; 194 | } 195 | 196 | // If it's a fixed height then don't change the height 197 | if (_isInteger(slider.settings.height)) { 198 | return; 199 | } 200 | 201 | var currentHeight = Math.round(slider._attributes.container.offsetHeight), 202 | newHeight = currentHeight; 203 | 204 | if (slider._attributes.aspectWidth && slider._attributes.aspectHeight) { 205 | // Aspect ratio 206 | newHeight = (slider._attributes.aspectHeight / slider._attributes.aspectWidth) * slider._attributes.container.offsetWidth; 207 | } else { 208 | // Auto 209 | var width = slider._attributes.currentSlide.getAttribute('data-actual-width'); 210 | var height = slider._attributes.currentSlide.getAttribute('data-actual-height'); 211 | 212 | if (width && height) { 213 | newHeight = (height / width) * slider._attributes.container.offsetWidth; 214 | } 215 | } 216 | 217 | var maxHeight = parseInt(slider.settings.maxHeight, 10); 218 | if (maxHeight && newHeight > maxHeight) { 219 | newHeight = maxHeight; 220 | } 221 | 222 | newHeight = Math.round(newHeight); 223 | if (newHeight === currentHeight) { 224 | return; 225 | } 226 | 227 | if (shouldAnimate) { 228 | _animate({ 229 | time: slider.settings.transitionDuration, 230 | run: function(progress) { 231 | slider._attributes.container.style.height = Math.round(progress * (newHeight - currentHeight) + currentHeight) + 'px'; 232 | } 233 | }); 234 | } else { 235 | slider._attributes.container.style.height = newHeight + 'px'; 236 | } 237 | }; 238 | 239 | var _touch = { 240 | 241 | vars: { 242 | start: {}, 243 | delta: {}, 244 | isScrolling: undefined, 245 | direction: null 246 | }, 247 | 248 | start: function(event) { 249 | if (_hasClass(this._attributes.container, this.settings.classes.animating)) return; 250 | 251 | var touches = event.touches[0]; 252 | _touch.vars.start = { 253 | x: touches.pageX, 254 | y: touches.pageY, 255 | time: +new Date() 256 | }; 257 | _touch.vars.delta = {}; 258 | _touch.vars.isScrolling = undefined; 259 | _touch.vars.direction = null; 260 | 261 | this.stop(); // Stop slider 262 | 263 | this.settings.beforeChange.apply(this); 264 | _addClass(this._attributes.container, this.settings.classes.touching); 265 | }, 266 | 267 | move: function(event) { 268 | if (_hasClass(this._attributes.container, this.settings.classes.animating)) return; 269 | // Ensure swiping with one touch and not pinching 270 | if (event.touches.length > 1 || event.scale && event.scale !== 1) return; 271 | 272 | var touches = event.touches[0]; 273 | _touch.vars.delta = { 274 | x: touches.pageX - _touch.vars.start.x, 275 | y: touches.pageY - _touch.vars.start.y 276 | }; 277 | 278 | if (typeof _touch.vars.isScrolling == 'undefined') { 279 | _touch.vars.isScrolling = !!(_touch.vars.isScrolling || Math.abs(_touch.vars.delta.x) < Math.abs(_touch.vars.delta.y)); 280 | } 281 | 282 | // If user is not trying to scroll vertically 283 | if (!_touch.vars.isScrolling) { 284 | event.preventDefault(); // Prevent native scrolling 285 | 286 | _translate(this._attributes.previousSlide, _touch.vars.delta.x - this._attributes.previousSlide.offsetWidth, 0); 287 | _translate(this._attributes.currentSlide, _touch.vars.delta.x, 0); 288 | _translate(this._attributes.nextSlide, _touch.vars.delta.x + this._attributes.currentSlide.offsetWidth, 0); 289 | } 290 | }, 291 | 292 | end: function(event) { 293 | if (_hasClass(this._attributes.container, this.settings.classes.animating)) return; 294 | 295 | var duration = +new Date() - _touch.vars.start.time; 296 | 297 | // Determine if slide attempt triggers next/prev slide 298 | var isChangeSlide = Number(duration) < 250 && Math.abs(_touch.vars.delta.x) > 20 || Math.abs(_touch.vars.delta.x) > this._attributes.currentSlide.offsetWidth / 2; 299 | 300 | var direction = _touch.vars.delta.x < 0 ? 'next' : 'previous'; 301 | var speed = this.settings.transitionDuration ? this.settings.transitionDuration / 2 : 0; 302 | 303 | // If not scrolling vertically 304 | if (!_touch.vars.isScrolling) { 305 | if (isChangeSlide) { 306 | _touch.vars.direction = direction; 307 | 308 | if (_touch.vars.direction == 'next') { 309 | _translate(this._attributes.currentSlide, -this._attributes.currentSlide.offsetWidth, speed); 310 | _translate(this._attributes.nextSlide, 0, speed); 311 | } else { 312 | _translate(this._attributes.previousSlide, 0, speed); 313 | _translate(this._attributes.currentSlide, this._attributes.currentSlide.offsetWidth, speed); 314 | } 315 | 316 | _requestTimeout(_touch.transitionEnd.bind(this), speed); 317 | } else { 318 | // Slides return to original position 319 | if (direction == 'next') { 320 | _translate(this._attributes.currentSlide, 0, speed); 321 | _translate(this._attributes.nextSlide, this._attributes.currentSlide.offsetWidth, speed); 322 | } else { 323 | _translate(this._attributes.previousSlide, -this._attributes.previousSlide.offsetWidth, speed); 324 | _translate(this._attributes.currentSlide, 0, speed); 325 | } 326 | } 327 | 328 | if (speed) { 329 | _addClass(this._attributes.container, this.settings.classes.animating); 330 | _requestTimeout(function() { 331 | _removeClass(this._attributes.container, this.settings.classes.animating); 332 | }.bind(this), speed); 333 | } 334 | } 335 | }, 336 | 337 | transitionEnd: function(event) { 338 | if (_touch.vars.direction) { 339 | _unTranslate(this._attributes.previousSlide); 340 | _unTranslate(this._attributes.currentSlide); 341 | _unTranslate(this._attributes.nextSlide); 342 | _removeClass(this._attributes.container, this.settings.classes.touching); 343 | 344 | _removeClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 345 | _removeClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 346 | _removeClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 347 | this._attributes.currentSlide.setAttribute('aria-hidden', 'true'); 348 | 349 | var slides = this._attributes.slides, 350 | index = slides.indexOf(this._attributes.currentSlide); 351 | 352 | if (_touch.vars.direction == 'next') { 353 | this._attributes.previousSlide = this._attributes.currentSlide; 354 | this._attributes.currentSlide = slides[index + 1]; 355 | this._attributes.nextSlide = slides[index + 2]; 356 | if (typeof this._attributes.currentSlide === 'undefined' && 357 | typeof this._attributes.nextSlide === 'undefined') { 358 | this._attributes.currentSlide = slides[0]; 359 | this._attributes.nextSlide = slides[1]; 360 | } else { 361 | if (typeof this._attributes.nextSlide === 'undefined') { 362 | this._attributes.nextSlide = slides[0]; 363 | } 364 | } 365 | 366 | _loadImg(this._attributes.nextSlide); 367 | } else { 368 | this._attributes.nextSlide = this._attributes.currentSlide; 369 | this._attributes.previousSlide = slides[index - 2]; 370 | this._attributes.currentSlide = slides[index - 1]; 371 | if (typeof this._attributes.currentSlide === 'undefined' && 372 | typeof this._attributes.previousSlide === 'undefined') { 373 | this._attributes.currentSlide = slides[slides.length - 1]; 374 | this._attributes.previousSlide = slides[slides.length - 2]; 375 | } else { 376 | if (typeof this._attributes.previousSlide === 'undefined') { 377 | this._attributes.previousSlide = slides[slides.length - 1]; 378 | } 379 | } 380 | 381 | _loadImg(this._attributes.previousSlide); 382 | } 383 | 384 | _addClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 385 | _addClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 386 | _addClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 387 | this._attributes.currentSlide.setAttribute('aria-hidden', 'false'); 388 | 389 | _setContainerHeight(this); 390 | this.settings.afterChange.apply(this); 391 | } 392 | } 393 | 394 | }; 395 | 396 | /* 397 | * Slider class 398 | */ 399 | var Slider = function(args) { 400 | // Defaults 401 | this.settings = { 402 | selector: '', 403 | height: 'auto', // "auto" | px value (e.g. 400) | aspect ratio (e.g. "16:9") 404 | initialHeight: 400, // for "auto" and aspect ratio 405 | maxHeight: null, // for "auto" and aspect ratio 406 | interval: 4000, 407 | transitionDuration: 700, 408 | effect: 'slide', 409 | disableNav: false, 410 | keyboardNav: true, 411 | previousNavSelector: '', 412 | nextNavSelector: '', 413 | classes: { 414 | container: 'ideal-image-slider', 415 | slide: 'iis-slide', 416 | previousSlide: 'iis-previous-slide', 417 | currentSlide: 'iis-current-slide', 418 | nextSlide: 'iis-next-slide', 419 | previousNav: 'iis-previous-nav', 420 | nextNav: 'iis-next-nav', 421 | animating: 'iis-is-animating', 422 | touchEnabled: 'iis-touch-enabled', 423 | touching: 'iis-is-touching', 424 | directionPrevious: 'iis-direction-previous', 425 | directionNext: 'iis-direction-next' 426 | }, 427 | onInit: function() {}, 428 | onStart: function() {}, 429 | onStop: function() {}, 430 | onDestroy: function() {}, 431 | beforeChange: function() {}, 432 | afterChange: function() {} 433 | }; 434 | 435 | // Parse args 436 | if (typeof args === 'string') { 437 | this.settings.selector = args; 438 | } else if (typeof args === 'object') { 439 | _deepExtend(this.settings, args); 440 | } 441 | 442 | // Slider (container) element 443 | var sliderEl = document.querySelector(this.settings.selector); 444 | if (!sliderEl) return null; 445 | 446 | // Slides 447 | var origChildren = _toArray(sliderEl.children), 448 | validSlides = []; 449 | sliderEl.innerHTML = ''; 450 | Array.prototype.forEach.call(origChildren, function(slide, i) { 451 | if (slide instanceof HTMLImageElement || slide instanceof HTMLAnchorElement) { 452 | var slideEl = document.createElement('a'), 453 | href = '', 454 | target = ''; 455 | 456 | if (slide instanceof HTMLAnchorElement) { 457 | href = slide.getAttribute('href'); 458 | target = slide.getAttribute('target'); 459 | 460 | var img = slide.querySelector('img'); 461 | if (img !== null) { 462 | slide = img; 463 | } else { 464 | return; 465 | } 466 | } 467 | 468 | if (typeof slide.dataset !== 'undefined') { 469 | _deepExtend(slideEl.dataset, slide.dataset); 470 | if (slide.dataset.src) { 471 | // Use data-src for on-demand loading 472 | slideEl.dataset.src = slide.dataset.src; 473 | } else { 474 | slideEl.dataset.src = slide.src; 475 | } 476 | 477 | // HiDPI support 478 | if (_isHighDPI() && slide.dataset['src-2x']) { 479 | slideEl.dataset.src = slide.dataset['src-2x']; 480 | } 481 | } else { 482 | // IE 483 | if (slide.getAttribute('data-src')) { 484 | slideEl.setAttribute('data-src', slide.getAttribute('data-src')); 485 | } else { 486 | slideEl.setAttribute('data-src', slide.getAttribute('src')); 487 | } 488 | } 489 | 490 | if (href) slideEl.setAttribute('href', href); 491 | if (target) slideEl.setAttribute('target', target); 492 | if (slide.getAttribute('className')) _addClass(slideEl, slide.getAttribute('className')); 493 | if (slide.getAttribute('id')) slideEl.setAttribute('id', slide.getAttribute('id')); 494 | if (slide.getAttribute('title')) slideEl.setAttribute('title', slide.getAttribute('title')); 495 | if (slide.getAttribute('alt')) slideEl.innerHTML = slide.getAttribute('alt'); 496 | slideEl.setAttribute('role', 'tabpanel'); 497 | slideEl.setAttribute('aria-hidden', 'true'); 498 | 499 | slideEl.style.cssText += '-webkit-transition-duration:' + this.settings.transitionDuration + 'ms;-moz-transition-duration:' + this.settings.transitionDuration + 'ms;-o-transition-duration:' + this.settings.transitionDuration + 'ms;transition-duration:' + this.settings.transitionDuration + 'ms;'; 500 | 501 | sliderEl.appendChild(slideEl); 502 | validSlides.push(slideEl); 503 | } 504 | }.bind(this)); 505 | 506 | var slides = validSlides; 507 | if (slides.length <= 1) { 508 | sliderEl.innerHTML = ''; 509 | Array.prototype.forEach.call(origChildren, function(child, i) { 510 | sliderEl.appendChild(child); 511 | }); 512 | return null; 513 | } 514 | 515 | // Create navigation 516 | if (!this.settings.disableNav) { 517 | var previousNav, nextNav; 518 | if (this.settings.previousNavSelector) { 519 | previousNav = document.querySelector(this.settings.previousNavSelector); 520 | } else { 521 | previousNav = document.createElement('a'); 522 | sliderEl.appendChild(previousNav); 523 | } 524 | if (this.settings.nextNavSelector) { 525 | nextNav = document.querySelector(this.settings.nextNavSelector); 526 | } else { 527 | nextNav = document.createElement('a'); 528 | sliderEl.appendChild(nextNav); 529 | } 530 | 531 | _addClass(previousNav, this.settings.classes.previousNav); 532 | _addClass(nextNav, this.settings.classes.nextNav); 533 | _addEvent(previousNav, 'click', function() { 534 | if (_hasClass(this._attributes.container, this.settings.classes.animating)) return false; 535 | this.stop(); 536 | this.previousSlide(); 537 | }.bind(this)); 538 | _addEvent(nextNav, 'click', function() { 539 | if (_hasClass(this._attributes.container, this.settings.classes.animating)) return false; 540 | this.stop(); 541 | this.nextSlide(); 542 | }.bind(this)); 543 | 544 | // Touch Navigation 545 | if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) { 546 | this.settings.effect = 'slide'; 547 | previousNav.style.display = 'none'; 548 | nextNav.style.display = 'none'; 549 | _addClass(sliderEl, this.settings.classes.touchEnabled); 550 | 551 | _addEvent(sliderEl, 'touchstart', _touch.start.bind(this), false); 552 | _addEvent(sliderEl, 'touchmove', _touch.move.bind(this), false); 553 | _addEvent(sliderEl, 'touchend', _touch.end.bind(this), false); 554 | } 555 | 556 | // Keyboard Navigation 557 | if (this.settings.keyboardNav) { 558 | _addEvent(document, 'keyup', function(e) { 559 | e = e || window.event; 560 | var button = (typeof e.which == 'number') ? e.which : e.keyCode; 561 | if (button == 37) { 562 | if (_hasClass(this._attributes.container, this.settings.classes.animating)) return false; 563 | this.stop(); 564 | this.previousSlide(); 565 | } else if (button == 39) { 566 | if (_hasClass(this._attributes.container, this.settings.classes.animating)) return false; 567 | this.stop(); 568 | this.nextSlide(); 569 | } 570 | }.bind(this)); 571 | } 572 | } 573 | 574 | // Create internal attributes 575 | this._attributes = { 576 | container: sliderEl, 577 | slides: slides, 578 | previousSlide: typeof slides[slides.length - 1] !== 'undefined' ? slides[slides.length - 1] : slides[0], 579 | currentSlide: slides[0], 580 | nextSlide: typeof slides[1] !== 'undefined' ? slides[1] : slides[0], 581 | timerId: 0, 582 | origChildren: origChildren, // Used in destroy() 583 | aspectWidth: 0, 584 | aspectHeight: 0 585 | }; 586 | 587 | // Set height 588 | if (_isInteger(this.settings.height)) { 589 | this._attributes.container.style.height = this.settings.height + 'px'; 590 | } else { 591 | if (_isInteger(this.settings.initialHeight)) { 592 | this._attributes.container.style.height = this.settings.initialHeight + 'px'; 593 | } 594 | 595 | // If aspect ratio parse and store 596 | if (this.settings.height.indexOf(':') > -1) { 597 | var aspectRatioParts = this.settings.height.split(':'); 598 | if (aspectRatioParts.length == 2 && _isInteger(parseInt(aspectRatioParts[0], 10)) && _isInteger(parseInt(aspectRatioParts[1], 10))) { 599 | this._attributes.aspectWidth = parseInt(aspectRatioParts[0], 10); 600 | this._attributes.aspectHeight = parseInt(aspectRatioParts[1], 10); 601 | } 602 | } 603 | 604 | _addEvent(window, 'resize', function() { 605 | _setContainerHeight(this, false); 606 | }.bind(this)); 607 | } 608 | 609 | // Add classes 610 | _addClass(sliderEl, this.settings.classes.container); 611 | _addClass(sliderEl, 'iis-effect-' + this.settings.effect); 612 | Array.prototype.forEach.call(this._attributes.slides, function(slide, i) { 613 | _addClass(slide, this.settings.classes.slide); 614 | }.bind(this)); 615 | _addClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 616 | _addClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 617 | _addClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 618 | 619 | // ARIA 620 | this._attributes.currentSlide.setAttribute('aria-hidden', 'false'); 621 | 622 | // Load first image 623 | _loadImg(this._attributes.currentSlide, (function() { 624 | this.settings.onInit.apply(this); 625 | _setContainerHeight(this, false); 626 | }).bind(this)); 627 | // Preload next images 628 | _loadImg(this._attributes.previousSlide); 629 | _loadImg(this._attributes.nextSlide); 630 | }; 631 | 632 | Slider.prototype.get = function(attribute) { 633 | if (!this._attributes) return null; 634 | if (this._attributes.hasOwnProperty(attribute)) { 635 | return this._attributes[attribute]; 636 | } 637 | }; 638 | 639 | Slider.prototype.set = function(attribute, value) { 640 | if (!this._attributes) return null; 641 | return (this._attributes[attribute] = value); 642 | }; 643 | 644 | Slider.prototype.start = function() { 645 | if (!this._attributes) return; 646 | this._attributes.timerId = setInterval(this.nextSlide.bind(this), this.settings.interval); 647 | this.settings.onStart.apply(this); 648 | 649 | // Stop if window blur 650 | window.onblur = function() { 651 | this.stop(); 652 | }.bind(this); 653 | }; 654 | 655 | Slider.prototype.stop = function() { 656 | if (!this._attributes) return; 657 | clearInterval(this._attributes.timerId); 658 | this._attributes.timerId = 0; 659 | this.settings.onStop.apply(this); 660 | }; 661 | 662 | Slider.prototype.previousSlide = function() { 663 | this.settings.beforeChange.apply(this); 664 | _removeClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 665 | _removeClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 666 | _removeClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 667 | this._attributes.currentSlide.setAttribute('aria-hidden', 'true'); 668 | 669 | var slides = this._attributes.slides, 670 | index = slides.indexOf(this._attributes.currentSlide); 671 | this._attributes.nextSlide = this._attributes.currentSlide; 672 | this._attributes.previousSlide = slides[index - 2]; 673 | this._attributes.currentSlide = slides[index - 1]; 674 | if (typeof this._attributes.currentSlide === 'undefined' && 675 | typeof this._attributes.previousSlide === 'undefined') { 676 | this._attributes.currentSlide = slides[slides.length - 1]; 677 | this._attributes.previousSlide = slides[slides.length - 2]; 678 | } else { 679 | if (typeof this._attributes.previousSlide === 'undefined') { 680 | this._attributes.previousSlide = slides[slides.length - 1]; 681 | } 682 | } 683 | 684 | // Preload next image 685 | _loadImg(this._attributes.previousSlide); 686 | 687 | _addClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 688 | _addClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 689 | _addClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 690 | this._attributes.currentSlide.setAttribute('aria-hidden', 'false'); 691 | 692 | _addClass(this._attributes.container, this.settings.classes.directionPrevious); 693 | _requestTimeout(function() { 694 | _removeClass(this._attributes.container, this.settings.classes.directionPrevious); 695 | }.bind(this), this.settings.transitionDuration); 696 | 697 | if (this.settings.transitionDuration) { 698 | _addClass(this._attributes.container, this.settings.classes.animating); 699 | _requestTimeout(function() { 700 | _removeClass(this._attributes.container, this.settings.classes.animating); 701 | }.bind(this), this.settings.transitionDuration); 702 | } 703 | 704 | _setContainerHeight(this); 705 | this.settings.afterChange.apply(this); 706 | }; 707 | 708 | Slider.prototype.nextSlide = function() { 709 | this.settings.beforeChange.apply(this); 710 | _removeClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 711 | _removeClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 712 | _removeClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 713 | this._attributes.currentSlide.setAttribute('aria-hidden', 'true'); 714 | 715 | var slides = this._attributes.slides, 716 | index = slides.indexOf(this._attributes.currentSlide); 717 | this._attributes.previousSlide = this._attributes.currentSlide; 718 | this._attributes.currentSlide = slides[index + 1]; 719 | this._attributes.nextSlide = slides[index + 2]; 720 | if (typeof this._attributes.currentSlide === 'undefined' && 721 | typeof this._attributes.nextSlide === 'undefined') { 722 | this._attributes.currentSlide = slides[0]; 723 | this._attributes.nextSlide = slides[1]; 724 | } else { 725 | if (typeof this._attributes.nextSlide === 'undefined') { 726 | this._attributes.nextSlide = slides[0]; 727 | } 728 | } 729 | 730 | // Preload next image 731 | _loadImg(this._attributes.nextSlide); 732 | 733 | _addClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 734 | _addClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 735 | _addClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 736 | this._attributes.currentSlide.setAttribute('aria-hidden', 'false'); 737 | 738 | _addClass(this._attributes.container, this.settings.classes.directionNext); 739 | _requestTimeout(function() { 740 | _removeClass(this._attributes.container, this.settings.classes.directionNext); 741 | }.bind(this), this.settings.transitionDuration); 742 | 743 | if (this.settings.transitionDuration) { 744 | _addClass(this._attributes.container, this.settings.classes.animating); 745 | _requestTimeout(function() { 746 | _removeClass(this._attributes.container, this.settings.classes.animating); 747 | }.bind(this), this.settings.transitionDuration); 748 | } 749 | 750 | _setContainerHeight(this); 751 | this.settings.afterChange.apply(this); 752 | }; 753 | 754 | Slider.prototype.gotoSlide = function(index) { 755 | this.settings.beforeChange.apply(this); 756 | this.stop(); 757 | 758 | _removeClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 759 | _removeClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 760 | _removeClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 761 | this._attributes.currentSlide.setAttribute('aria-hidden', 'true'); 762 | 763 | index--; // Index should be 1-indexed 764 | var slides = this._attributes.slides, 765 | oldIndex = slides.indexOf(this._attributes.currentSlide); 766 | this._attributes.previousSlide = slides[index - 1]; 767 | this._attributes.currentSlide = slides[index]; 768 | this._attributes.nextSlide = slides[index + 1]; 769 | if (typeof this._attributes.previousSlide === 'undefined') { 770 | this._attributes.previousSlide = slides[slides.length - 1]; 771 | } 772 | if (typeof this._attributes.nextSlide === 'undefined') { 773 | this._attributes.nextSlide = slides[0]; 774 | } 775 | 776 | // Load images 777 | _loadImg(this._attributes.previousSlide); 778 | _loadImg(this._attributes.currentSlide); 779 | _loadImg(this._attributes.nextSlide); 780 | 781 | _addClass(this._attributes.previousSlide, this.settings.classes.previousSlide); 782 | _addClass(this._attributes.currentSlide, this.settings.classes.currentSlide); 783 | _addClass(this._attributes.nextSlide, this.settings.classes.nextSlide); 784 | this._attributes.currentSlide.setAttribute('aria-hidden', 'false'); 785 | 786 | if (index < oldIndex) { 787 | _addClass(this._attributes.container, this.settings.classes.directionPrevious); 788 | _requestTimeout(function() { 789 | _removeClass(this._attributes.container, this.settings.classes.directionPrevious); 790 | }.bind(this), this.settings.transitionDuration); 791 | } else { 792 | _addClass(this._attributes.container, this.settings.classes.directionNext); 793 | _requestTimeout(function() { 794 | _removeClass(this._attributes.container, this.settings.classes.directionNext); 795 | }.bind(this), this.settings.transitionDuration); 796 | } 797 | 798 | if (this.settings.transitionDuration) { 799 | _addClass(this._attributes.container, this.settings.classes.animating); 800 | _requestTimeout(function() { 801 | _removeClass(this._attributes.container, this.settings.classes.animating); 802 | }.bind(this), this.settings.transitionDuration); 803 | } 804 | 805 | _setContainerHeight(this); 806 | this.settings.afterChange.apply(this); 807 | }; 808 | 809 | Slider.prototype.destroy = function() { 810 | clearInterval(this._attributes.timerId); 811 | this._attributes.timerId = 0; 812 | 813 | this._attributes.container.innerHTML = ''; 814 | Array.prototype.forEach.call(this._attributes.origChildren, function(child, i) { 815 | this._attributes.container.appendChild(child); 816 | }.bind(this)); 817 | 818 | _removeClass(this._attributes.container, this.settings.classes.container); 819 | _removeClass(this._attributes.container, 'iis-effect-' + this.settings.effect); 820 | this._attributes.container.style.height = ''; 821 | 822 | this.settings.onDestroy.apply(this); 823 | }; 824 | 825 | return { 826 | _hasClass: _hasClass, 827 | _addClass: _addClass, 828 | _removeClass: _removeClass, 829 | Slider: Slider 830 | }; 831 | 832 | })(); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | --------------------------------------------------------------------------------