Skip to content

Commit

Permalink
First Version (Vanilla)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzyma committed Feb 14, 2015
0 parents commit 304cd77
Show file tree
Hide file tree
Showing 15 changed files with 1,623 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
/node_modules/
/test
14 changes: 14 additions & 0 deletions .jshintrc
@@ -0,0 +1,14 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"node": true
}
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,31 @@
# Contributing

## Important notes
Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory!

### Code style
Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.**

### PhantomJS
While Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers.

## Modifying the code
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.

Test that Grunt's CLI is installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing Grunt, see the [getting started guide](http://gruntjs.com/getting-started).

1. Fork and clone the repo.
1. Run `npm install` to install all dependencies (including Grunt).
1. Run `grunt` to grunt this project.

Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken.

## Submitting pull requests

1. Create a new branch, please don't work in your `master` branch directly.
1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
1. Fix stuff.
1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere.
1. Update the documentation to reflect any changes.
1. Push to your fork and submit a pull request.
98 changes: 98 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,98 @@
'use strict';

module.exports = function(grunt) {

// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= pkg.license %> */\n',
// Task configuration.
clean: {
files: ['dist']
},
copy: {
main: {
files: [{
expand: true,
cwd: 'src/',
src: ['*.css'],
dest: 'dist/',
}]
}
},
concat: {
options: {
banner: '<%= banner %>',
stripBanners: true
},
dist: {
src: ['src/<%= pkg.name %>.js'],
dest: 'dist/<%= pkg.name %>.js'
},
},
uglify: {
options: {
banner: '<%= banner %>'
},
dist: {
src: '<%= concat.dist.dest %>',
dest: 'dist/<%= pkg.name %>.min.js'
},
},
cssmin: {
target: {
files: [{
expand: true,
cwd: 'src/',
src: ['*.css'],
dest: 'dist/',
ext: '.min.css'
}]
}
},
jshint: {
options: {
jshintrc: true
},
gruntfile: {
src: 'Gruntfile.js'
},
src: {
src: ['src/**/*.js']
}
},
watch: {
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
src: {
files: '<%= jshint.src.src %>'
}
},
bumper: {
options: {
files: ['package.json', 'bower.json']
}
},
});

// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bumper');

// Default task.
grunt.registerTask('default', ['jshint', 'clean', 'copy', 'concat', 'uglify', 'cssmin']);

};
22 changes: 22 additions & 0 deletions LICENSE-MIT
@@ -0,0 +1,22 @@
Copyright (c) 2015 Ulrich-Matthias Schäfer

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
154 changes: 154 additions & 0 deletions README.md
@@ -0,0 +1,154 @@
# Yalb (Vanilla)

Yet Another LightBox
Yalb only uses pure Javascript. All animations are done using css-transition or animation.
If you would like to go with a jQuery-version take a look at [jquery.yalb][jqueryyalb].

[jqueryyalb]: https://github.com/Fuzzyma/jquery.yalb

## Getting Started
Download the [production version][min] or the [development version][max].
Or run

bower install yalb

[min]: https://raw.githubusercontent.com/Fuzzyma/yalb/master/dist/yalb.min.js
[max]: https://raw.githubusercontent.com/Fuzzyma/yalb/master/dist/yalb.js

Include yalb in your web page:

<link rel="stylesheet" href="dist/yalb.min.css">
<script src="dist/yalb.min.js"></script>
<script>
jQuery(function($) {

var images = [
'img1.jpg',
'img2.jpg',
'img3.jpg',
'img4.jpg',
'img5.jpg'
]

yalb(images);

// for other possibilities to call yalb see below

});
</script>

## Documentation

### Collections you can pass to Yalb / Examples

- `array` filled with `Strings`

var images = [
'img1.jpg',
'img2.jpg',
'img3.jpg',
'img4.jpg',
'img5.jpg'
];
yalb(images);

- `NodeList` or `Array` of `Nodes`

var images = document.getElementsByTagName('img');
yalb(images);

// or
var links = document.getElementsByTagName('a');
yalb(links, {src: 'href'});

// or any other node with an attribute containing the path
// e.g. <span data-image="/path/to/image.jpg"
yalb(span, {src: 'data-image'});

- `jQuery`-Collection

var images = $('img');
yalb(images);

// or same as above


- selfmade object containing the path

var images = [
{
foo: 'bar'
path: 'path/to/image.jpg'
},
{
// and so on
}
];

yalb(images, {src: 'path'});

// or even
var images = [
{
path: {
'to': {
'image': 'path/to/image.jpg'
}
}
},
{
// and so on
}
];

yalb(images, {src: 'path.to.image'});

### Options

The following options can be passed when calling yalb:

- `src` ( `default:'src'` ), Attribute where the path is located.
- `current` ( `default:0` ), The image which is presented when opening yalb
- `class` ( `default:'yalb'` ), The class passed to the html-container of yalb
- `loop` ( `default:true` ), If true, images will be repeated when hitting the first/last image
- `open` ( `default:true` ), If true, yalb opens when called
- `width` ( `default:0` ), max-with of the Yalb-window
- `height` ( `default:0` ), max-height of the Yalb-window

You can change the default values for the whole page by assigning to `yalb.defaults`

yalb.defaults = {
src: 'src',
current: 0,
'class': 'yalb',
loop: true,
open: true,
width: 0,
height: 0
};

### Methods

You can control the behavior of yalb with the following methods

- `yalb.open()` - Opens yalb when still not open
- `yalb.close0()` - Close yalb; same as hitting the close-button
- `yalb.next()` - Next Image; same as hitting the next-button
- `yalb.prev()` - Previous Image; same as hitting the prev-button
- `yalb.show(index)` - Changes to the image on position `index`
- `yalb.get()` - Gets the node of the container on which all events are triggered

### Events

You can listen to the following Events:

- `change` - When the image has changed
- `open` - When open is called (per Method or per yalb-call with `open:true`)
- `close` - When close-button is pressed
- `next` - When next-button is pressed
- `prev` - When prev-button is pressed
- `show` - When show is called
###
var yalb_instance = yalb.get(); // or yalb_instance = yalb(); or next().next()
yalb_instance.addEventListener('next', function(){ /* do stuff */ }, false);
26 changes: 26 additions & 0 deletions bower.json
@@ -0,0 +1,26 @@
{
"name": "yalb",
"version": "0.1.0",
"homepage": "https://github.com/Fuzzyma/yalb",
"authors": [
"Ulrich-Matthias Schäfer"
],
"description": "Yet Another LighBox. Easy to use and out of the Box in pure JS",
"main": [
"./src/yalb.js",
"./src/yalb.css"
],
"keywords": [
"vanilla",
"lightbox",
"yalb"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}

0 comments on commit 304cd77

Please sign in to comment.