Skip to content

Commit

Permalink
Update index property
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyapps committed Jan 18, 2012
1 parent c23e13f commit f2a268d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
46 changes: 26 additions & 20 deletions source/jquery.fancybox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* fancyBox - jQuery Plugin
* version: 2.0.4 (12/01/2012)
* version: 2.0.4 (18/01/2012)
* @requires jQuery v1.6 or later
*
* Examples at http://fancyapps.com/fancybox/
Expand All @@ -9,7 +9,7 @@
* Copyright 2011 Janis Skarnelis - janis@fancyapps.com
*
*/
(function (window, document, $) {
(function (window, document, $, undefined) {
var W = $(window),
D = $(document),
F = $.fancybox = function () {
Expand All @@ -20,7 +20,7 @@

$.extend(F, {
// The current version of fancyBox
version: '2.0.4',
version: '2.0.5',

defaults: {
padding: 15,
Expand Down Expand Up @@ -159,7 +159,7 @@
* Static methods
*/

open: function (group, opts, index) {
open: function (group, opts) {
// Normalize group
if (!$.isArray(group)) {
group = group.jquery ? $(group).get() : [group];
Expand All @@ -178,7 +178,7 @@
F.opts = $.extend(true, {}, F.defaults, opts);
F.group = group;

F._start(index || 0);
F._start(F.opts.index || 0);
},

cancel: function () {
Expand Down Expand Up @@ -471,7 +471,7 @@
type,
rez;

if (typeof element === 'object' && (element.nodeType || element instanceof $)) {
if (element && typeof element === 'object' && (element.nodeType || element instanceof $)) {
isDom = true;

if ($.metadata) {
Expand Down Expand Up @@ -761,13 +761,14 @@
}

if (type === 'iframe') {
current.scrolling = 'auto';
content = $(current.tpl.iframe.replace('{rnd}', new Date().getTime()) )
.attr({
'scrolling' : current.scrolling,
'src' : current.href
})
.appendTo( F.inner );

content = $(current.tpl.iframe.replace('{rnd}', new Date().getTime()) ).attr({
'scrolling' : current.scrolling,
'src' : current.href
})
.appendTo( F.inner );
current.scrolling = 'auto';

// Set auto height for iframes
if (current.autoSize) {
Expand Down Expand Up @@ -1341,11 +1342,11 @@

// jQuery plugin initialization
$.fn.fancybox = function (options) {
var opts = options || {},
that = $(this),
var that = $(this),
selector = this.selector || '',
index,
run = function(e) {
var group = this, index = 0, relType = 'rel', relVal = this.rel;
var what = this, relType = 'rel', relVal = what[ relType ];

if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
e.preventDefault();
Expand All @@ -1356,21 +1357,26 @@
}

if (relVal && relVal !== '' && relVal !== 'nofollow') {
group = selector.length ? $(selector) : that;
group = group.filter('[' + relType + '="' + relVal + '"]');
what = selector.length ? $(selector) : that;
what = what.filter('[' + relType + '="' + relVal + '"]');

index = group.index(this);
if (!index) {
options.index = what.index(this);
}
}

F.open(group, opts, index);
F.open(what, options);
}
};

options = options || {};
index = options.index || false;

if (selector) {
D.undelegate(selector, 'click.fb-start').delegate(selector, 'click.fb-start', run);

} else {
$(this).unbind('click.fb-start').bind('click.fb-start', run);
that.unbind('click.fb-start').bind('click.fb-start', run);
}

return this;
Expand Down
Loading

0 comments on commit f2a268d

Please sign in to comment.