Skip to content

Commit

Permalink
added navigateTo()
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleydw committed Dec 3, 2014
1 parent cdb0bc4 commit bed8606
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 44 deletions.
6 changes: 2 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module.exports = function (grunt) {
"use strict";

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner:
'/*!\n' +
' * Lightbox for Bootstrap 3 by @ashleydw\n' +
Expand Down Expand Up @@ -61,11 +60,10 @@ module.exports = function (grunt) {
},
bump: {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: ['pkg'],
files: ['bower.json'],
commit: true,
commitMessage: 'Release v%VERSION%',
commitFiles: ['package.json', 'bower.json'],
commitFiles: ['bower.json'],
createTag: true,
tagName: 'v%VERSION%',
tagMessage: 'Version %VERSION%',
Expand Down
41 changes: 22 additions & 19 deletions dist/ekko-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,46 +152,49 @@ License: https://github.com/ashleydw/lightbox/blob/master/LICENSE
}
}
},
navigateTo: function(index) {
var next, src;
if (index < 0 || index > this.gallery_items.length - 1) {
return this;
}
this.showLoading();
this.gallery_index = index;
this.options.onNavigate.call(this, this.gallery_index);
this.$element = $(this.gallery_items.get(this.gallery_index));
this.updateTitleAndFooter();
src = this.$element.attr('data-remote') || this.$element.attr('href');
this.detectRemoteType(src, this.$element.attr('data-type') || false);
if (this.gallery_index + 1 < this.gallery_items.length) {
next = $(this.gallery_items.get(this.gallery_index + 1), false);
src = next.attr('data-remote') || next.attr('href');
if (next.attr('data-type') === 'image' || this.isImage(src)) {
return this.preloadImage(src, false);
}
}
},
navigate_left: function() {
var src;
if (this.gallery_items.length === 1) {
return;
}
this.showLoading();
if (this.gallery_index === 0) {
this.gallery_index = this.gallery_items.length - 1;
} else {
this.gallery_index--;
}
this.options.onNavigate.call(this, 'left', this.gallery_index);
this.$element = $(this.gallery_items.get(this.gallery_index));
this.updateTitleAndFooter();
src = this.$element.attr('data-remote') || this.$element.attr('href');
return this.detectRemoteType(src, this.$element.attr('data-type'));
return this.navigateTo(this.gallery_index);
},
navigate_right: function() {
var next, src;
if (this.gallery_items.length === 1) {
return;
}
this.showLoading();
if (this.gallery_index === this.gallery_items.length - 1) {
this.gallery_index = 0;
} else {
this.gallery_index++;
}
this.options.onNavigate.call(this, 'right', this.gallery_index);
this.$element = $(this.gallery_items.get(this.gallery_index));
src = this.$element.attr('data-remote') || this.$element.attr('href');
this.updateTitleAndFooter();
this.detectRemoteType(src, this.$element.attr('data-type'));
if (this.gallery_index + 1 < this.gallery_items.length) {
next = $(this.gallery_items.get(this.gallery_index + 1), false);
src = next.attr('data-remote') || next.attr('href');
if (next.attr('data-type') === 'image' || this.isImage(src)) {
return this.preloadImage(src, false);
}
}
return this.navigateTo(this.gallery_index);
},
detectRemoteType: function(src, type) {
var video_id;
Expand Down
Loading

0 comments on commit bed8606

Please sign in to comment.