ajgkqsldxvkqsldkqs
azelfkqsmkqsmlkdqsmld
azmlekdqmskdmlqskd
nkldsfkqsmldkqsmdmlskd
PK J R]e¦ù"øY øY jquery.fancybox.jsnu W+A„¶ // ==================================================
// fancyBox v3.2.10
//
// Licensed GPLv3 for open source use
// or fancyBox Commercial License for commercial use
//
// http://fancyapps.com/fancybox/
// Copyright 2017 fancyApps
//
// ==================================================
;(function (window, document, $, undefined) {
'use strict';
// If there's no jQuery, fancyBox can't work
// =========================================
if ( !$ ) {
return;
}
// Check if fancyBox is already initialized
// ========================================
if ( $.fn.fancybox ) {
if ( 'console' in window ) {
console.log( 'fancyBox already initialized' );
}
return;
}
// Private default settings
// ========================
var defaults = {
// Enable infinite gallery navigation
loop : false,
// Space around image, ignored if zoomed-in or viewport width is smaller than 800px
margin : [44, 0],
// Horizontal space between slides
gutter : 50,
// Enable keyboard navigation
keyboard : true,
// Should display navigation arrows at the screen edges
arrows : true,
// Should display infobar (counter and arrows at the top)
infobar : true,
// Should display toolbar (buttons at the top)
toolbar : true,
// What buttons should appear in the top right corner.
// Buttons will be created using templates from `btnTpl` option
// and they will be placed into toolbar (class="fancybox-toolbar"` element)
buttons : [
'slideShow',
'fullScreen',
'thumbs',
'share',
//'download',
//'zoom',
'close'
],
// Detect "idle" time in seconds
idleTime : 3,
// Should display buttons at top right corner of the content
// If 'auto' - they will be created for content having type 'html', 'inline' or 'ajax'
// Use template from `btnTpl.smallBtn` for customization
smallBtn : 'auto',
// Disable right-click and use simple image protection for images
protect : false,
// Shortcut to make content "modal" - disable keyboard navigtion, hide buttons, etc
modal : false,
image : {
// Wait for images to load before displaying
// Requires predefined image dimensions
// If 'auto' - will zoom in thumbnail if 'width' and 'height' attributes are found
preload : "auto"
},
ajax : {
// Object containing settings for ajax request
settings : {
// This helps to indicate that request comes from the modal
// Feel free to change naming
data : {
fancybox : true
}
}
},
iframe : {
// Iframe template
tpl : '',
// Preload iframe before displaying it
// This allows to calculate iframe content width and height
// (note: Due to "Same Origin Policy", you can't get cross domain data).
preload : true,
// Custom CSS styling for iframe wrapping element
// You can use this to set custom iframe dimensions
css : {},
// Iframe tag attributes
attr : {
scrolling : 'auto'
}
},
// Default content type if cannot be detected automatically
defaultType : 'image',
// Open/close animation type
// Possible values:
// false - disable
// "zoom" - zoom images from/to thumbnail
// "fade"
// "zoom-in-out"
//
animationEffect : "zoom",
// Duration in ms for open/close animation
animationDuration : 500,
// Should image change opacity while zooming
// If opacity is "auto", then opacity will be changed if image and thumbnail have different aspect ratios
zoomOpacity : "auto",
// Transition effect between slides
//
// Possible values:
// false - disable
// "fade'
// "slide'
// "circular'
// "tube'
// "zoom-in-out'
// "rotate'
//
transitionEffect : "fade",
// Duration in ms for transition animation
transitionDuration : 366,
// Custom CSS class for slide element
slideClass : '',
// Custom CSS class for layout
baseClass : '',
// Base template for layout
baseTpl :
'
',
btnTpl : {
download : '' +
'' +
'',
zoom : '',
close : '',
// This small close button will be appended to your html/inline/ajax content by default,
// if "smallBtn" option is not set to false
smallBtn : '',
// Arrows
arrowLeft : '',
arrowRight : ''
},
// Container is injected into this element
parentEl : 'body',
// Focus handling
// ==============
// Try to focus on the first focusable element after opening
autoFocus : false,
// Put focus back to active element after closing
backFocus : true,
// Do not let user to focus on element outside modal content
trapFocus : true,
// Module specific options
// =======================
fullScreen : {
autoStart : false,
},
// Set `touch: false` to disable dragging/swiping
touch : {
vertical : true, // Allow to drag content vertically
momentum : true // Continue movement after releasing mouse/touch when panning
},
// Hash value when initializing manually,
// set `false` to disable hash change
hash : null,
// Customize or add new media types
// Example:
/*
media : {
youtube : {
params : {
autoplay : 0
}
}
}
*/
media : {},
slideShow : {
autoStart : false,
speed : 4000
},
thumbs : {
autoStart : false, // Display thumbnails on opening
hideOnClose : true, // Hide thumbnail grid when closing animation starts
parentEl : '.fancybox-container', // Container is injected into this element
axis : 'y' // Vertical (y) or horizontal (x) scrolling
},
// Use mousewheel to navigate gallery
// If 'auto' - enabled for images only
wheel : 'auto',
// Callbacks
//==========
// See Documentation/API/Events for more information
// Example:
/*
afterShow: function( instance, current ) {
console.info( 'Clicked element:' );
console.info( current.opts.$orig );
}
*/
onInit : $.noop, // When instance has been initialized
beforeLoad : $.noop, // Before the content of a slide is being loaded
afterLoad : $.noop, // When the content of a slide is done loading
beforeShow : $.noop, // Before open animation starts
afterShow : $.noop, // When content is done loading and animating
beforeClose : $.noop, // Before the instance attempts to close. Return false to cancel the close.
afterClose : $.noop, // After instance has been closed
onActivate : $.noop, // When instance is brought to front
onDeactivate : $.noop, // When other instance has been activated
// Interaction
// ===========
// Use options below to customize taken action when user clicks or double clicks on the fancyBox area,
// each option can be string or method that returns value.
//
// Possible values:
// "close" - close instance
// "next" - move to next gallery item
// "nextOrClose" - move to next gallery item or close if gallery has only one item
// "toggleControls" - show/hide controls
// "zoom" - zoom image (if loaded)
// false - do nothing
// Clicked on the content
clickContent : function( current, event ) {
return current.type === 'image' ? 'zoom' : false;
},
// Clicked on the slide
clickSlide : 'close',
// Clicked on the background (backdrop) element
clickOutside : 'close',
// Same as previous two, but for double click
dblclickContent : false,
dblclickSlide : false,
dblclickOutside : false,
// Custom options when mobile device is detected
// =============================================
mobile : {
idleTime : false,
margin : 0,
clickContent : function( current, event ) {
return current.type === 'image' ? 'toggleControls' : false;
},
clickSlide : function( current, event ) {
return current.type === 'image' ? 'toggleControls' : 'close';
},
dblclickContent : function( current, event ) {
return current.type === 'image' ? 'zoom' : false;
},
dblclickSlide : function( current, event ) {
return current.type === 'image' ? 'zoom' : false;
}
},
// Internationalization
// ============
lang : 'en',
i18n : {
'en' : {
CLOSE : 'Close',
NEXT : 'Next',
PREV : 'Previous',
ERROR : 'The requested content cannot be loaded. Please try again later.',
PLAY_START : 'Start slideshow',
PLAY_STOP : 'Pause slideshow',
FULL_SCREEN : 'Full screen',
THUMBS : 'Thumbnails',
DOWNLOAD : 'Download',
SHARE : 'Share',
ZOOM : 'Zoom'
},
'de' : {
CLOSE : 'Schliessen',
NEXT : 'Weiter',
PREV : 'Zurück',
ERROR : 'Die angeforderten Daten konnten nicht geladen werden. Bitte versuchen Sie es später nochmal.',
PLAY_START : 'Diaschau starten',
PLAY_STOP : 'Diaschau beenden',
FULL_SCREEN : 'Vollbild',
THUMBS : 'Vorschaubilder',
DOWNLOAD : 'Herunterladen',
SHARE : 'Teilen',
ZOOM : 'Maßstab'
}
}
};
// Few useful variables and methods
// ================================
var $W = $(window);
var $D = $(document);
var called = 0;
// Check if an object is a jQuery object and not a native JavaScript object
// ========================================================================
var isQuery = function ( obj ) {
return obj && obj.hasOwnProperty && obj instanceof $;
};
// Handle multiple browsers for "requestAnimationFrame" and "cancelAnimationFrame"
// ===============================================================================
var requestAFrame = (function () {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
// if all else fails, use setTimeout
function (callback) {
return window.setTimeout(callback, 1000 / 60);
};
})();
// Detect the supported transition-end event property name
// =======================================================
var transitionEnd = (function () {
var t, el = document.createElement("fakeelement");
var transitions = {
"transition" : "transitionend",
"OTransition" : "oTransitionEnd",
"MozTransition" : "transitionend",
"WebkitTransition": "webkitTransitionEnd"
};
for (t in transitions) {
if (el.style[t] !== undefined){
return transitions[t];
}
}
return 'transitionend';
})();
// Force redraw on an element.
// This helps in cases where the browser doesn't redraw an updated element properly.
// =================================================================================
var forceRedraw = function( $el ) {
return ( $el && $el.length && $el[0].offsetHeight );
};
// Class definition
// ================
var FancyBox = function( content, opts, index ) {
var self = this;
self.opts = $.extend( true, { index : index }, $.fancybox.defaults, opts || {} );
if ( $.fancybox.isMobile ) {
self.opts = $.extend( true, {}, self.opts, self.opts.mobile );
}
// Exclude buttons option from deep merging
if ( opts && $.isArray( opts.buttons ) ) {
self.opts.buttons = opts.buttons;
}
self.id = self.opts.id || ++called;
self.group = [];
self.currIndex = parseInt( self.opts.index, 10 ) || 0;
self.prevIndex = null;
self.prevPos = null;
self.currPos = 0;
self.firstRun = null;
// Create group elements from original item collection
self.createGroup( content );
if ( !self.group.length ) {
return;
}
// Save last active element and current scroll position
self.$lastFocus = $(document.activeElement).blur();
// Collection of gallery objects
self.slides = {};
self.init();
};
$.extend(FancyBox.prototype, {
// Create DOM structure
// ====================
init : function() {
var self = this,
firstItem = self.group[ self.currIndex ],
firstItemOpts = firstItem.opts,
scrollbarWidth = $.fancybox.scrollbarWidth,
$scrollDiv,
$container,
buttonStr;
self.scrollTop = $D.scrollTop();
self.scrollLeft = $D.scrollLeft();
// Hide scrollbars
// ===============
if ( !$.fancybox.getInstance() ) {
$( 'body' ).addClass( 'fancybox-active' );
// iOS hack
if ( /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream ) {
// iOS has problems for input elements inside fixed containers,
// the workaround is to apply `position: fixed` to `` element,
// unfortunately, this makes it lose the scrollbars and forces address bar to appear.
if ( firstItem.type !== 'image' ) {
$( 'body' ).css( 'top', $( 'body' ).scrollTop() * -1 ).addClass( 'fancybox-iosfix' );
}
} else if ( !$.fancybox.isMobile && document.body.scrollHeight > window.innerHeight ) {
if ( scrollbarWidth === undefined ) {
$scrollDiv = $('').appendTo( 'body' );
scrollbarWidth = $.fancybox.scrollbarWidth = $scrollDiv[0].offsetWidth - $scrollDiv[0].clientWidth;
$scrollDiv.remove();
}
$( 'head' ).append( '' );
$( 'body' ).addClass( 'compensate-for-scrollbar' );
}
}
// Build html markup and set references
// ====================================
// Build html code for buttons and insert into main template
buttonStr = '';
$.each( firstItemOpts.buttons, function( index, value ) {
buttonStr += ( firstItemOpts.btnTpl[ value ] || '' );
});
// Create markup from base template, it will be initially hidden to
// avoid unnecessary work like painting while initializing is not complete
$container = $(
self.translate( self,
firstItemOpts.baseTpl
.replace( '\{\{buttons\}\}', buttonStr )
.replace( '\{\{arrows\}\}', firstItemOpts.btnTpl.arrowLeft + firstItemOpts.btnTpl.arrowRight )
)
)
.attr( 'id', 'fancybox-container-' + self.id )
.addClass( 'fancybox-is-hidden' )
.addClass( firstItemOpts.baseClass )
.data( 'FancyBox', self )
.appendTo( firstItemOpts.parentEl );
// Create object holding references to jQuery wrapped nodes
self.$refs = {
container : $container
};
[ 'bg', 'inner', 'infobar', 'toolbar', 'stage', 'caption', 'navigation' ].forEach(function(item) {
self.$refs[ item ] = $container.find( '.fancybox-' + item );
});
self.trigger( 'onInit' );
// Enable events, deactive previous instances
self.activate();
// Build slides, load and reveal content
self.jumpTo( self.currIndex );
},
// Simple i18n support - replaces object keys found in template
// with corresponding values
// ============================================================
translate : function( obj, str ) {
var arr = obj.opts.i18n[ obj.opts.lang ];
return str.replace(/\{\{(\w+)\}\}/g, function(match, n) {
var value = arr[n];
if ( value === undefined ) {
return match;
}
return value;
});
},
// Create array of gally item objects
// Check if each object has valid type and content
// ===============================================
createGroup : function ( content ) {
var self = this;
var items = $.makeArray( content );
$.each(items, function( i, item ) {
var obj = {},
opts = {},
$item,
type,
found,
src,
srcParts;
// Step 1 - Make sure we have an object
// ====================================
if ( $.isPlainObject( item ) ) {
// We probably have manual usage here, something like
// $.fancybox.open( [ { src : "image.jpg", type : "image" } ] )
obj = item;
opts = item.opts || item;
} else if ( $.type( item ) === 'object' && $( item ).length ) {
// Here we probably have jQuery collection returned by some selector
$item = $( item );
opts = $item.data();
opts = $.extend( {}, opts, opts.options || {} );
// Here we store clicked element
opts.$orig = $item;
obj.src = opts.src || $item.attr( 'href' );
// Assume that simple syntax is used, for example:
// `$.fancybox.open( $("#test"), {} );`
if ( !obj.type && !obj.src ) {
obj.type = 'inline';
obj.src = item;
}
} else {
// Assume we have a simple html code, for example:
// $.fancybox.open( '
Hi!
' );
obj = {
type : 'html',
src : item + ''
};
}
// Each gallery object has full collection of options
obj.opts = $.extend( true, {}, self.opts, opts );
// Do not merge buttons array
if ( $.isArray( opts.buttons ) ) {
obj.opts.buttons = opts.buttons;
}
// Step 2 - Make sure we have content type, if not - try to guess
// ==============================================================
type = obj.type || obj.opts.type;
src = obj.src || '';
if ( !type && src ) {
if ( src.match(/(^data:image\/[a-z0-9+\/=]*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg|ico)((\?|#).*)?$)/i) ) {
type = 'image';
} else if ( src.match(/\.(pdf)((\?|#).*)?$/i) ) {
type = 'pdf';
} else if ( found = src.match(/\.(mp4|mov|ogv)((\?|#).*)?$/i) ) {
type = 'video';
if ( !obj.opts.videoFormat ) {
obj.opts.videoFormat = 'video/' + ( found[1] === 'ogv' ? 'ogg' : found[1] );
}
} else if ( src.charAt(0) === '#' ) {
type = 'inline';
}
}
if ( type ) {
obj.type = type;
} else {
self.trigger( 'objectNeedsType', obj );
}
// Step 3 - Some adjustments
// =========================
obj.index = self.group.length;
// Check if $orig and $thumb objects exist
if ( obj.opts.$orig && !obj.opts.$orig.length ) {
delete obj.opts.$orig;
}
if ( !obj.opts.$thumb && obj.opts.$orig ) {
obj.opts.$thumb = obj.opts.$orig.find( 'img:first' );
}
if ( obj.opts.$thumb && !obj.opts.$thumb.length ) {
delete obj.opts.$thumb;
}
// "caption" is a "special" option, it can be used to customize caption per gallery item ..
if ( $.type( obj.opts.caption ) === 'function' ) {
obj.opts.caption = obj.opts.caption.apply( item, [ self, obj ] );
}
if ( $.type( self.opts.caption ) === 'function' ) {
obj.opts.caption = self.opts.caption.apply( item, [ self, obj ] );
}
// Make sure we have caption as a string or jQuery object
if ( !( obj.opts.caption instanceof $ ) ) {
obj.opts.caption = obj.opts.caption === undefined ? '' : obj.opts.caption + '';
}
// Check if url contains "filter" used to filter the content
// Example: "ajax.html #something"
if ( type === 'ajax' ) {
srcParts = src.split(/\s+/, 2);
if ( srcParts.length > 1 ) {
obj.src = srcParts.shift();
obj.opts.filter = srcParts.shift();
}
}
if ( obj.opts.smallBtn == 'auto' ) {
if ( $.inArray( type, ['html', 'inline', 'ajax'] ) > -1 ) {
obj.opts.toolbar = false;
obj.opts.smallBtn = true;
} else {
obj.opts.smallBtn = false;
}
}
// If the type is "pdf", then simply load file into iframe
if ( type === 'pdf' ) {
obj.type = 'iframe';
obj.opts.iframe.preload = false;
}
// Hide all buttons and disable interactivity for modal items
if ( obj.opts.modal ) {
obj.opts = $.extend(true, obj.opts, {
// Remove buttons
infobar : 0,
toolbar : 0,
smallBtn : 0,
// Disable keyboard navigation
keyboard : 0,
// Disable some modules
slideShow : 0,
fullScreen : 0,
thumbs : 0,
touch : 0,
// Disable click event handlers
clickContent : false,
clickSlide : false,
clickOutside : false,
dblclickContent : false,
dblclickSlide : false,
dblclickOutside : false
});
}
// Step 4 - Add processed object to group
// ======================================
self.group.push( obj );
});
},
// Attach an event handler functions for:
// - navigation buttons
// - browser scrolling, resizing;
// - focusing
// - keyboard
// - detect idle
// ======================================
addEvents : function() {
var self = this;
self.removeEvents();
// Make navigation elements clickable
self.$refs.container.on('click.fb-close', '[data-fancybox-close]', function(e) {
e.stopPropagation();
e.preventDefault();
self.close( e );
}).on( 'click.fb-prev touchend.fb-prev', '[data-fancybox-prev]', function(e) {
e.stopPropagation();
e.preventDefault();
self.previous();
}).on( 'click.fb-next touchend.fb-next', '[data-fancybox-next]', function(e) {
e.stopPropagation();
e.preventDefault();
self.next();
}).on( 'click.fb', '[data-fancybox-zoom]', function(e) {
// Click handler for zoom button
self[ self.isScaledDown() ? 'scaleToActual' : 'scaleToFit' ]();
});
// Handle page scrolling and browser resizing
$W.on('orientationchange.fb resize.fb', function(e) {
if ( e && e.originalEvent && e.originalEvent.type === "resize" ) {
requestAFrame(function() {
self.update();
});
} else {
self.$refs.stage.hide();
setTimeout(function() {
self.$refs.stage.show();
self.update();
}, 600);
}
});
// Trap keyboard focus inside of the modal, so the user does not accidentally tab outside of the modal
// (a.k.a. "escaping the modal")
$D.on('focusin.fb', function(e) {
var instance = $.fancybox ? $.fancybox.getInstance() : null;
if ( instance.isClosing || !instance.current || !instance.current.opts.trapFocus || $( e.target ).hasClass( 'fancybox-container' ) || $( e.target ).is( document ) ) {
return;
}
if ( instance && $( e.target ).css( 'position' ) !== 'fixed' && !instance.$refs.container.has( e.target ).length ) {
e.stopPropagation();
instance.focus();
// Sometimes page gets scrolled, set it back
$W.scrollTop( self.scrollTop ).scrollLeft( self.scrollLeft );
}
});
// Enable keyboard navigation
$D.on('keydown.fb', function (e) {
var current = self.current,
keycode = e.keyCode || e.which;
if ( !current || !current.opts.keyboard ) {
return;
}
if ( $(e.target).is('input') || $(e.target).is('textarea') ) {
return;
}
// Backspace and Esc keys
if ( keycode === 8 || keycode === 27 ) {
e.preventDefault();
self.close( e );
return;
}
// Left arrow and Up arrow
if ( keycode === 37 || keycode === 38 ) {
e.preventDefault();
self.previous();
return;
}
// Righ arrow and Down arrow
if ( keycode === 39 || keycode === 40 ) {
e.preventDefault();
self.next();
return;
}
self.trigger('afterKeydown', e, keycode);
});
// Hide controls after some inactivity period
if ( self.group[ self.currIndex ].opts.idleTime ) {
self.idleSecondsCounter = 0;
$D.on('mousemove.fb-idle mouseleave.fb-idle mousedown.fb-idle touchstart.fb-idle touchmove.fb-idle scroll.fb-idle keydown.fb-idle', function(e) {
self.idleSecondsCounter = 0;
if ( self.isIdle ) {
self.showControls();
}
self.isIdle = false;
});
self.idleInterval = window.setInterval(function() {
self.idleSecondsCounter++;
if ( self.idleSecondsCounter >= self.group[ self.currIndex ].opts.idleTime && !self.isDragging ) {
self.isIdle = true;
self.idleSecondsCounter = 0;
self.hideControls();
}
}, 1000);
}
},
// Remove events added by the core
// ===============================
removeEvents : function() {
var self = this;
$W.off( 'orientationchange.fb resize.fb' );
$D.off( 'focusin.fb keydown.fb .fb-idle' );
this.$refs.container.off( '.fb-close .fb-prev .fb-next' );
if ( self.idleInterval ) {
window.clearInterval( self.idleInterval );
self.idleInterval = null;
}
},
// Change to previous gallery item
// ===============================
previous : function( duration ) {
return this.jumpTo( this.currPos - 1, duration );
},
// Change to next gallery item
// ===========================
next : function( duration ) {
return this.jumpTo( this.currPos + 1, duration );
},
// Switch to selected gallery item
// ===============================
jumpTo : function ( pos, duration, slide ) {
var self = this,
firstRun,
loop,
current,
previous,
canvasWidth,
currentPos,
transitionProps;
var groupLen = self.group.length;
if ( self.isDragging || self.isClosing || ( self.isAnimating && self.firstRun ) ) {
return;
}
pos = parseInt( pos, 10 );
loop = self.current ? self.current.opts.loop : self.opts.loop;
if ( !loop && ( pos < 0 || pos >= groupLen ) ) {
return false;
}
firstRun = self.firstRun = ( self.firstRun === null );
if ( groupLen < 2 && !firstRun && !!self.isDragging ) {
return;
}
previous = self.current;
self.prevIndex = self.currIndex;
self.prevPos = self.currPos;
// Create slides
current = self.createSlide( pos );
if ( groupLen > 1 ) {
if ( loop || current.index > 0 ) {
self.createSlide( pos - 1 );
}
if ( loop || current.index < groupLen - 1 ) {
self.createSlide( pos + 1 );
}
}
self.current = current;
self.currIndex = current.index;
self.currPos = current.pos;
self.trigger( 'beforeShow', firstRun );
self.updateControls();
currentPos = $.fancybox.getTranslate( current.$slide );
current.isMoved = ( currentPos.left !== 0 || currentPos.top !== 0 ) && !current.$slide.hasClass( 'fancybox-animated' );
current.forcedDuration = undefined;
if ( $.isNumeric( duration ) ) {
current.forcedDuration = duration;
} else {
duration = current.opts[ firstRun ? 'animationDuration' : 'transitionDuration' ];
}
duration = parseInt( duration, 10 );
// Fresh start - reveal container, current slide and start loading content
if ( firstRun ) {
if ( current.opts.animationEffect && duration ) {
self.$refs.container.css( 'transition-duration', duration + 'ms' );
}
self.$refs.container.removeClass( 'fancybox-is-hidden' );
forceRedraw( self.$refs.container );
self.$refs.container.addClass( 'fancybox-is-open' );
// Make first slide visible (to display loading icon, if needed)
current.$slide.addClass( 'fancybox-slide--current' );
self.loadSlide( current );
self.preload( 'image' );
return;
}
// Clean up
$.each(self.slides, function( index, slide ) {
$.fancybox.stop( slide.$slide );
});
// Make current that slide is visible even if content is still loading
current.$slide.removeClass( 'fancybox-slide--next fancybox-slide--previous' ).addClass( 'fancybox-slide--current' );
// If slides have been dragged, animate them to correct position
if ( current.isMoved ) {
canvasWidth = Math.round( current.$slide.width() );
$.each(self.slides, function( index, slide ) {
var pos = slide.pos - current.pos;
$.fancybox.animate( slide.$slide, {
top : 0,
left : ( pos * canvasWidth ) + ( pos * slide.opts.gutter )
}, duration, function() {
slide.$slide.removeAttr('style').removeClass( 'fancybox-slide--next fancybox-slide--previous' );
if ( slide.pos === self.currPos ) {
current.isMoved = false;
self.complete();
}
});
});
} else {
self.$refs.stage.children().removeAttr( 'style' );
}
// Start transition that reveals current content
// or wait when it will be loaded
if ( current.isLoaded ) {
self.revealContent( current );
} else {
self.loadSlide( current );
}
self.preload( 'image' );
if ( previous.pos === current.pos ) {
return;
}
// Handle previous slide
// =====================
transitionProps = 'fancybox-slide--' + ( previous.pos > current.pos ? 'next' : 'previous' );
previous.$slide.removeClass( 'fancybox-slide--complete fancybox-slide--current fancybox-slide--next fancybox-slide--previous' );
previous.isComplete = false;
if ( !duration || ( !current.isMoved && !current.opts.transitionEffect ) ) {
return;
}
if ( current.isMoved ) {
previous.$slide.addClass( transitionProps );
} else {
transitionProps = 'fancybox-animated ' + transitionProps + ' fancybox-fx-' + current.opts.transitionEffect;
$.fancybox.animate( previous.$slide, transitionProps, duration, function() {
previous.$slide.removeClass( transitionProps ).removeAttr( 'style' );
});
}
},
// Create new "slide" element
// These are gallery items that are actually added to DOM
// =======================================================
createSlide : function( pos ) {
var self = this;
var $slide;
var index;
index = pos % self.group.length;
index = index < 0 ? self.group.length + index : index;
if ( !self.slides[ pos ] && self.group[ index ] ) {
$slide = $('').appendTo( self.$refs.stage );
self.slides[ pos ] = $.extend( true, {}, self.group[ index ], {
pos : pos,
$slide : $slide,
isLoaded : false,
});
self.updateSlide( self.slides[ pos ] );
}
return self.slides[ pos ];
},
// Scale image to the actual size of the image
// ===========================================
scaleToActual : function( x, y, duration ) {
var self = this;
var current = self.current;
var $what = current.$content;
var imgPos, posX, posY, scaleX, scaleY;
var canvasWidth = parseInt( current.$slide.width(), 10 );
var canvasHeight = parseInt( current.$slide.height(), 10 );
var newImgWidth = current.width;
var newImgHeight = current.height;
if ( !( current.type == 'image' && !current.hasError) || !$what || self.isAnimating ) {
return;
}
$.fancybox.stop( $what );
self.isAnimating = true;
x = x === undefined ? canvasWidth * 0.5 : x;
y = y === undefined ? canvasHeight * 0.5 : y;
imgPos = $.fancybox.getTranslate( $what );
scaleX = newImgWidth / imgPos.width;
scaleY = newImgHeight / imgPos.height;
// Get center position for original image
posX = ( canvasWidth * 0.5 - newImgWidth * 0.5 );
posY = ( canvasHeight * 0.5 - newImgHeight * 0.5 );
// Make sure image does not move away from edges
if ( newImgWidth > canvasWidth ) {
posX = imgPos.left * scaleX - ( ( x * scaleX ) - x );
if ( posX > 0 ) {
posX = 0;
}
if ( posX < canvasWidth - newImgWidth ) {
posX = canvasWidth - newImgWidth;
}
}
if ( newImgHeight > canvasHeight) {
posY = imgPos.top * scaleY - ( ( y * scaleY ) - y );
if ( posY > 0 ) {
posY = 0;
}
if ( posY < canvasHeight - newImgHeight ) {
posY = canvasHeight - newImgHeight;
}
}
self.updateCursor( newImgWidth, newImgHeight );
$.fancybox.animate( $what, {
top : posY,
left : posX,
scaleX : scaleX,
scaleY : scaleY
}, duration || 330, function() {
self.isAnimating = false;
});
// Stop slideshow
if ( self.SlideShow && self.SlideShow.isActive ) {
self.SlideShow.stop();
}
},
// Scale image to fit inside parent element
// ========================================
scaleToFit : function( duration ) {
var self = this;
var current = self.current;
var $what = current.$content;
var end;
if ( !( current.type == 'image' && !current.hasError) || !$what || self.isAnimating ) {
return;
}
$.fancybox.stop( $what );
self.isAnimating = true;
end = self.getFitPos( current );
self.updateCursor( end.width, end.height );
$.fancybox.animate( $what, {
top : end.top,
left : end.left,
scaleX : end.width / $what.width(),
scaleY : end.height / $what.height()
}, duration || 330, function() {
self.isAnimating = false;
});
},
// Calculate image size to fit inside viewport
// ===========================================
getFitPos : function( slide ) {
var self = this;
var $what = slide.$content;
var imgWidth = slide.width;
var imgHeight = slide.height;
var margin = slide.opts.margin;
var canvasWidth, canvasHeight, minRatio, width, height;
if ( !$what || !$what.length || ( !imgWidth && !imgHeight) ) {
return false;
}
// Convert "margin to CSS style: [ top, right, bottom, left ]
if ( $.type( margin ) === "number" ) {
margin = [ margin, margin ];
}
if ( margin.length == 2 ) {
margin = [ margin[0], margin[1], margin[0], margin[1] ];
}
// We can not use $slide width here, because it can have different diemensions while in transiton
canvasWidth = parseInt( self.$refs.stage.width(), 10 ) - ( margin[ 1 ] + margin[ 3 ] );
canvasHeight = parseInt( self.$refs.stage.height(), 10 ) - ( margin[ 0 ] + margin[ 2 ] );
minRatio = Math.min(1, canvasWidth / imgWidth, canvasHeight / imgHeight );
width = Math.floor( minRatio * imgWidth );
height = Math.floor( minRatio * imgHeight );
// Use floor rounding to make sure it really fits
return {
top : Math.floor( ( canvasHeight - height ) * 0.5 ) + margin[ 0 ],
left : Math.floor( ( canvasWidth - width ) * 0.5 ) + margin[ 3 ],
width : width,
height : height
};
},
// Update content size and position for all slides
// ==============================================
update : function() {
var self = this;
$.each( self.slides, function( key, slide ) {
self.updateSlide( slide );
});
},
// Update slide content position and size
// ======================================
updateSlide : function( slide, duration ) {
var self = this,
$what = slide && slide.$content;
if ( $what && ( slide.width || slide.height ) ) {
self.isAnimating = false;
$.fancybox.stop( $what );
$.fancybox.setTranslate( $what, self.getFitPos( slide ) );
if ( slide.pos === self.currPos ) {
self.updateCursor();
}
}
slide.$slide.trigger( 'refresh' );
self.trigger( 'onUpdate', slide );
},
// Horizontally center slide
// =========================
centerSlide : function( slide, duration ) {
var self = this, canvasWidth, pos;
if ( self.current ) {
canvasWidth = Math.round( slide.$slide.width() );
pos = slide.pos - self.current.pos;
$.fancybox.animate( slide.$slide, {
top : 0,
left : ( pos * canvasWidth ) + ( pos * slide.opts.gutter ),
opacity : 1
}, duration === undefined ? 0 : duration, null, false);
}
},
// Update cursor style depending if content can be zoomed
// ======================================================
updateCursor : function( nextWidth, nextHeight ) {
var self = this;
var isScaledDown;
var $container = self.$refs.container.removeClass( 'fancybox-is-zoomable fancybox-can-zoomIn fancybox-can-drag fancybox-can-zoomOut' );
if ( !self.current || self.isClosing ) {
return;
}
if ( self.isZoomable() ) {
$container.addClass( 'fancybox-is-zoomable' );
if ( nextWidth !== undefined && nextHeight !== undefined ) {
isScaledDown = nextWidth < self.current.width && nextHeight < self.current.height;
} else {
isScaledDown = self.isScaledDown();
}
if ( isScaledDown ) {
// If image is scaled down, then, obviously, it can be zoomed to full size
$container.addClass( 'fancybox-can-zoomIn' );
} else {
if ( self.current.opts.touch ) {
// If image size ir largen than available available and touch module is not disable,
// then user can do panning
$container.addClass( 'fancybox-can-drag' );
} else {
$container.addClass( 'fancybox-can-zoomOut' );
}
}
} else if ( self.current.opts.touch ) {
$container.addClass( 'fancybox-can-drag' );
}
},
// Check if current slide is zoomable
// ==================================
isZoomable : function() {
var self = this;
var current = self.current;
var fitPos;
if ( !current || self.isClosing ) {
return;
}
// Assume that slide is zoomable if
// - image is loaded successfuly
// - click action is "zoom"
// - actual size of the image is smaller than available area
if ( current.type === 'image' && current.isLoaded && !current.hasError &&
( current.opts.clickContent === 'zoom' || ( $.isFunction( current.opts.clickContent ) && current.opts.clickContent( current ) === "zoom" ) )
) {
fitPos = self.getFitPos( current );
if ( current.width > fitPos.width || current.height > fitPos.height ) {
return true;
}
}
return false;
},
// Check if current image dimensions are smaller than actual
// =========================================================
isScaledDown : function() {
var self = this;
var current = self.current;
var $what = current.$content;
var rez = false;
if ( $what ) {
rez = $.fancybox.getTranslate( $what );
rez = rez.width < current.width || rez.height < current.height;
}
return rez;
},
// Check if image dimensions exceed parent element
// ===============================================
canPan : function() {
var self = this;
var current = self.current;
var $what = current.$content;
var rez = false;
if ( $what ) {
rez = self.getFitPos( current );
rez = Math.abs( $what.width() - rez.width ) > 1 || Math.abs( $what.height() - rez.height ) > 1;
}
return rez;
},
// Load content into the slide
// ===========================
loadSlide : function( slide ) {
var self = this, type, $slide;
var ajaxLoad;
if ( slide.isLoading ) {
return;
}
if ( slide.isLoaded ) {
return;
}
slide.isLoading = true;
self.trigger( 'beforeLoad', slide );
type = slide.type;
$slide = slide.$slide;
$slide
.off( 'refresh' )
.trigger( 'onReset' )
.addClass( 'fancybox-slide--' + ( type || 'unknown' ) )
.addClass( slide.opts.slideClass );
// Create content depending on the type
switch ( type ) {
case 'image':
self.setImage( slide );
break;
case 'iframe':
self.setIframe( slide );
break;
case 'html':
self.setContent( slide, slide.src || slide.content );
break;
case 'inline':
if ( $( slide.src ).length ) {
self.setContent( slide, $( slide.src ) );
} else {
self.setError( slide );
}
break;
case 'ajax':
self.showLoading( slide );
ajaxLoad = $.ajax( $.extend( {}, slide.opts.ajax.settings, {
url : slide.src,
success : function ( data, textStatus ) {
if ( textStatus === 'success' ) {
self.setContent( slide, data );
}
},
error : function ( jqXHR, textStatus ) {
if ( jqXHR && textStatus !== 'abort' ) {
self.setError( slide );
}
}
}));
$slide.one( 'onReset', function () {
ajaxLoad.abort();
});
break;
case 'video' :
self.setContent( slide,
''
);
break;
default:
self.setError( slide );
break;
}
return true;
},
// Use thumbnail image, if possible
// ================================
setImage : function( slide ) {
var self = this;
var srcset = slide.opts.srcset || slide.opts.image.srcset;
var found, temp, pxRatio, windowWidth;
// If we have "srcset", then we need to find matching "src" value.
// This is necessary, because when you set an src attribute, the browser will preload the image
// before any javascript or even CSS is applied.
if ( srcset ) {
pxRatio = window.devicePixelRatio || 1;
windowWidth = window.innerWidth * pxRatio;
temp = srcset.split(',').map(function ( el ) {
var ret = {};
el.trim().split(/\s+/).forEach(function ( el, i ) {
var value = parseInt( el.substring(0, el.length - 1), 10 );
if ( i === 0 ) {
return ( ret.url = el );
}
if ( value ) {
ret.value = value;
ret.postfix = el[ el.length - 1 ];
}
});
return ret;
});
// Sort by value
temp.sort(function (a, b) {
return a.value - b.value;
});
// Ok, now we have an array of all srcset values
for ( var j = 0; j < temp.length; j++ ) {
var el = temp[ j ];
if ( ( el.postfix === 'w' && el.value >= windowWidth ) || ( el.postfix === 'x' && el.value >= pxRatio ) ) {
found = el;
break;
}
}
// If not found, take the last one
if ( !found && temp.length ) {
found = temp[ temp.length - 1 ];
}
if ( found ) {
slide.src = found.url;
// If we have default width/height values, we can calculate height for matching source
if ( slide.width && slide.height && found.postfix == 'w' ) {
slide.height = ( slide.width / slide.height ) * found.value;
slide.width = found.value;
}
}
}
// This will be wrapper containing both ghost and actual image
slide.$content = $('')
.addClass( 'fancybox-is-hidden' )
.appendTo( slide.$slide );
// If we have a thumbnail, we can display it while actual image is loading
// Users will not stare at black screen and actual image will appear gradually
if ( slide.opts.preload !== false && slide.opts.width && slide.opts.height && ( slide.opts.thumb || slide.opts.$thumb ) ) {
slide.width = slide.opts.width;
slide.height = slide.opts.height;
slide.$ghost = $('')
.one('error', function() {
$(this).remove();
slide.$ghost = null;
self.setBigImage( slide );
})
.one('load', function() {
self.afterLoad( slide );
self.setBigImage( slide );
})
.addClass( 'fancybox-image' )
.appendTo( slide.$content )
.attr( 'src', slide.opts.thumb || slide.opts.$thumb.attr( 'src' ) );
} else {
self.setBigImage( slide );
}
},
// Create full-size image
// ======================
setBigImage : function ( slide ) {
var self = this;
var $img = $('');
slide.$image = $img
.one('error', function() {
self.setError( slide );
})
.one('load', function() {
// Clear timeout that checks if loading icon needs to be displayed
clearTimeout( slide.timouts );
slide.timouts = null;
if ( self.isClosing ) {
return;
}
slide.width = slide.opts.width || this.naturalWidth;
slide.height = slide.opts.height || this.naturalHeight;
if ( slide.opts.image.srcset ) {
$img.attr( 'sizes', '100vw' ).attr( 'srcset', slide.opts.image.srcset );
}
self.hideLoading( slide );
if ( slide.$ghost ) {
slide.timouts = setTimeout(function() {
slide.timouts = null;
slide.$ghost.hide();
}, Math.min( 300, Math.max( 1000, slide.height / 1600 ) ) );
} else {
self.afterLoad( slide );
}
})
.addClass( 'fancybox-image' )
.attr('src', slide.src)
.appendTo( slide.$content );
if ( ( $img[0].complete || $img[0].readyState == "complete" ) && $img[0].naturalWidth && $img[0].naturalHeight ) {
$img.trigger( 'load' );
} else if( $img[0].error ) {
$img.trigger( 'error' );
} else {
slide.timouts = setTimeout(function() {
if ( !$img[0].complete && !slide.hasError ) {
self.showLoading( slide );
}
}, 100);
}
},
// Create iframe wrapper, iframe and bindings
// ==========================================
setIframe : function( slide ) {
var self = this,
opts = slide.opts.iframe,
$slide = slide.$slide,
$iframe;
slide.$content = $('')
.css( opts.css )
.appendTo( $slide );
$iframe = $( opts.tpl.replace(/\{rnd\}/g, new Date().getTime()) )
.attr( opts.attr )
.appendTo( slide.$content );
if ( opts.preload ) {
self.showLoading( slide );
// Unfortunately, it is not always possible to determine if iframe is successfully loaded
// (due to browser security policy)
$iframe.on('load.fb error.fb', function(e) {
this.isReady = 1;
slide.$slide.trigger( 'refresh' );
self.afterLoad( slide );
});
// Recalculate iframe content size
// ===============================
$slide.on('refresh.fb', function() {
var $wrap = slide.$content,
frameWidth = opts.css.width,
frameHeight = opts.css.height,
scrollWidth,
$contents,
$body;
if ( $iframe[0].isReady !== 1 ) {
return;
}
// Check if content is accessible,
// it will fail if frame is not with the same origin
try {
$contents = $iframe.contents();
$body = $contents.find('body');
} catch (ignore) {}
// Calculate dimensions for the wrapper
if ( $body && $body.length ) {
if ( frameWidth === undefined ) {
scrollWidth = $iframe[0].contentWindow.document.documentElement.scrollWidth;
frameWidth = Math.ceil( $body.outerWidth(true) + ( $wrap.width() - scrollWidth ) );
frameWidth += $wrap.outerWidth() - $wrap.innerWidth();
}
if ( frameHeight === undefined ) {
frameHeight = Math.ceil( $body.outerHeight(true) );
frameHeight += $wrap.outerHeight() - $wrap.innerHeight();
}
// Resize wrapper to fit iframe content
if ( frameWidth ) {
$wrap.width( frameWidth );
}
if ( frameHeight ) {
$wrap.height( frameHeight );
}
}
$wrap.removeClass( 'fancybox-is-hidden' );
});
} else {
this.afterLoad( slide );
}
$iframe.attr( 'src', slide.src );
if ( slide.opts.smallBtn === true ) {
slide.$content.prepend( self.translate( slide, slide.opts.btnTpl.smallBtn ) );
}
// Remove iframe if closing or changing gallery item
$slide.one( 'onReset', function () {
// This helps IE not to throw errors when closing
try {
$( this ).find( 'iframe' ).hide().attr( 'src', '//about:blank' );
} catch ( ignore ) {}
$( this ).empty();
slide.isLoaded = false;
});
},
// Wrap and append content to the slide
// ======================================
setContent : function ( slide, content ) {
var self = this;
if ( self.isClosing ) {
return;
}
self.hideLoading( slide );
slide.$slide.empty();
if ( isQuery( content ) && content.parent().length ) {
// If content is a jQuery object, then it will be moved to the slide.
// The placeholder is created so we will know where to put it back.
// If user is navigating gallery fast, then the content might be already inside fancyBox
// =====================================================================================
// Make sure content is not already moved to fancyBox
content.parent( '.fancybox-slide--inline' ).trigger( 'onReset' );
// Create temporary element marking original place of the content
slide.$placeholder = $( '' ).hide().insertAfter( content );
// Make sure content is visible
content.css('display', 'inline-block');
} else if ( !slide.hasError ) {
// If content is just a plain text, try to convert it to html
if ( $.type( content ) === 'string' ) {
content = $('
').append( $.trim( content ) ).contents();
// If we have text node, then add wrapping element to make vertical alignment work
if ( content[0].nodeType === 3 ) {
content = $('
').html( content );
}
}
// If "filter" option is provided, then filter content
if ( slide.opts.filter ) {
content = $('
').html( content ).find( slide.opts.filter );
}
}
slide.$slide.one('onReset', function () {
// Pause all html5 video/audio
$( this ).find( 'video,audio' ).trigger( 'pause' );
// Put content back
if ( slide.$placeholder ) {
slide.$placeholder.after( content.hide() ).remove();
slide.$placeholder = null;
}
// Remove custom close button
if ( slide.$smallBtn ) {
slide.$smallBtn.remove();
slide.$smallBtn = null;
}
// Remove content and mark slide as not loaded
if ( !slide.hasError ) {
$(this).empty();
slide.isLoaded = false;
}
});
slide.$content = $( content ).appendTo( slide.$slide );
this.afterLoad( slide );
},
// Display error message
// =====================
setError : function ( slide ) {
slide.hasError = true;
slide.$slide.removeClass( 'fancybox-slide--' + slide.type );
this.setContent( slide, this.translate( slide, slide.opts.errorTpl ) );
},
// Show loading icon inside the slide
// ==================================
showLoading : function( slide ) {
var self = this;
slide = slide || self.current;
if ( slide && !slide.$spinner ) {
slide.$spinner = $( self.opts.spinnerTpl ).appendTo( slide.$slide );
}
},
// Remove loading icon from the slide
// ==================================
hideLoading : function( slide ) {
var self = this;
slide = slide || self.current;
if ( slide && slide.$spinner ) {
slide.$spinner.remove();
delete slide.$spinner;
}
},
// Adjustments after slide content has been loaded
// ===============================================
afterLoad : function( slide ) {
var self = this;
if ( self.isClosing ) {
return;
}
slide.isLoading = false;
slide.isLoaded = true;
self.trigger( 'afterLoad', slide );
self.hideLoading( slide );
if ( slide.opts.smallBtn && !slide.$smallBtn ) {
slide.$smallBtn = $( self.translate( slide, slide.opts.btnTpl.smallBtn ) ).appendTo( slide.$content.filter('div,form').first() );
}
if ( slide.opts.protect && slide.$content && !slide.hasError ) {
// Disable right click
slide.$content.on( 'contextmenu.fb', function( e ) {
if ( e.button == 2 ) {
e.preventDefault();
}
return true;
});
// Add fake element on top of the image
// This makes a bit harder for user to select image
if ( slide.type === 'image' ) {
$( '' ).appendTo( slide.$content );
}
}
self.revealContent( slide );
},
// Make content visible
// This method is called right after content has been loaded or
// user navigates gallery and transition should start
// ============================================================
revealContent : function( slide ) {
var self = this;
var $slide = slide.$slide;
var effect, effectClassName, duration, opacity, end, start = false;
effect = slide.opts[ self.firstRun ? 'animationEffect' : 'transitionEffect' ];
duration = slide.opts[ self.firstRun ? 'animationDuration' : 'transitionDuration' ];
duration = parseInt( slide.forcedDuration === undefined ? duration : slide.forcedDuration, 10 );
if ( slide.isMoved || slide.pos !== self.currPos || !duration ) {
effect = false;
}
// Check if can zoom
if ( effect === 'zoom' && !( slide.pos === self.currPos && duration && slide.type === 'image' && !slide.hasError && ( start = self.getThumbPos( slide ) ) ) ) {
effect = 'fade';
}
// Zoom animation
// ==============
if ( effect === 'zoom' ) {
end = self.getFitPos( slide );
end.scaleX = end.width / start.width;
end.scaleY = end.height / start.height;
delete end.width;
delete end.height;
// Check if we need to animate opacity
opacity = slide.opts.zoomOpacity;
if ( opacity == 'auto' ) {
opacity = Math.abs( slide.width / slide.height - start.width / start.height ) > 0.1;
}
if ( opacity ) {
start.opacity = 0.1;
end.opacity = 1;
}
// Draw image at start position
$.fancybox.setTranslate( slide.$content.removeClass( 'fancybox-is-hidden' ), start );
forceRedraw( slide.$content );
// Start animation
$.fancybox.animate( slide.$content, end, duration, function() {
self.complete();
});
return;
}
self.updateSlide( slide );
// Simply show content
// ===================
if ( !effect ) {
forceRedraw( $slide );
slide.$content.removeClass( 'fancybox-is-hidden' );
if ( slide.pos === self.currPos ) {
self.complete();
}
return;
}
$.fancybox.stop( $slide );
effectClassName = 'fancybox-animated fancybox-slide--' + ( slide.pos >= self.prevPos ? 'next' : 'previous' ) + ' fancybox-fx-' + effect;
$slide.removeAttr( 'style' ).removeClass( 'fancybox-slide--current fancybox-slide--next fancybox-slide--previous' ).addClass( effectClassName );
slide.$content.removeClass( 'fancybox-is-hidden' );
//Force reflow for CSS3 transitions
forceRedraw( $slide );
$.fancybox.animate( $slide, 'fancybox-slide--current', duration, function(e) {
$slide.removeClass( effectClassName ).removeAttr( 'style' );
if ( slide.pos === self.currPos ) {
self.complete();
}
}, true);
},
// Check if we can and have to zoom from thumbnail
//================================================
getThumbPos : function( slide ) {
var self = this;
var rez = false;
// Check if element is inside the viewport by at least 1 pixel
var isElementVisible = function( $el ) {
var element = $el[0];
var elementRect = element.getBoundingClientRect();
var parentRects = [];
var visibleInAllParents;
while ( element.parentElement !== null ) {
if ( $(element.parentElement).css('overflow') === 'hidden' || $(element.parentElement).css('overflow') === 'auto' ) {
parentRects.push(element.parentElement.getBoundingClientRect());
}
element = element.parentElement;
}
visibleInAllParents = parentRects.every(function(parentRect){
var visiblePixelX = Math.min(elementRect.right, parentRect.right) - Math.max(elementRect.left, parentRect.left);
var visiblePixelY = Math.min(elementRect.bottom, parentRect.bottom) - Math.max(elementRect.top, parentRect.top);
return visiblePixelX > 0 && visiblePixelY > 0;
});
return visibleInAllParents &&
elementRect.bottom > 0 && elementRect.right > 0 &&
elementRect.left < $(window).width() && elementRect.top < $(window).height();
};
var $thumb = slide.opts.$thumb;
var thumbPos = $thumb ? $thumb.offset() : 0;
var slidePos;
if ( thumbPos && $thumb[0].ownerDocument === document && isElementVisible( $thumb ) ) {
slidePos = self.$refs.stage.offset();
rez = {
top : thumbPos.top - slidePos.top + parseFloat( $thumb.css( "border-top-width" ) || 0 ),
left : thumbPos.left - slidePos.left + parseFloat( $thumb.css( "border-left-width" ) || 0 ),
width : $thumb.width(),
height : $thumb.height(),
scaleX : 1,
scaleY : 1
};
}
return rez;
},
// Final adjustments after current gallery item is moved to position
// and it`s content is loaded
// ==================================================================
complete : function() {
var self = this,
current = self.current,
slides = {},
promise;
if ( current.isMoved || !current.isLoaded || current.isComplete ) {
return;
}
current.isComplete = true;
current.$slide.siblings().trigger( 'onReset' );
self.preload( 'inline' );
// Trigger any CSS3 transiton inside the slide
forceRedraw( current.$slide );
current.$slide.addClass( 'fancybox-slide--complete' );
// Remove unnecessary slides
$.each( self.slides, function( key, slide ) {
if ( slide.pos >= self.currPos - 1 && slide.pos <= self.currPos + 1 ) {
slides[ slide.pos ] = slide;
} else if ( slide ) {
$.fancybox.stop( slide.$slide );
slide.$slide.off().remove();
}
});
self.slides = slides;
self.updateCursor();
self.trigger( 'afterShow' );
// Play first html5 video/audio
current.$slide.find( 'video,audio' ).first().trigger( 'play' );
// Try to focus on the first focusable element
if ( $( document.activeElement ).is( '[disabled]' ) || ( current.opts.autoFocus && !( current.type == 'image' || current.type === 'iframe' ) ) ) {
self.focus();
}
},
// Preload next and previous slides
// ================================
preload : function( type ) {
var self = this,
next = self.slides[ self.currPos + 1 ],
prev = self.slides[ self.currPos - 1 ];
if ( next && next.type === type ) {
self.loadSlide( next );
}
if ( prev && prev.type === type ) {
self.loadSlide( prev );
}
},
// Try to find and focus on the first focusable element
// ====================================================
focus : function() {
var current = this.current;
var $el;
if ( this.isClosing ) {
return;
}
if ( current && current.isComplete ) {
// Look for first input with autofocus attribute
$el = current.$slide.find('input[autofocus]:enabled:visible:first');
if ( !$el.length ) {
$el = current.$slide.find('button,:input,[tabindex],a').filter(':enabled:visible:first');
}
}
$el = $el && $el.length ? $el : this.$refs.container;
$el.focus();
},
// Activates current instance - brings container to the front and enables keyboard,
// notifies other instances about deactivating
// =================================================================================
activate : function () {
var self = this;
// Deactivate all instances
$( '.fancybox-container' ).each(function () {
var instance = $(this).data( 'FancyBox' );
// Skip self and closing instances
if (instance && instance.id !== self.id && !instance.isClosing) {
instance.trigger( 'onDeactivate' );
instance.removeEvents();
instance.isVisible = false;
}
});
self.isVisible = true;
if ( self.current || self.isIdle ) {
self.update();
self.updateControls();
}
self.trigger( 'onActivate' );
self.addEvents();
},
// Start closing procedure
// This will start "zoom-out" animation if needed and clean everything up afterwards
// =================================================================================
close : function( e, d ) {
var self = this;
var current = self.current;
var effect, duration;
var $what, opacity, start, end;
var done = function() {
self.cleanUp( e );
};
if ( self.isClosing ) {
return false;
}
self.isClosing = true;
// If beforeClose callback prevents closing, make sure content is centered
if ( self.trigger( 'beforeClose', e ) === false ) {
self.isClosing = false;
requestAFrame(function() {
self.update();
});
return false;
}
// Remove all events
// If there are multiple instances, they will be set again by "activate" method
self.removeEvents();
if ( current.timouts ) {
clearTimeout( current.timouts );
}
$what = current.$content;
effect = current.opts.animationEffect;
duration = $.isNumeric( d ) ? d : ( effect ? current.opts.animationDuration : 0 );
// Remove other slides
current.$slide.off( transitionEnd ).removeClass( 'fancybox-slide--complete fancybox-slide--next fancybox-slide--previous fancybox-animated' );
current.$slide.siblings().trigger( 'onReset' ).remove();
// Trigger animations
if ( duration ) {
self.$refs.container.removeClass( 'fancybox-is-open' ).addClass( 'fancybox-is-closing' );
}
// Clean up
self.hideLoading( current );
self.hideControls();
self.updateCursor();
// Check if possible to zoom-out
if ( effect === 'zoom' && !( e !== true && $what && duration && current.type === 'image' && !current.hasError && ( end = self.getThumbPos( current ) ) ) ) {
effect = 'fade';
}
if ( effect === 'zoom' ) {
$.fancybox.stop( $what );
start = $.fancybox.getTranslate( $what );
start.width = start.width * start.scaleX;
start.height = start.height * start.scaleY;
// Check if we need to animate opacity
opacity = current.opts.zoomOpacity;
if ( opacity == 'auto' ) {
opacity = Math.abs( current.width / current.height - end.width / end.height ) > 0.1;
}
if ( opacity ) {
end.opacity = 0;
}
start.scaleX = start.width / end.width;
start.scaleY = start.height / end.height;
start.width = end.width;
start.height = end.height;
$.fancybox.setTranslate( current.$content, start );
forceRedraw( current.$content );
$.fancybox.animate( current.$content, end, duration, done );
return true;
}
if ( effect && duration ) {
// If skip animation
if ( e === true ) {
setTimeout( done, duration );
} else {
$.fancybox.animate( current.$slide.removeClass( 'fancybox-slide--current' ), 'fancybox-animated fancybox-slide--previous fancybox-fx-' + effect, duration, done );
}
} else {
done();
}
return true;
},
// Final adjustments after removing the instance
// =============================================
cleanUp : function( e ) {
var self = this,
$body = $( 'body' ),
instance,
offset;
self.current.$slide.trigger( 'onReset' );
self.$refs.container.empty().remove();
self.trigger( 'afterClose', e );
// Place back focus
if ( self.$lastFocus && !!self.current.opts.backFocus ) {
self.$lastFocus.focus();
}
self.current = null;
// Check if there are other instances
instance = $.fancybox.getInstance();
if ( instance ) {
instance.activate();
} else {
$W.scrollTop( self.scrollTop ).scrollLeft( self.scrollLeft );
$body.removeClass( 'fancybox-active compensate-for-scrollbar' );
if ( $body.hasClass( 'fancybox-iosfix' ) ) {
offset = parseInt(document.body.style.top, 10);
$body.removeClass( 'fancybox-iosfix' ).css( 'top', '' ).scrollTop( offset * -1 );
}
$( '#fancybox-style-noscroll' ).remove();
}
},
// Call callback and trigger an event
// ==================================
trigger : function( name, slide ) {
var args = Array.prototype.slice.call(arguments, 1),
self = this,
obj = slide && slide.opts ? slide : self.current,
rez;
if ( obj ) {
args.unshift( obj );
} else {
obj = self;
}
args.unshift( self );
if ( $.isFunction( obj.opts[ name ] ) ) {
rez = obj.opts[ name ].apply( obj, args );
}
if ( rez === false ) {
return rez;
}
if ( name === 'afterClose' || !self.$refs ) {
$D.trigger( name + '.fb', args );
} else {
self.$refs.container.trigger( name + '.fb', args );
}
},
// Update infobar values, navigation button states and reveal caption
// ==================================================================
updateControls : function ( force ) {
var self = this;
var current = self.current,
index = current.index,
caption = current.opts.caption,
$container = self.$refs.container,
$caption = self.$refs.caption;
// Recalculate content dimensions
current.$slide.trigger( 'refresh' );
self.$caption = caption && caption.length ? $caption.html( caption ) : null;
if ( !self.isHiddenControls && !self.isIdle ) {
self.showControls();
}
// Update info and navigation elements
$container.find('[data-fancybox-count]').html( self.group.length );
$container.find('[data-fancybox-index]').html( index + 1 );
$container.find('[data-fancybox-prev]').prop( 'disabled', ( !current.opts.loop && index <= 0 ) );
$container.find('[data-fancybox-next]').prop( 'disabled', ( !current.opts.loop && index >= self.group.length - 1 ) );
if ( current.type === 'image' ) {
// Update download button source
$container.find('[data-fancybox-download]').attr( 'href', current.opts.image.src || current.src ).show();
} else {
$container.find('[data-fancybox-download],[data-fancybox-zoom]').hide();
}
},
// Hide toolbar and caption
// ========================
hideControls : function () {
this.isHiddenControls = true;
this.$refs.container.removeClass( 'fancybox-show-infobar fancybox-show-toolbar fancybox-show-caption fancybox-show-nav' );
},
showControls : function() {
var self = this;
var opts = self.current ? self.current.opts : self.opts;
var $container = self.$refs.container;
self.isHiddenControls = false;
self.idleSecondsCounter = 0;
$container
.toggleClass( 'fancybox-show-toolbar', !!( opts.toolbar && opts.buttons ) )
.toggleClass( 'fancybox-show-infobar', !!( opts.infobar && self.group.length > 1 ) )
.toggleClass( 'fancybox-show-nav', !!( opts.arrows && self.group.length > 1 ) )
.toggleClass( 'fancybox-is-modal', !!opts.modal );
if ( self.$caption ) {
$container.addClass( 'fancybox-show-caption ');
} else {
$container.removeClass( 'fancybox-show-caption' );
}
},
// Toggle toolbar and caption
// ==========================
toggleControls : function() {
if ( this.isHiddenControls ) {
this.showControls();
} else {
this.hideControls();
}
},
});
$.fancybox = {
version : "3.2.10",
defaults : defaults,
// Get current instance and execute a command.
//
// Examples of usage:
//
// $instance = $.fancybox.getInstance();
// $.fancybox.getInstance().jumpTo( 1 );
// $.fancybox.getInstance( 'jumpTo', 1 );
// $.fancybox.getInstance( function() {
// console.info( this.currIndex );
// });
// ======================================================
getInstance : function ( command ) {
var instance = $('.fancybox-container:not(".fancybox-is-closing"):last').data( 'FancyBox' );
var args = Array.prototype.slice.call(arguments, 1);
if ( instance instanceof FancyBox ) {
if ( $.type( command ) === 'string' ) {
instance[ command ].apply( instance, args );
} else if ( $.type( command ) === 'function' ) {
command.apply( instance, args );
}
return instance;
}
return false;
},
// Create new instance
// ===================
open : function ( items, opts, index ) {
return new FancyBox( items, opts, index );
},
// Close current or all instances
// ==============================
close : function ( all ) {
var instance = this.getInstance();
if ( instance ) {
instance.close();
// Try to find and close next instance
if ( all === true ) {
this.close();
}
}
},
// Close instances and unbind all events
// ==============================
destroy : function() {
this.close( true );
$D.off( 'click.fb-start' );
},
// Try to detect mobile devices
// ============================
isMobile : document.createTouch !== undefined && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
// Detect if 'translate3d' support is available
// ============================================
use3d : (function() {
var div = document.createElement('div');
return window.getComputedStyle && window.getComputedStyle( div ).getPropertyValue('transform') && !(document.documentMode && document.documentMode < 11);
}()),
// Helper function to get current visual state of an element
// returns array[ top, left, horizontal-scale, vertical-scale, opacity ]
// =====================================================================
getTranslate : function( $el ) {
var matrix;
if ( !$el || !$el.length ) {
return false;
}
matrix = $el.eq( 0 ).css('transform');
if ( matrix && matrix.indexOf( 'matrix' ) !== -1 ) {
matrix = matrix.split('(')[1];
matrix = matrix.split(')')[0];
matrix = matrix.split(',');
} else {
matrix = [];
}
if ( matrix.length ) {
// If IE
if ( matrix.length > 10 ) {
matrix = [ matrix[13], matrix[12], matrix[0], matrix[5] ];
} else {
matrix = [ matrix[5], matrix[4], matrix[0], matrix[3]];
}
matrix = matrix.map(parseFloat);
} else {
matrix = [ 0, 0, 1, 1 ];
var transRegex = /\.*translate\((.*)px,(.*)px\)/i;
var transRez = transRegex.exec( $el.eq( 0 ).attr('style') );
if ( transRez ) {
matrix[ 0 ] = parseFloat( transRez[2] );
matrix[ 1 ] = parseFloat( transRez[1] );
}
}
return {
top : matrix[ 0 ],
left : matrix[ 1 ],
scaleX : matrix[ 2 ],
scaleY : matrix[ 3 ],
opacity : parseFloat( $el.css('opacity') ),
width : $el.width(),
height : $el.height()
};
},
// Shortcut for setting "translate3d" properties for element
// Can set be used to set opacity, too
// ========================================================
setTranslate : function( $el, props ) {
var str = '';
var css = {};
if ( !$el || !props ) {
return;
}
if ( props.left !== undefined || props.top !== undefined ) {
str = ( props.left === undefined ? $el.position().left : props.left ) + 'px, ' + ( props.top === undefined ? $el.position().top : props.top ) + 'px';
if ( this.use3d ) {
str = 'translate3d(' + str + ', 0px)';
} else {
str = 'translate(' + str + ')';
}
}
if ( props.scaleX !== undefined && props.scaleY !== undefined ) {
str = (str.length ? str + ' ' : '') + 'scale(' + props.scaleX + ', ' + props.scaleY + ')';
}
if ( str.length ) {
css.transform = str;
}
if ( props.opacity !== undefined ) {
css.opacity = props.opacity;
}
if ( props.width !== undefined ) {
css.width = props.width;
}
if ( props.height !== undefined ) {
css.height = props.height;
}
return $el.css( css );
},
// Simple CSS transition handler
// =============================
animate : function ( $el, to, duration, callback, leaveAnimationName ) {
if ( $.isFunction( duration ) ) {
callback = duration;
duration = null;
}
if ( !$.isPlainObject( to ) ) {
$el.removeAttr( 'style' );
}
$el.on( transitionEnd, function(e) {
// Skip events from child elements and z-index change
if ( e && e.originalEvent && ( !$el.is( e.originalEvent.target ) || e.originalEvent.propertyName == 'z-index' ) ) {
return;
}
$.fancybox.stop( $el );
if ( $.isPlainObject( to ) ) {
if ( to.scaleX !== undefined && to.scaleY !== undefined ) {
$el.css( 'transition-duration', '' );
to.width = Math.round( $el.width() * to.scaleX );
to.height = Math.round( $el.height() * to.scaleY );
to.scaleX = 1;
to.scaleY = 1;
$.fancybox.setTranslate( $el, to );
}
if ( leaveAnimationName === false ) {
$el.removeAttr( 'style' );
}
} else if ( leaveAnimationName !== true ) {
$el.removeClass( to );
}
if ( $.isFunction( callback ) ) {
callback( e );
}
});
if ( $.isNumeric( duration ) ) {
$el.css( 'transition-duration', duration + 'ms' );
}
if ( $.isPlainObject( to ) ) {
$.fancybox.setTranslate( $el, to );
} else {
$el.addClass( to );
}
if ( to.scaleX && $el.hasClass( 'fancybox-image-wrap' ) ) {
$el.parent().addClass( 'fancybox-is-scaling' );
}
// Make sure that `transitionend` callback gets fired
$el.data("timer", setTimeout(function() {
$el.trigger( 'transitionend' );
}, duration + 16));
},
stop : function( $el ) {
clearTimeout( $el.data("timer") );
$el.off( 'transitionend' ).css( 'transition-duration', '' );
if ( $el.hasClass( 'fancybox-image-wrap' ) ) {
$el.parent().removeClass( 'fancybox-is-scaling' );
}
}
};
// Default click handler for "fancyboxed" links
// ============================================
function _run( e ) {
var $target = $( e.currentTarget ),
opts = e.data ? e.data.options : {},
value = $target.attr( 'data-fancybox' ) || '',
index = 0,
items = [];
// Avoid opening multiple times
if ( e.isDefaultPrevented() ) {
return;
}
e.preventDefault();
// Get all related items and find index for clicked one
if ( value ) {
items = opts.selector ? $( opts.selector ) : ( e.data ? e.data.items : [] );
items = items.length ? items.filter( '[data-fancybox="' + value + '"]' ) : $( '[data-fancybox="' + value + '"]' );
index = items.index( $target );
// Sometimes current item can not be found
// (for example, when slider clones items)
if ( index < 0 ) {
index = 0;
}
} else {
items = [ $target ];
}
$.fancybox.open( items, opts, index );
}
// Create a jQuery plugin
// ======================
$.fn.fancybox = function (options) {
var selector;
options = options || {};
selector = options.selector || false;
if ( selector ) {
$( 'body' ).off( 'click.fb-start', selector ).on( 'click.fb-start', selector, {
options : options
}, _run );
} else {
this.off( 'click.fb-start' ).on( 'click.fb-start', {
items : this,
options : options
}, _run);
}
return this;
};
// Self initializing plugin
// ========================
$D.on( 'click.fb-start', '[data-fancybox]', _run );
}( window, document, window.jQuery || jQuery ));
// ==========================================================================
//
// Media
// Adds additional media type support
//
// ==========================================================================
;(function ($) {
'use strict';
// Formats matching url to final form
var format = function (url, rez, params) {
if ( !url ) {
return;
}
params = params || '';
if ( $.type(params) === "object" ) {
params = $.param(params, true);
}
$.each(rez, function (key, value) {
url = url.replace('$' + key, value || '');
});
if (params.length) {
url += (url.indexOf('?') > 0 ? '&' : '?') + params;
}
return url;
};
// Object containing properties for each media type
var defaults = {
youtube : {
matcher : /(youtube\.com|youtu\.be|youtube\-nocookie\.com)\/(watch\?(.*&)?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*))(.*)/i,
params : {
autoplay : 1,
autohide : 1,
fs : 1,
rel : 0,
hd : 1,
wmode : 'transparent',
enablejsapi : 1,
html5 : 1
},
paramPlace : 8,
type : 'iframe',
url : '//www.youtube.com/embed/$4',
thumb : '//img.youtube.com/vi/$4/hqdefault.jpg'
},
vimeo : {
matcher : /^.+vimeo.com\/(.*\/)?([\d]+)(.*)?/,
params : {
autoplay : 1,
hd : 1,
show_title : 1,
show_byline : 1,
show_portrait : 0,
fullscreen : 1,
api : 1
},
paramPlace : 3,
type : 'iframe',
url : '//player.vimeo.com/video/$2'
},
metacafe : {
matcher : /metacafe.com\/watch\/(\d+)\/(.*)?/,
type : 'iframe',
url : '//www.metacafe.com/embed/$1/?ap=1'
},
dailymotion : {
matcher : /dailymotion.com\/video\/(.*)\/?(.*)/,
params : {
additionalInfos : 0,
autoStart : 1
},
type : 'iframe',
url : '//www.dailymotion.com/embed/video/$1'
},
vine : {
matcher : /vine.co\/v\/([a-zA-Z0-9\?\=\-]+)/,
type : 'iframe',
url : '//vine.co/v/$1/embed/simple'
},
instagram : {
matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i,
type : 'image',
url : '//$1/p/$2/media/?size=l'
},
// Examples:
// http://maps.google.com/?ll=48.857995,2.294297&spn=0.007666,0.021136&t=m&z=16
// https://www.google.com/maps/@37.7852006,-122.4146355,14.65z
// https://www.google.com/maps/place/Googleplex/@37.4220041,-122.0833494,17z/data=!4m5!3m4!1s0x0:0x6c296c66619367e0!8m2!3d37.4219998!4d-122.0840572
gmap_place : {
matcher : /(maps\.)?google\.([a-z]{2,3}(\.[a-z]{2})?)\/(((maps\/(place\/(.*)\/)?\@(.*),(\d+.?\d+?)z))|(\?ll=))(.*)?/i,
type : 'iframe',
url : function (rez) {
return '//maps.google.' + rez[2] + '/?ll=' + ( rez[9] ? rez[9] + '&z=' + Math.floor( rez[10] ) + ( rez[12] ? rez[12].replace(/^\//, "&") : '' ) : rez[12] ) + '&output=' + ( rez[12] && rez[12].indexOf('layer=c') > 0 ? 'svembed' : 'embed' );
}
},
// Examples:
// https://www.google.com/maps/search/Empire+State+Building/
// https://www.google.com/maps/search/?api=1&query=centurylink+field
// https://www.google.com/maps/search/?api=1&query=47.5951518,-122.3316393
gmap_search : {
matcher : /(maps\.)?google\.([a-z]{2,3}(\.[a-z]{2})?)\/(maps\/search\/)(.*)/i,
type : 'iframe',
url : function (rez) {
return '//maps.google.' + rez[2] + '/maps?q=' + rez[5].replace('query=', 'q=').replace('api=1', '') + '&output=embed';
}
}
};
$(document).on('objectNeedsType.fb', function (e, instance, item) {
var url = item.src || '',
type = false,
media,
thumb,
rez,
params,
urlParams,
paramObj,
provider;
media = $.extend( true, {}, defaults, item.opts.media );
// Look for any matching media type
$.each(media, function ( providerName, providerOpts ) {
rez = url.match( providerOpts.matcher );
if ( !rez ) {
return;
}
type = providerOpts.type;
paramObj = {};
if ( providerOpts.paramPlace && rez[ providerOpts.paramPlace ] ) {
urlParams = rez[ providerOpts.paramPlace ];
if ( urlParams[ 0 ] == '?' ) {
urlParams = urlParams.substring(1);
}
urlParams = urlParams.split('&');
for ( var m = 0; m < urlParams.length; ++m ) {
var p = urlParams[ m ].split('=', 2);
if ( p.length == 2 ) {
paramObj[ p[0] ] = decodeURIComponent( p[1].replace(/\+/g, " ") );
}
}
}
params = $.extend( true, {}, providerOpts.params, item.opts[ providerName ], paramObj );
url = $.type( providerOpts.url ) === "function" ? providerOpts.url.call( this, rez, params, item ) : format( providerOpts.url, rez, params );
thumb = $.type( providerOpts.thumb ) === "function" ? providerOpts.thumb.call( this, rez, params, item ) : format( providerOpts.thumb, rez );
if ( providerName === 'vimeo' ) {
url = url.replace('&%23', '#');
}
return false;
});
// If it is found, then change content type and update the url
if ( type ) {
item.src = url;
item.type = type;
if ( !item.opts.thumb && !( item.opts.$thumb && item.opts.$thumb.length ) ) {
item.opts.thumb = thumb;
}
if ( type === 'iframe' ) {
$.extend(true, item.opts, {
iframe : {
preload : false,
attr : {
scrolling : "no"
}
}
});
item.contentProvider = provider;
item.opts.slideClass += ' fancybox-slide--' + ( provider == 'gmap_place' || provider == 'gmap_search' ? 'map' : 'video' );
}
} else if ( url ) {
item.type = item.opts.defaultType;
}
});
}( window.jQuery || jQuery ));
// ==========================================================================
//
// Guestures
// Adds touch guestures, handles click and tap events
//
// ==========================================================================
;(function (window, document, $) {
'use strict';
var requestAFrame = (function () {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
// if all else fails, use setTimeout
function (callback) {
return window.setTimeout(callback, 1000 / 60);
};
})();
var cancelAFrame = (function () {
return window.cancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.oCancelAnimationFrame ||
function (id) {
window.clearTimeout(id);
};
})();
var pointers = function( e ) {
var result = [];
e = e.originalEvent || e || window.e;
e = e.touches && e.touches.length ? e.touches : ( e.changedTouches && e.changedTouches.length ? e.changedTouches : [ e ] );
for ( var key in e ) {
if ( e[ key ].pageX ) {
result.push( { x : e[ key ].pageX, y : e[ key ].pageY } );
} else if ( e[ key ].clientX ) {
result.push( { x : e[ key ].clientX, y : e[ key ].clientY } );
}
}
return result;
};
var distance = function( point2, point1, what ) {
if ( !point1 || !point2 ) {
return 0;
}
if ( what === 'x' ) {
return point2.x - point1.x;
} else if ( what === 'y' ) {
return point2.y - point1.y;
}
return Math.sqrt( Math.pow( point2.x - point1.x, 2 ) + Math.pow( point2.y - point1.y, 2 ) );
};
var isClickable = function( $el ) {
if ( $el.is('a,area,button,[role="button"],input,label,select,summary,textarea') || $.isFunction( $el.get(0).onclick ) || $el.data('selectable') ) {
return true;
}
// Check for attributes like data-fancybox-next or data-fancybox-close
for ( var i = 0, atts = $el[0].attributes, n = atts.length; i < n; i++ ) {
if ( atts[i].nodeName.substr(0, 14) === 'data-fancybox-' ) {
return true;
}
}
return false;
};
var hasScrollbars = function( el ) {
var overflowY = window.getComputedStyle( el )['overflow-y'];
var overflowX = window.getComputedStyle( el )['overflow-x'];
var vertical = (overflowY === 'scroll' || overflowY === 'auto') && el.scrollHeight > el.clientHeight;
var horizontal = (overflowX === 'scroll' || overflowX === 'auto') && el.scrollWidth > el.clientWidth;
return vertical || horizontal;
};
var isScrollable = function ( $el ) {
var rez = false;
while ( true ) {
rez = hasScrollbars( $el.get(0) );
if ( rez ) {
break;
}
$el = $el.parent();
if ( !$el.length || $el.hasClass( 'fancybox-stage' ) || $el.is( 'body' ) ) {
break;
}
}
return rez;
};
var Guestures = function ( instance ) {
var self = this;
self.instance = instance;
self.$bg = instance.$refs.bg;
self.$stage = instance.$refs.stage;
self.$container = instance.$refs.container;
self.destroy();
self.$container.on( 'touchstart.fb.touch mousedown.fb.touch', $.proxy(self, 'ontouchstart') );
};
Guestures.prototype.destroy = function() {
this.$container.off( '.fb.touch' );
};
Guestures.prototype.ontouchstart = function( e ) {
var self = this;
var $target = $( e.target );
var instance = self.instance;
var current = instance.current;
var $content = current.$content;
var isTouchDevice = ( e.type == 'touchstart' );
// Do not respond to both (touch and mouse) events
if ( isTouchDevice ) {
self.$container.off( 'mousedown.fb.touch' );
}
// Ignore right click
if ( e.originalEvent && e.originalEvent.button == 2 ) {
return;
}
// Ignore taping on links, buttons, input elements
if ( !$target.length || isClickable( $target ) || isClickable( $target.parent() ) ) {
return;
}
// Ignore clicks on the scrollbar
if ( !$target.is('img') && e.originalEvent.clientX > $target[0].clientWidth + $target.offset().left ) {
return;
}
// Ignore clicks while zooming or closing
if ( !current || self.instance.isAnimating || self.instance.isClosing ) {
e.stopPropagation();
e.preventDefault();
return;
}
self.realPoints = self.startPoints = pointers( e );
if ( !self.startPoints ) {
return;
}
e.stopPropagation();
self.startEvent = e;
self.canTap = true;
self.$target = $target;
self.$content = $content;
self.opts = current.opts.touch;
self.isPanning = false;
self.isSwiping = false;
self.isZooming = false;
self.isScrolling = false;
self.sliderStartPos = self.sliderLastPos || { top: 0, left: 0 };
self.contentStartPos = $.fancybox.getTranslate( self.$content );
self.contentLastPos = null;
self.startTime = new Date().getTime();
self.distanceX = self.distanceY = self.distance = 0;
self.canvasWidth = Math.round( current.$slide[0].clientWidth );
self.canvasHeight = Math.round( current.$slide[0].clientHeight );
$(document)
.off( '.fb.touch' )
.on( isTouchDevice ? 'touchend.fb.touch touchcancel.fb.touch' : 'mouseup.fb.touch mouseleave.fb.touch', $.proxy(self, "ontouchend"))
.on( isTouchDevice ? 'touchmove.fb.touch' : 'mousemove.fb.touch', $.proxy(self, "ontouchmove"));
if ( $.fancybox.isMobile ) {
document.addEventListener('scroll', self.onscroll, true);
}
if ( !(self.opts || instance.canPan() ) || !( $target.is( self.$stage ) || self.$stage.find( $target ).length ) ) {
// Prevent image ghosting while dragging
if ( $target.is('img') ) {
e.preventDefault();
}
return;
}
if ( !( $.fancybox.isMobile && ( isScrollable( $target ) || isScrollable( $target.parent() ) ) ) ) {
e.preventDefault();
}
if ( self.startPoints.length === 1 ) {
if ( current.type === 'image' && ( self.contentStartPos.width > self.canvasWidth + 1 || self.contentStartPos.height > self.canvasHeight + 1 ) ) {
$.fancybox.stop( self.$content );
self.$content.css( 'transition-duration', '' );
self.isPanning = true;
} else {
self.isSwiping = true;
}
self.$container.addClass( 'fancybox-controls--isGrabbing' );
}
if ( self.startPoints.length === 2 && !instance.isAnimating && !current.hasError && current.type === 'image' && ( current.isLoaded || current.$ghost ) ) {
self.canTap = false;
self.isSwiping = false;
self.isPanning = false;
self.isZooming = true;
$.fancybox.stop( self.$content );
self.$content.css( 'transition-duration', '' );
self.centerPointStartX = ( ( self.startPoints[0].x + self.startPoints[1].x ) * 0.5 ) - $(window).scrollLeft();
self.centerPointStartY = ( ( self.startPoints[0].y + self.startPoints[1].y ) * 0.5 ) - $(window).scrollTop();
self.percentageOfImageAtPinchPointX = ( self.centerPointStartX - self.contentStartPos.left ) / self.contentStartPos.width;
self.percentageOfImageAtPinchPointY = ( self.centerPointStartY - self.contentStartPos.top ) / self.contentStartPos.height;
self.startDistanceBetweenFingers = distance( self.startPoints[0], self.startPoints[1] );
}
};
Guestures.prototype.onscroll = function(e) {
self.isScrolling = true;
};
Guestures.prototype.ontouchmove = function( e ) {
var self = this,
$target = $(e.target);
if ( self.isScrolling || !( $target.is( self.$stage ) || self.$stage.find( $target ).length ) ) {
self.canTap = false;
return;
}
self.newPoints = pointers( e );
if ( !( self.opts || self.instance.canPan() ) || !self.newPoints || !self.newPoints.length ) {
return;
}
if ( !(self.isSwiping && self.isSwiping === true) ) {
e.preventDefault();
}
self.distanceX = distance( self.newPoints[0], self.startPoints[0], 'x' );
self.distanceY = distance( self.newPoints[0], self.startPoints[0], 'y' );
self.distance = distance( self.newPoints[0], self.startPoints[0] )
// Skip false ontouchmove events (Chrome)
if ( self.distance > 0 ) {
if ( self.isSwiping ) {
self.onSwipe(e);
} else if ( self.isPanning ) {
self.onPan();
} else if ( self.isZooming ) {
self.onZoom();
}
}
};
Guestures.prototype.onSwipe = function(e) {
var self = this,
swiping = self.isSwiping,
left = self.sliderStartPos.left || 0,
angle;
// If direction is not yet determined
if ( swiping === true ) {
// We need at least 10px distance to correctly calculate an angle
if ( Math.abs( self.distance ) > 10 ) {
self.canTap = false;
if ( self.instance.group.length < 2 && self.opts.vertical ) {
self.isSwiping = 'y';
} else if ( self.instance.isDragging || self.opts.vertical === false || ( self.opts.vertical === 'auto' && $( window ).width() > 800 ) ) {
self.isSwiping = 'x';
} else {
angle = Math.abs( Math.atan2( self.distanceY, self.distanceX ) * 180 / Math.PI );
self.isSwiping = ( angle > 45 && angle < 135 ) ? 'y' : 'x';
}
self.canTap = false;
if ( self.isSwiping === 'y' && $.fancybox.isMobile && ( isScrollable( self.$target ) || isScrollable( self.$target.parent() ) ) ) {
self.isScrolling = true;
return;
}
self.instance.isDragging = self.isSwiping;
// Reset points to avoid jumping, because we dropped first swipes to calculate the angle
self.startPoints = self.newPoints;
$.each(self.instance.slides, function( index, slide ) {
$.fancybox.stop( slide.$slide );
slide.$slide.css( 'transition-duration', '' );
slide.inTransition = false;
if ( slide.pos === self.instance.current.pos ) {
self.sliderStartPos.left = $.fancybox.getTranslate( slide.$slide ).left;
}
});
// Stop slideshow
if ( self.instance.SlideShow && self.instance.SlideShow.isActive ) {
self.instance.SlideShow.stop();
}
}
return;
}
// Sticky edges
if ( swiping == 'x' ) {
if ( self.distanceX > 0 && ( self.instance.group.length < 2 || ( self.instance.current.index === 0 && !self.instance.current.opts.loop ) ) ) {
left = left + Math.pow( self.distanceX, 0.8 );
} else if ( self.distanceX < 0 && ( self.instance.group.length < 2 || ( self.instance.current.index === self.instance.group.length - 1 && !self.instance.current.opts.loop ) ) ) {
left = left - Math.pow( -self.distanceX, 0.8 );
} else {
left = left + self.distanceX;
}
}
self.sliderLastPos = {
top : swiping == 'x' ? 0 : self.sliderStartPos.top + self.distanceY,
left : left
};
if ( self.requestId ) {
cancelAFrame( self.requestId );
self.requestId = null;
}
self.requestId = requestAFrame(function() {
if ( self.sliderLastPos ) {
$.each(self.instance.slides, function( index, slide ) {
var pos = slide.pos - self.instance.currPos;
$.fancybox.setTranslate( slide.$slide, {
top : self.sliderLastPos.top,
left : self.sliderLastPos.left + ( pos * self.canvasWidth ) + ( pos * slide.opts.gutter )
});
});
self.$container.addClass( 'fancybox-is-sliding' );
}
});
};
Guestures.prototype.onPan = function() {
var self = this;
// Sometimes, when tapping causally, image can move a bit and that breaks double tapping
if ( distance( self.newPoints[0], self.realPoints[0] ) < ($.fancybox.isMobile ? 10 : 5) ) {
self.startPoints = self.newPoints;
return;
}
self.canTap = false;
self.contentLastPos = self.limitMovement();
if ( self.requestId ) {
cancelAFrame( self.requestId );
self.requestId = null;
}
self.requestId = requestAFrame(function() {
$.fancybox.setTranslate( self.$content, self.contentLastPos );
});
};
// Make panning sticky to the edges
Guestures.prototype.limitMovement = function() {
var self = this;
var canvasWidth = self.canvasWidth;
var canvasHeight = self.canvasHeight;
var distanceX = self.distanceX;
var distanceY = self.distanceY;
var contentStartPos = self.contentStartPos;
var currentOffsetX = contentStartPos.left;
var currentOffsetY = contentStartPos.top;
var currentWidth = contentStartPos.width;
var currentHeight = contentStartPos.height;
var minTranslateX, minTranslateY,
maxTranslateX, maxTranslateY,
newOffsetX, newOffsetY;
if ( currentWidth > canvasWidth ) {
newOffsetX = currentOffsetX + distanceX;
} else {
newOffsetX = currentOffsetX;
}
newOffsetY = currentOffsetY + distanceY;
// Slow down proportionally to traveled distance
minTranslateX = Math.max( 0, canvasWidth * 0.5 - currentWidth * 0.5 );
minTranslateY = Math.max( 0, canvasHeight * 0.5 - currentHeight * 0.5 );
maxTranslateX = Math.min( canvasWidth - currentWidth, canvasWidth * 0.5 - currentWidth * 0.5 );
maxTranslateY = Math.min( canvasHeight - currentHeight, canvasHeight * 0.5 - currentHeight * 0.5 );
if ( currentWidth > canvasWidth ) {
// ->
if ( distanceX > 0 && newOffsetX > minTranslateX ) {
newOffsetX = minTranslateX - 1 + Math.pow( -minTranslateX + currentOffsetX + distanceX, 0.8 ) || 0;
}
// <-
if ( distanceX < 0 && newOffsetX < maxTranslateX ) {
newOffsetX = maxTranslateX + 1 - Math.pow( maxTranslateX - currentOffsetX - distanceX, 0.8 ) || 0;
}
}
if ( currentHeight > canvasHeight ) {
// \/
if ( distanceY > 0 && newOffsetY > minTranslateY ) {
newOffsetY = minTranslateY - 1 + Math.pow(-minTranslateY + currentOffsetY + distanceY, 0.8 ) || 0;
}
// /\
if ( distanceY < 0 && newOffsetY < maxTranslateY ) {
newOffsetY = maxTranslateY + 1 - Math.pow ( maxTranslateY - currentOffsetY - distanceY, 0.8 ) || 0;
}
}
return {
top : newOffsetY,
left : newOffsetX,
scaleX : contentStartPos.scaleX,
scaleY : contentStartPos.scaleY
};
};
Guestures.prototype.limitPosition = function( newOffsetX, newOffsetY, newWidth, newHeight ) {
var self = this;
var canvasWidth = self.canvasWidth;
var canvasHeight = self.canvasHeight;
if ( newWidth > canvasWidth ) {
newOffsetX = newOffsetX > 0 ? 0 : newOffsetX;
newOffsetX = newOffsetX < canvasWidth - newWidth ? canvasWidth - newWidth : newOffsetX;
} else {
// Center horizontally
newOffsetX = Math.max( 0, canvasWidth / 2 - newWidth / 2 );
}
if ( newHeight > canvasHeight ) {
newOffsetY = newOffsetY > 0 ? 0 : newOffsetY;
newOffsetY = newOffsetY < canvasHeight - newHeight ? canvasHeight - newHeight : newOffsetY;
} else {
// Center vertically
newOffsetY = Math.max( 0, canvasHeight / 2 - newHeight / 2 );
}
return {
top : newOffsetY,
left : newOffsetX
};
};
Guestures.prototype.onZoom = function() {
var self = this;
// Calculate current distance between points to get pinch ratio and new width and height
var currentWidth = self.contentStartPos.width;
var currentHeight = self.contentStartPos.height;
var currentOffsetX = self.contentStartPos.left;
var currentOffsetY = self.contentStartPos.top;
var endDistanceBetweenFingers = distance( self.newPoints[0], self.newPoints[1] );
var pinchRatio = endDistanceBetweenFingers / self.startDistanceBetweenFingers;
var newWidth = Math.floor( currentWidth * pinchRatio );
var newHeight = Math.floor( currentHeight * pinchRatio );
// This is the translation due to pinch-zooming
var translateFromZoomingX = (currentWidth - newWidth) * self.percentageOfImageAtPinchPointX;
var translateFromZoomingY = (currentHeight - newHeight) * self.percentageOfImageAtPinchPointY;
//Point between the two touches
var centerPointEndX = ((self.newPoints[0].x + self.newPoints[1].x) / 2) - $(window).scrollLeft();
var centerPointEndY = ((self.newPoints[0].y + self.newPoints[1].y) / 2) - $(window).scrollTop();
// And this is the translation due to translation of the centerpoint
// between the two fingers
var translateFromTranslatingX = centerPointEndX - self.centerPointStartX;
var translateFromTranslatingY = centerPointEndY - self.centerPointStartY;
// The new offset is the old/current one plus the total translation
var newOffsetX = currentOffsetX + ( translateFromZoomingX + translateFromTranslatingX );
var newOffsetY = currentOffsetY + ( translateFromZoomingY + translateFromTranslatingY );
var newPos = {
top : newOffsetY,
left : newOffsetX,
scaleX : self.contentStartPos.scaleX * pinchRatio,
scaleY : self.contentStartPos.scaleY * pinchRatio
};
self.canTap = false;
self.newWidth = newWidth;
self.newHeight = newHeight;
self.contentLastPos = newPos;
if ( self.requestId ) {
cancelAFrame( self.requestId );
self.requestId = null;
}
self.requestId = requestAFrame(function() {
$.fancybox.setTranslate( self.$content, self.contentLastPos );
});
};
Guestures.prototype.ontouchend = function( e ) {
var self = this;
var dMs = Math.max( (new Date().getTime() ) - self.startTime, 1);
var swiping = self.isSwiping;
var panning = self.isPanning;
var zooming = self.isZooming;
var scrolling = self.isScrolling;
self.endPoints = pointers( e );
self.$container.removeClass( 'fancybox-controls--isGrabbing' );
$(document).off( '.fb.touch' );
document.removeEventListener('scroll', self.onscroll, true);
if ( self.requestId ) {
cancelAFrame( self.requestId );
self.requestId = null;
}
self.isSwiping = false;
self.isPanning = false;
self.isZooming = false;
self.isScrolling = false;
self.instance.isDragging = false;
if ( self.canTap ) {
return self.onTap( e );
}
self.speed = 366;
// Speed in px/ms
self.velocityX = self.distanceX / dMs * 0.5;
self.velocityY = self.distanceY / dMs * 0.5;
self.speedX = Math.max( self.speed * 0.5, Math.min( self.speed * 1.5, ( 1 / Math.abs( self.velocityX ) ) * self.speed ) );
if ( panning ) {
self.endPanning();
} else if ( zooming ) {
self.endZooming();
} else {
self.endSwiping( swiping, scrolling );
}
return;
};
Guestures.prototype.endSwiping = function( swiping, scrolling ) {
var self = this,
ret = false,
len = self.instance.group.length;
self.sliderLastPos = null;
// Close if swiped vertically / navigate if horizontally
if ( swiping == 'y' && !scrolling && Math.abs( self.distanceY ) > 50 ) {
// Continue vertical movement
$.fancybox.animate( self.instance.current.$slide, {
top : self.sliderStartPos.top + self.distanceY + ( self.velocityY * 150 ),
opacity : 0
}, 150 );
ret = self.instance.close( true, 300 );
} else if ( swiping == 'x' && self.distanceX > 50 && len > 1 ) {
ret = self.instance.previous( self.speedX );
} else if ( swiping == 'x' && self.distanceX < -50 && len > 1 ) {
ret = self.instance.next( self.speedX );
}
if ( ret === false && ( swiping == 'x' || swiping == 'y' ) ) {
if ( scrolling || len < 2 ) {
self.instance.centerSlide( self.instance.current, 150 );
} else {
self.instance.jumpTo( self.instance.current.index );
}
}
self.$container.removeClass( 'fancybox-is-sliding' );
};
// Limit panning from edges
// ========================
Guestures.prototype.endPanning = function() {
var self = this;
var newOffsetX, newOffsetY, newPos;
if ( !self.contentLastPos ) {
return;
}
if ( self.opts.momentum === false ) {
newOffsetX = self.contentLastPos.left;
newOffsetY = self.contentLastPos.top;
} else {
// Continue movement
newOffsetX = self.contentLastPos.left + ( self.velocityX * self.speed );
newOffsetY = self.contentLastPos.top + ( self.velocityY * self.speed );
}
newPos = self.limitPosition( newOffsetX, newOffsetY, self.contentStartPos.width, self.contentStartPos.height );
newPos.width = self.contentStartPos.width;
newPos.height = self.contentStartPos.height;
$.fancybox.animate( self.$content, newPos, 330 );
};
Guestures.prototype.endZooming = function() {
var self = this;
var current = self.instance.current;
var newOffsetX, newOffsetY, newPos, reset;
var newWidth = self.newWidth;
var newHeight = self.newHeight;
if ( !self.contentLastPos ) {
return;
}
newOffsetX = self.contentLastPos.left;
newOffsetY = self.contentLastPos.top;
reset = {
top : newOffsetY,
left : newOffsetX,
width : newWidth,
height : newHeight,
scaleX : 1,
scaleY : 1
};
// Reset scalex/scaleY values; this helps for perfomance and does not break animation
$.fancybox.setTranslate( self.$content, reset );
if ( newWidth < self.canvasWidth && newHeight < self.canvasHeight ) {
self.instance.scaleToFit( 150 );
} else if ( newWidth > current.width || newHeight > current.height ) {
self.instance.scaleToActual( self.centerPointStartX, self.centerPointStartY, 150 );
} else {
newPos = self.limitPosition( newOffsetX, newOffsetY, newWidth, newHeight );
// Switch from scale() to width/height or animation will not work correctly
$.fancybox.setTranslate( self.content, $.fancybox.getTranslate( self.$content ) );
$.fancybox.animate( self.$content, newPos, 150 );
}
};
Guestures.prototype.onTap = function(e) {
var self = this;
var $target = $( e.target );
var instance = self.instance;
var current = instance.current;
var endPoints = ( e && pointers( e ) ) || self.startPoints;
var tapX = endPoints[0] ? endPoints[0].x - self.$stage.offset().left : 0;
var tapY = endPoints[0] ? endPoints[0].y - self.$stage.offset().top : 0;
var where;
var process = function ( prefix ) {
var action = current.opts[ prefix ];
if ( $.isFunction( action ) ) {
action = action.apply( instance, [ current, e ] );
}
if ( !action) {
return;
}
switch ( action ) {
case "close" :
instance.close( self.startEvent );
break;
case "toggleControls" :
instance.toggleControls( true );
break;
case "next" :
instance.next();
break;
case "nextOrClose" :
if ( instance.group.length > 1 ) {
instance.next();
} else {
instance.close( self.startEvent );
}
break;
case "zoom" :
if ( current.type == 'image' && ( current.isLoaded || current.$ghost ) ) {
if ( instance.canPan() ) {
instance.scaleToFit();
} else if ( instance.isScaledDown() ) {
instance.scaleToActual( tapX, tapY );
} else if ( instance.group.length < 2 ) {
instance.close( self.startEvent );
}
}
break;
}
};
// Ignore right click
if ( e.originalEvent && e.originalEvent.button == 2 ) {
return;
}
// Skip if clicked on the scrollbar
if ( !$target.is('img') && tapX > $target[0].clientWidth + $target.offset().left ) {
return;
}
// Check where is clicked
if ( $target.is( '.fancybox-bg,.fancybox-inner,.fancybox-outer,.fancybox-container' ) ) {
where = 'Outside';
} else if ( $target.is( '.fancybox-slide' ) ) {
where = 'Slide';
} else if ( instance.current.$content && instance.current.$content.find( $target ).addBack().filter( $target ).length ) {
where = 'Content';
} else {
return;
}
// Check if this is a double tap
if ( self.tapped ) {
// Stop previously created single tap
clearTimeout( self.tapped );
self.tapped = null;
// Skip if distance between taps is too big
if ( Math.abs( tapX - self.tapX ) > 50 || Math.abs( tapY - self.tapY ) > 50 ) {
return this;
}
// OK, now we assume that this is a double-tap
process( 'dblclick' + where );
} else {
// Single tap will be processed if user has not clicked second time within 300ms
// or there is no need to wait for double-tap
self.tapX = tapX;
self.tapY = tapY;
if ( current.opts[ 'dblclick' + where ] && current.opts[ 'dblclick' + where ] !== current.opts[ 'click' + where ] ) {
self.tapped = setTimeout(function() {
self.tapped = null;
process( 'click' + where );
}, 500);
} else {
process( 'click' + where );
}
}
return this;
};
$(document).on('onActivate.fb', function (e, instance) {
if ( instance && !instance.Guestures ) {
instance.Guestures = new Guestures( instance );
}
});
}( window, document, window.jQuery || jQuery ));
// ==========================================================================
//
// SlideShow
// Enables slideshow functionality
//
// Example of usage:
// $.fancybox.getInstance().SlideShow.start()
//
// ==========================================================================
;(function (document, $) {
'use strict';
$.extend(true, $.fancybox.defaults, {
btnTpl : {
slideShow :
''
},
slideShow : {
autoStart : false,
speed : 3000
}
});
var SlideShow = function( instance ) {
this.instance = instance;
this.init();
};
$.extend( SlideShow.prototype, {
timer : null,
isActive : false,
$button : null,
init : function() {
var self = this;
self.$button = self.instance.$refs.toolbar.find('[data-fancybox-play]').on('click', function() {
self.toggle();
});
if ( self.instance.group.length < 2 || !self.instance.group[ self.instance.currIndex ].opts.slideShow ) {
self.$button.hide();
}
},
set : function( force ) {
var self = this;
// Check if reached last element
if ( self.instance && self.instance.current && (force === true || self.instance.current.opts.loop || self.instance.currIndex < self.instance.group.length - 1 )) {
self.timer = setTimeout(function() {
if ( self.isActive ) {
self.instance.jumpTo( (self.instance.currIndex + 1) % self.instance.group.length );
}
}, self.instance.current.opts.slideShow.speed);
} else {
self.stop();
self.instance.idleSecondsCounter = 0;
self.instance.showControls();
}
},
clear : function() {
var self = this;
clearTimeout( self.timer );
self.timer = null;
},
start : function() {
var self = this;
var current = self.instance.current;
if ( current ) {
self.isActive = true;
self.$button
.attr( 'title', current.opts.i18n[ current.opts.lang ].PLAY_STOP )
.removeClass( 'fancybox-button--play' )
.addClass( 'fancybox-button--pause' );
self.set( true );
}
},
stop : function() {
var self = this;
var current = self.instance.current;
self.clear();
self.$button
.attr( 'title', current.opts.i18n[ current.opts.lang ].PLAY_START )
.removeClass( 'fancybox-button--pause' )
.addClass( 'fancybox-button--play' );
self.isActive = false;
},
toggle : function() {
var self = this;
if ( self.isActive ) {
self.stop();
} else {
self.start();
}
}
});
$(document).on({
'onInit.fb' : function(e, instance) {
if ( instance && !instance.SlideShow ) {
instance.SlideShow = new SlideShow( instance );
}
},
'beforeShow.fb' : function(e, instance, current, firstRun) {
var SlideShow = instance && instance.SlideShow;
if ( firstRun ) {
if ( SlideShow && current.opts.slideShow.autoStart ) {
SlideShow.start();
}
} else if ( SlideShow && SlideShow.isActive ) {
SlideShow.clear();
}
},
'afterShow.fb' : function(e, instance, current) {
var SlideShow = instance && instance.SlideShow;
if ( SlideShow && SlideShow.isActive ) {
SlideShow.set();
}
},
'afterKeydown.fb' : function(e, instance, current, keypress, keycode) {
var SlideShow = instance && instance.SlideShow;
// "P" or Spacebar
if ( SlideShow && current.opts.slideShow && ( keycode === 80 || keycode === 32 ) && !$(document.activeElement).is( 'button,a,input' ) ) {
keypress.preventDefault();
SlideShow.toggle();
}
},
'beforeClose.fb onDeactivate.fb' : function(e, instance) {
var SlideShow = instance && instance.SlideShow;
if ( SlideShow ) {
SlideShow.stop();
}
}
});
// Page Visibility API to pause slideshow when window is not active
$(document).on("visibilitychange", function() {
var instance = $.fancybox.getInstance();
var SlideShow = instance && instance.SlideShow;
if ( SlideShow && SlideShow.isActive ) {
if ( document.hidden ) {
SlideShow.clear();
} else {
SlideShow.set();
}
}
});
}( document, window.jQuery || jQuery ));
// ==========================================================================
//
// FullScreen
// Adds fullscreen functionality
//
// ==========================================================================
;(function (document, $) {
'use strict';
// Collection of methods supported by user browser
var fn = (function () {
var fnMap = [
[
'requestFullscreen',
'exitFullscreen',
'fullscreenElement',
'fullscreenEnabled',
'fullscreenchange',
'fullscreenerror'
],
// new WebKit
[
'webkitRequestFullscreen',
'webkitExitFullscreen',
'webkitFullscreenElement',
'webkitFullscreenEnabled',
'webkitfullscreenchange',
'webkitfullscreenerror'
],
// old WebKit (Safari 5.1)
[
'webkitRequestFullScreen',
'webkitCancelFullScreen',
'webkitCurrentFullScreenElement',
'webkitCancelFullScreen',
'webkitfullscreenchange',
'webkitfullscreenerror'
],
[
'mozRequestFullScreen',
'mozCancelFullScreen',
'mozFullScreenElement',
'mozFullScreenEnabled',
'mozfullscreenchange',
'mozfullscreenerror'
],
[
'msRequestFullscreen',
'msExitFullscreen',
'msFullscreenElement',
'msFullscreenEnabled',
'MSFullscreenChange',
'MSFullscreenError'
]
];
var val;
var ret = {};
var i, j;
for ( i = 0; i < fnMap.length; i++ ) {
val = fnMap[ i ];
if ( val && val[ 1 ] in document ) {
for ( j = 0; j < val.length; j++ ) {
ret[ fnMap[ 0 ][ j ] ] = val[ j ];
}
return ret;
}
}
return false;
})();
// If browser does not have Full Screen API, then simply unset default button template and stop
if ( !fn ) {
if ( $ && $.fancybox ) {
$.fancybox.defaults.btnTpl.fullScreen = false;
}
return;
}
var FullScreen = {
request : function ( elem ) {
elem = elem || document.documentElement;
elem[ fn.requestFullscreen ]( elem.ALLOW_KEYBOARD_INPUT );
},
exit : function () {
document[ fn.exitFullscreen ]();
},
toggle : function ( elem ) {
elem = elem || document.documentElement;
if ( this.isFullscreen() ) {
this.exit();
} else {
this.request( elem );
}
},
isFullscreen : function() {
return Boolean( document[ fn.fullscreenElement ] );
},
enabled : function() {
return Boolean( document[ fn.fullscreenEnabled ] );
}
};
$.extend(true, $.fancybox.defaults, {
btnTpl : {
fullScreen :
''
},
fullScreen : {
autoStart : false
}
});
$(document).on({
'onInit.fb' : function(e, instance) {
var $container;
if ( instance && instance.group[ instance.currIndex ].opts.fullScreen ) {
$container = instance.$refs.container;
$container.on('click.fb-fullscreen', '[data-fancybox-fullscreen]', function(e) {
e.stopPropagation();
e.preventDefault();
FullScreen.toggle( $container[ 0 ] );
});
if ( instance.opts.fullScreen && instance.opts.fullScreen.autoStart === true ) {
FullScreen.request( $container[ 0 ] );
}
// Expose API
instance.FullScreen = FullScreen;
} else if ( instance ) {
instance.$refs.toolbar.find('[data-fancybox-fullscreen]').hide();
}
},
'afterKeydown.fb' : function(e, instance, current, keypress, keycode) {
// "P" or Spacebar
if ( instance && instance.FullScreen && keycode === 70 ) {
keypress.preventDefault();
instance.FullScreen.toggle( instance.$refs.container[ 0 ] );
}
},
'beforeClose.fb' : function( instance ) {
if ( instance && instance.FullScreen ) {
FullScreen.exit();
}
}
});
$(document).on(fn.fullscreenchange, function() {
var isFullscreen = FullScreen.isFullscreen(),
instance = $.fancybox.getInstance();
if ( instance ) {
// If image is zooming, then force to stop and reposition properly
if ( instance.current && instance.current.type === 'image' && instance.isAnimating ) {
instance.current.$content.css( 'transition', 'none' );
instance.isAnimating = false;
instance.update( true, true, 0 );
}
instance.trigger( 'onFullscreenChange', isFullscreen );
instance.$refs.container.toggleClass( 'fancybox-is-fullscreen', isFullscreen );
}
});
}( document, window.jQuery || jQuery ));
// ==========================================================================
//
// Thumbs
// Displays thumbnails in a grid
//
// ==========================================================================
;(function (document, $) {
'use strict';
// Make sure there are default values
$.fancybox.defaults = $.extend(true, {
btnTpl : {
thumbs :
''
},
thumbs : {
autoStart : false, // Display thumbnails on opening
hideOnClose : true, // Hide thumbnail grid when closing animation starts
parentEl : '.fancybox-container', // Container is injected into this element
axis : 'y' // Vertical (y) or horizontal (x) scrolling
}
}, $.fancybox.defaults);
var FancyThumbs = function( instance ) {
this.init( instance );
};
$.extend( FancyThumbs.prototype, {
$button : null,
$grid : null,
$list : null,
isVisible : false,
isActive : false,
init : function( instance ) {
var self = this;
self.instance = instance;
instance.Thumbs = self;
// Enable thumbs if at least two group items have thumbnails
var first = instance.group[0],
second = instance.group[1];
self.opts = instance.group[ instance.currIndex ].opts.thumbs;
self.$button = instance.$refs.toolbar.find( '[data-fancybox-thumbs]' );
if ( self.opts && first && second && (
( first.type == 'image' || first.opts.thumb || first.opts.$thumb ) &&
( second.type == 'image' || second.opts.thumb || second.opts.$thumb )
)) {
self.$button.show().on('click', function() {
self.toggle();
});
self.isActive = true;
} else {
self.$button.hide();
}
},
create : function() {
var self = this,
instance = self.instance,
parentEl = self.opts.parentEl,
list,
src;
self.$grid = $('').appendTo( instance.$refs.container.find( parentEl ).addBack().filter( parentEl ) );
// Build list HTML
list = '
'
}
});
function escapeHtml(string) {
var entityMap = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": ''',
'/': '/',
'`': '`',
'=': '='
};
return String(string).replace(/[&<>"'`=\/]/g, function (s) {
return entityMap[s];
});
}
$(document).on('click', '[data-fancybox-share]', function() {
var f = $.fancybox.getInstance(),
url,
tpl;
if ( f ) {
url = f.current.opts.hash === false ? f.current.src : window.location;
tpl = f.current.opts.share.tpl
.replace( /\{\{media\}\}/g, f.current.type === 'image' ? encodeURIComponent( f.current.src ) : '' )
.replace( /\{\{url\}\}/g, encodeURIComponent( url ) )
.replace( /\{\{url_raw\}\}/g, escapeHtml( url ) )
.replace( /\{\{descr\}\}/g, f.$caption ? encodeURIComponent( f.$caption.text() ) : '' );
$.fancybox.open({
src : f.translate( f, tpl ),
type : 'html',
opts : {
animationEffect : "fade",
animationDuration : 250,
afterLoad : function(instance, current) {
// Opening links in a popup window
current.$content.find('.fancybox-share__links a').click(function() {
window.open(this.href, "Share", "width=550, height=450");
return false;
});
}
}
});
}
});
}( document, window.jQuery || jQuery ));
// ==========================================================================
//
// Hash
// Enables linking to each modal
//
// ==========================================================================
;(function (document, window, $) {
'use strict';
// Simple $.escapeSelector polyfill (for jQuery prior v3)
if ( !$.escapeSelector ) {
$.escapeSelector = function( sel ) {
var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
var fcssescape = function( ch, asCodePoint ) {
if ( asCodePoint ) {
// U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
if ( ch === "\0" ) {
return "\uFFFD";
}
// Control characters and (dependent upon position) numbers get escaped as code points
return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
}
// Other potentially-special ASCII characters get backslash-escaped
return "\\" + ch;
};
return ( sel + "" ).replace( rcssescape, fcssescape );
};
}
// Create new history entry only once
var shouldCreateHistory = true;
// Variable containing last hash value set by fancyBox
// It will be used to determine if fancyBox needs to close after hash change is detected
var currentHash = null;
// Throttling the history change
var timerID = null;
// Get info about gallery name and current index from url
function parseUrl() {
var hash = window.location.hash.substr( 1 );
var rez = hash.split( '-' );
var index = rez.length > 1 && /^\+?\d+$/.test( rez[ rez.length - 1 ] ) ? parseInt( rez.pop( -1 ), 10 ) || 1 : 1;
var gallery = rez.join( '-' );
// Index is starting from 1
if ( index < 1 ) {
index = 1;
}
return {
hash : hash,
index : index,
gallery : gallery
};
}
// Trigger click evnt on links to open new fancyBox instance
function triggerFromUrl( url ) {
var $el;
if ( url.gallery !== '' ) {
// If we can find element matching 'data-fancybox' atribute, then trigger click event for that ..
$el = $( "[data-fancybox='" + $.escapeSelector( url.gallery ) + "']" ).eq( url.index - 1 );
if ( !$el.length ) {
// .. if not, try finding element by ID
$el = $( "#" + $.escapeSelector( url.gallery ) + "" );
}
if ( $el.length ) {
shouldCreateHistory = false;
$el.trigger( 'click' );
}
}
}
// Get gallery name from current instance
function getGalleryID( instance ) {
var opts;
if ( !instance ) {
return false;
}
opts = instance.current ? instance.current.opts : instance.opts;
return opts.hash || ( opts.$orig ? opts.$orig.data( 'fancybox' ) : '' );
}
// Start when DOM becomes ready
$(function() {
// Check if user has disabled this module
if ( $.fancybox.defaults.hash === false ) {
return;
}
// Update hash when opening/closing fancyBox
$(document).on({
'onInit.fb' : function( e, instance ) {
var url, gallery;
if ( instance.group[ instance.currIndex ].opts.hash === false ) {
return;
}
url = parseUrl();
gallery = getGalleryID( instance );
// Make sure gallery start index matches index from hash
if ( gallery && url.gallery && gallery == url.gallery ) {
instance.currIndex = url.index - 1;
}
},
'beforeShow.fb' : function( e, instance, current ) {
var gallery;
if ( !current || current.opts.hash === false ) {
return;
}
gallery = getGalleryID( instance );
// Update window hash
if ( gallery && gallery !== '' ) {
if ( window.location.hash.indexOf( gallery ) < 0 ) {
instance.opts.origHash = window.location.hash;
}
currentHash = gallery + ( instance.group.length > 1 ? '-' + ( current.index + 1 ) : '' );
if ( 'replaceState' in window.history ) {
if ( timerID ) {
clearTimeout( timerID );
}
timerID = setTimeout(function() {
window.history[ shouldCreateHistory ? 'pushState' : 'replaceState' ]( {} , document.title, window.location.pathname + window.location.search + '#' + currentHash );
timerID = null;
shouldCreateHistory = false;
}, 300);
} else {
window.location.hash = currentHash;
}
}
},
'beforeClose.fb' : function( e, instance, current ) {
var gallery, origHash;
if ( timerID ) {
clearTimeout( timerID );
}
if ( current.opts.hash === false ) {
return;
}
gallery = getGalleryID( instance );
origHash = instance && instance.opts.origHash ? instance.opts.origHash : '';
// Remove hash from location bar
if ( gallery && gallery !== '' ) {
if ( 'replaceState' in history ) {
window.history.replaceState( {} , document.title, window.location.pathname + window.location.search + origHash );
} else {
window.location.hash = origHash;
// Keep original scroll position
$( window ).scrollTop( instance.scrollTop ).scrollLeft( instance.scrollLeft );
}
}
currentHash = null;
}
});
// Check if need to close after url has changed
$(window).on('hashchange.fb', function() {
var url = parseUrl();
if ( $.fancybox.getInstance() ) {
if ( currentHash && currentHash !== url.gallery + '-' + url.index && !( url.index === 1 && currentHash == url.gallery ) ) {
currentHash = null;
$.fancybox.close();
}
} else if ( url.gallery !== '' ) {
triggerFromUrl( url );
}
});
// Check current hash and trigger click event on matching element to start fancyBox, if needed
setTimeout(function() {
triggerFromUrl( parseUrl() );
}, 50);
});
}( document, window, window.jQuery || jQuery ));
;(function (document, $) {
'use strict';
var prevTime = new Date().getTime();
$(document).on({
'onInit.fb' : function( e, instance, current ) {
instance.$refs.stage.on('mousewheel DOMMouseScroll wheel MozMousePixelScroll', function(e) {
var current = instance.current,
currTime = new Date().getTime();
if ( instance.group.length < 1 || current.opts.wheel === false || ( current.opts.wheel === 'auto' && current.type !== 'image' ) ) {
return;
}
e.preventDefault();
e.stopPropagation();
if ( current.$slide.hasClass( 'fancybox-animated' ) ) {
return;
}
e = e.originalEvent || e;
if ( currTime - prevTime < 250 ) {
return;
}
prevTime = currTime;
instance[ ( -e.deltaY || -e.deltaX || e.wheelDelta || -e.detail ) < 0 ? 'next' : 'previous' ]();
});
}
});
}( document, window.jQuery || jQuery ));
PK J R]aÔª9‰ ‰ lean-slider.jsnu W+A„¶ /*
* Lean Slider v1.0
* http://dev7studios.com/lean-slider
*
* Copyright 2012, Dev7studios
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
;(function($) {
$.fn.leanSlider = function(options) {
// Defaults
var defaults = {
pauseTime: 4000,
pauseOnHover: true,
startSlide: 0,
directionNav: '',
directionNavPrevBuilder: '',
directionNavNextBuilder: '',
controlNav: '',
controlNavBuilder: '',
prevText: 'Prev',
nextText: 'Next',
beforeChange: function(){},
afterChange: function(){},
afterLoad: function(){}
};
// Set up plugin vars
var plugin = this,
settings = {},
slider = $(this),
slides = slider.children(),
currentSlide = 0,
timer = 0;
var init = function() {
// Set up settings
settings = $.extend({}, defaults, options);
// Add inital classes
slider.addClass('lean-slider');
slides.addClass('lean-slider-slide');
currentSlide = settings.startSlide;
if(settings.startSlide < 0 || settings.startSlide >= slides.length) currentSlide = 0;
$(slides[currentSlide]).addClass('current');
// Set up directionNav
if(settings.directionNav && $(settings.directionNav).length){
var prevNav = $(''+ settings.prevText +''),
nextNav = $(''+ settings.nextText +'');
if(settings.directionNavPrevBuilder) prevNav = $(settings.directionNavPrevBuilder.call(this, settings.prevText));
if(settings.directionNavNextBuilder) nextNav = $(settings.directionNavNextBuilder.call(this, settings.nextText));
prevNav.on('click', function(e){
e.preventDefault();
plugin.prev();
});
nextNav.on('click', function(e){
e.preventDefault();
plugin.next();
});
$(settings.directionNav).append(prevNav);
$(settings.directionNav).append(nextNav);
}
// Set up controlNav
if(settings.controlNav && $(settings.controlNav).length){
slides.each(function(i){
var controlNav = $(''+ (i + 1) +'');
if(settings.controlNavBuilder) controlNav = $(settings.controlNavBuilder.call(this, i, $(slides[i])));
controlNav.on('click', function(e){
e.preventDefault();
plugin.show(i);
});
$(settings.controlNav).append(controlNav);
});
}
// Set up pauseOnHover
if(settings.pauseOnHover && settings.pauseTime && settings.pauseTime > 0){
slider.hover(
function () {
clearTimeout(timer);
},
function () {
doTimer();
}
);
}
// Initial processing
updateControlNav();
doTimer();
// Trigger the afterLoad callback
settings.afterLoad.call(this);
return plugin;
};
// Process timer
var doTimer = function(){
if(settings.pauseTime && settings.pauseTime > 0){
clearTimeout(timer);
timer = setTimeout(function(){ plugin.next(); }, settings.pauseTime);
}
};
// Update controlNav
var updateControlNav = function(){
if(settings.controlNav){
$('.lean-slider-control-nav', settings.controlNav).removeClass('active');
$($('.lean-slider-control-nav', settings.controlNav).get(currentSlide)).addClass('active');
}
};
// Prev
plugin.prev = function(){
// Trigger the beforeChange callback
settings.beforeChange.call(this, currentSlide);
currentSlide--;
if(currentSlide < 0) currentSlide = slides.length - 1;
slides.removeClass('current');
$(slides[currentSlide]).addClass('current');
updateControlNav();
doTimer();
// Trigger the afterChange callback
settings.afterChange.call(this, currentSlide);
};
// Next
plugin.next = function(){
// Trigger the beforeChange callback
settings.beforeChange.call(this, currentSlide);
currentSlide++;
if(currentSlide >= slides.length) currentSlide = 0;
slides.removeClass('current');
$(slides[currentSlide]).addClass('current');
updateControlNav();
doTimer();
// Trigger the afterChange callback
settings.afterChange.call(this, currentSlide);
};
// Show
plugin.show = function(index){
// Trigger the beforeChange callback
settings.beforeChange.call(this, currentSlide);
currentSlide = index;
if(currentSlide < 0) currentSlide = slides.length - 1;
if(currentSlide >= slides.length) currentSlide = 0;
slides.removeClass('current');
$(slides[currentSlide]).addClass('current');
updateControlNav();
doTimer();
// Trigger the afterChange callback
settings.afterChange.call(this, currentSlide);
};
// Call constructor
return init();
};
})(jQuery);PK J R]´¯l=Ì$ Ì$ menu_dropdown.min.jsnu W+A„¶ /*! AdminLTE app.js
* ================
* Main JS application file for AdminLTE v2. This file
* should be included in all pages. It controls some layout
* options and implements exclusive AdminLTE plugins.
*
* @Author Almsaeed Studio
* @Support
* @Email
* @version 2.3.0
* @license MIT
*/
function _init(){"use strict";$.AdminLTE.layout={activate:function(){var a=this;a.fix(),a.fixSidebar(),$(window,".wrapper").resize(function(){a.fix(),a.fixSidebar()})},fix:function(){var a=$(".main-header").outerHeight()+$(".main-footer").outerHeight(),b=$(window).height(),c=$(".sidebar").height();if($("body").hasClass("fixed"))$(".content-wrapper, .right-side").css("min-height",b-$(".main-footer").outerHeight());else{var d;b>=c?($(".content-wrapper, .right-side").css("min-height",b-a),d=b-a):($(".content-wrapper, .right-side").css("min-height",c),d=c);var e=$($.AdminLTE.options.controlSidebarOptions.selector);"undefined"!=typeof e&&e.height()>d&&$(".content-wrapper, .right-side").css("min-height",e.height())}},fixSidebar:function(){return $("body").hasClass("fixed")?("undefined"==typeof $.fn.slimScroll&&window.console&&window.console.error("Error: the fixed layout requires the slimscroll plugin!"),void($.AdminLTE.options.sidebarSlimScroll&&"undefined"!=typeof $.fn.slimScroll&&($(".sidebar").slimScroll({destroy:!0}).height("auto"),$(".sidebar").slimscroll({height:$(window).height()-$(".main-header").height()+"px",color:"rgba(0,0,0,0.2)",size:"3px"})))):void("undefined"!=typeof $.fn.slimScroll&&$(".sidebar").slimScroll({destroy:!0}).height("auto"))}},$.AdminLTE.pushMenu={activate:function(a){var b=$.AdminLTE.options.screenSizes;$(a).on("click",function(a){a.preventDefault(),$(window).width()>b.sm-1?$("body").hasClass("sidebar-collapse")?$("body").removeClass("sidebar-collapse").trigger("expanded.pushMenu"):$("body").addClass("sidebar-collapse").trigger("collapsed.pushMenu"):$("body").hasClass("sidebar-open")?$("body").removeClass("sidebar-open").removeClass("sidebar-collapse").trigger("collapsed.pushMenu"):$("body").addClass("sidebar-open").trigger("expanded.pushMenu")}),$(".content-wrapper").click(function(){$(window).width()<=b.sm-1&&$("body").hasClass("sidebar-open")&&$("body").removeClass("sidebar-open")}),($.AdminLTE.options.sidebarExpandOnHover||$("body").hasClass("fixed")&&$("body").hasClass("sidebar-mini"))&&this.expandOnHover()},expandOnHover:function(){var a=this,b=$.AdminLTE.options.screenSizes.sm-1;$(".main-sidebar").hover(function(){$("body").hasClass("sidebar-mini")&&$("body").hasClass("sidebar-collapse")&&$(window).width()>b&&a.expand()},function(){$("body").hasClass("sidebar-mini")&&$("body").hasClass("sidebar-expanded-on-hover")&&$(window).width()>b&&a.collapse()})},expand:function(){$("body").removeClass("sidebar-collapse").addClass("sidebar-expanded-on-hover")},collapse:function(){$("body").hasClass("sidebar-expanded-on-hover")&&$("body").removeClass("sidebar-expanded-on-hover").addClass("sidebar-collapse")}},$.AdminLTE.tree=function(a){var b=this,c=$.AdminLTE.options.animationSpeed;$(document).on("click",a+" li a",function(a){var d=$(this),e=d.next();if(e.is(".treeview-menu")&&e.is(":visible"))e.slideUp(c,function(){e.removeClass("menu-open")}),e.parent("li").removeClass("active");else if(e.is(".treeview-menu")&&!e.is(":visible")){var f=d.parents("ul").first(),g=f.find("ul:visible").slideUp(c);g.removeClass("menu-open");var h=d.parent("li");e.slideDown(c,function(){e.addClass("menu-open"),f.find("li.active").removeClass("active"),h.addClass("active"),b.layout.fix()})}e.is(".treeview-menu")&&a.preventDefault()})},$.AdminLTE.controlSidebar={activate:function(){var a=this,b=$.AdminLTE.options.controlSidebarOptions,c=$(b.selector),d=$(b.toggleBtnSelector);d.on("click",function(d){d.preventDefault(),c.hasClass("control-sidebar-open")||$("body").hasClass("control-sidebar-open")?a.close(c,b.slide):a.open(c,b.slide)});var e=$(".control-sidebar-bg");a._fix(e),$("body").hasClass("fixed")?a._fixForFixed(c):$(".content-wrapper, .right-side").height() .box-body, > .box-footer, > form >.box-body, > form > .box-footer");c.hasClass("collapsed-box")?(a.children(":first").removeClass(b.icons.open).addClass(b.icons.collapse),d.slideDown(b.animationSpeed,function(){c.removeClass("collapsed-box")})):(a.children(":first").removeClass(b.icons.collapse).addClass(b.icons.open),d.slideUp(b.animationSpeed,function(){c.addClass("collapsed-box")}))},remove:function(a){var b=a.parents(".box").first();b.slideUp(this.animationSpeed)}}}if("undefined"==typeof jQuery)throw new Error("AdminLTE requires jQuery");$.AdminLTE={},$.AdminLTE.options={navbarMenuSlimscroll:!0,navbarMenuSlimscrollWidth:"3px",navbarMenuHeight:"200px",animationSpeed:500,sidebarToggleSelector:"[data-toggle='offcanvas']",sidebarPushMenu:!0,sidebarSlimScroll:!0,sidebarExpandOnHover:!1,enableBoxRefresh:!0,enableBSToppltip:!0,BSTooltipSelector:"[data-toggle='tooltip']",enableFastclick:!0,enableControlSidebar:!0,controlSidebarOptions:{toggleBtnSelector:"[data-toggle='control-sidebar']",selector:".control-sidebar",slide:!0},enableBoxWidget:!0,boxWidgetOptions:{boxWidgetIcons:{collapse:"fa-minus",open:"fa-plus",remove:"fa-times"},boxWidgetSelectors:{remove:'[data-widget="remove"]',collapse:'[data-widget="collapse"]'}},directChat:{enable:!0,contactToggleSelector:'[data-widget="chat-pane-toggle"]'},colors:{lightBlue:"#3c8dbc",red:"#f56954",green:"#00a65a",aqua:"#00c0ef",yellow:"#f39c12",blue:"#0073b7",navy:"#001F3F",teal:"#39CCCC",olive:"#3D9970",lime:"#01FF70",orange:"#FF851B",fuchsia:"#F012BE",purple:"#8E24AA",maroon:"#D81B60",black:"#222222",gray:"#d2d6de"},screenSizes:{xs:480,sm:768,md:992,lg:1200}},$(function(){"use strict";$("body").removeClass("hold-transition"),"undefined"!=typeof AdminLTEOptions&&$.extend(!0,$.AdminLTE.options,AdminLTEOptions);var a=$.AdminLTE.options;_init(),$.AdminLTE.layout.activate(),$.AdminLTE.tree(".sidebar"),a.enableControlSidebar&&$.AdminLTE.controlSidebar.activate(),a.navbarMenuSlimscroll&&"undefined"!=typeof $.fn.slimscroll&&$(".navbar .menu").slimscroll({height:a.navbarMenuHeight,alwaysVisible:!1,size:a.navbarMenuSlimscrollWidth}).css("width","100%"),a.sidebarPushMenu&&$.AdminLTE.pushMenu.activate(a.sidebarToggleSelector),a.enableBSToppltip&&$("body").tooltip({selector:a.BSTooltipSelector}),a.enableBoxWidget&&$.AdminLTE.boxWidget.activate(),a.enableFastclick&&"undefined"!=typeof FastClick&&FastClick.attach(document.body),a.directChat.enable&&$(document).on("click",a.directChat.contactToggleSelector,function(){var a=$(this).parents(".direct-chat").first();a.toggleClass("direct-chat-contacts-open")}),$('.btn-group[data-toggle="btn-toggle"]').each(function(){var a=$(this);$(this).find(".btn").on("click",function(b){a.find(".btn.active").removeClass("active"),$(this).addClass("active"),b.preventDefault()})})}),function(a){"use strict";a.fn.boxRefresh=function(b){function c(a){a.append(f),e.onLoadStart.call(a)}function d(a){a.find(f).remove(),e.onLoadDone.call(a)}var e=a.extend({trigger:".refresh-btn",source:"",onLoadStart:function(a){return a},onLoadDone:function(a){return a}},b),f=a('
');return this.each(function(){if(""===e.source)return void(window.console&&window.console.log("Please specify a source first - boxRefresh()"));var b=a(this),f=b.find(e.trigger).first();f.on("click",function(a){a.preventDefault(),c(b),b.find(".box-body").load(e.source,function(){d(b)})})})}}(jQuery),function(a){"use strict";a.fn.activateBox=function(){a.AdminLTE.boxWidget.activate(this)}}(jQuery),function(a){"use strict";a.fn.todolist=function(b){var c=a.extend({onCheck:function(a){return a},onUncheck:function(a){return a}},b);return this.each(function(){"undefined"!=typeof a.fn.iCheck?(a("input",this).on("ifChecked",function(){var b=a(this).parents("li").first();b.toggleClass("done"),c.onCheck.call(b)}),a("input",this).on("ifUnchecked",function(){var b=a(this).parents("li").first();b.toggleClass("done"),c.onUncheck.call(b)})):a("input",this).on("change",function(){var b=a(this).parents("li").first();b.toggleClass("done"),a("input",b).is(":checked")?c.onCheck.call(b):c.onUncheck.call(b)})})}}(jQuery);PK J R]ösˆ1] ] jquery.jsnu W+A„¶ /*!
* jQuery JavaScript Library v1.9.1
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2013-2-4
*/
(function( window, undefined ) {
// Can't do this because several apps including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if
// you try to trace through "use strict" call chains. (#13335)
// Support: Firefox 18+
//"use strict";
var
// The deferred used on DOM ready
readyList,
// A central reference to the root jQuery(document)
rootjQuery,
// Support: IE<9
// For `typeof node.method` instead of `node.method !== undefined`
core_strundefined = typeof undefined,
// Use the correct document accordingly with window argument (sandbox)
document = window.document,
location = window.location,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrite
_$ = window.$,
// [[Class]] -> type pairs
class2type = {},
// List of deleted data cache ids, so we can reuse them
core_deletedIds = [],
core_version = "1.9.1",
// Save a reference to some core methods
core_concat = core_deletedIds.concat,
core_push = core_deletedIds.push,
core_slice = core_deletedIds.slice,
core_indexOf = core_deletedIds.indexOf,
core_toString = class2type.toString,
core_hasOwn = class2type.hasOwnProperty,
core_trim = core_version.trim,
// Define a local copy of jQuery
jQuery = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
},
// Used for matching numbers
core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,
// Used for splitting on whitespace
core_rnotwhite = /\S+/g,
// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
// A simple way to check for HTML strings
// Prioritize #id over to avoid XSS via location.hash (#9521)
// Strict HTML recognition (#11290: must start with <)
rquickExpr = /^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,
// Match a standalone tag
rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
// JSON RegExp
rvalidchars = /^[\],:{}\s]*$/,
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
// Matches dashed string for camelizing
rmsPrefix = /^-ms-/,
rdashAlpha = /-([\da-z])/gi,
// Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) {
return letter.toUpperCase();
},
// The ready event handler
completed = function( event ) {
// readyState === "complete" is good enough for us to call the dom ready in oldIE
if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
detach();
jQuery.ready();
}
},
// Clean-up method for dom ready events
detach = function() {
if ( document.addEventListener ) {
document.removeEventListener( "DOMContentLoaded", completed, false );
window.removeEventListener( "load", completed, false );
} else {
document.detachEvent( "onreadystatechange", completed );
window.detachEvent( "onload", completed );
}
};
jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used
jquery: core_version,
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
var match, elem;
// HANDLE: $(""), $(null), $(undefined), $(false)
if ( !selector ) {
return this;
}
// Handle HTML strings
if ( typeof selector === "string" ) {
if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
// Assume that strings that start and end with <> are HTML and skip the regex check
match = [ null, selector, null ];
} else {
match = rquickExpr.exec( selector );
}
// Match html or make sure no context is specified for #id
if ( match && (match[1] || !context) ) {
// HANDLE: $(html) -> $(array)
if ( match[1] ) {
context = context instanceof jQuery ? context[0] : context;
// scripts is true for back-compat
jQuery.merge( this, jQuery.parseHTML(
match[1],
context && context.nodeType ? context.ownerDocument || context : document,
true
) );
// HANDLE: $(html, props)
if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) {
// Properties of context are called as methods if possible
if ( jQuery.isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] );
// ...and otherwise set as attributes
} else {
this.attr( match, context[ match ] );
}
}
}
return this;
// HANDLE: $(#id)
} else {
elem = document.getElementById( match[2] );
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if ( elem && elem.parentNode ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id !== match[2] ) {
return rootjQuery.find( selector );
}
// Otherwise, we inject the element directly into the jQuery object
this.length = 1;
this[0] = elem;
}
this.context = document;
this.selector = selector;
return this;
}
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
return ( context || rootjQuery ).find( selector );
// HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr)
} else {
return this.constructor( context ).find( selector );
}
// HANDLE: $(DOMElement)
} else if ( selector.nodeType ) {
this.context = this[0] = selector;
this.length = 1;
return this;
// HANDLE: $(function)
// Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) {
return rootjQuery.ready( selector );
}
if ( selector.selector !== undefined ) {
this.selector = selector.selector;
this.context = selector.context;
}
return jQuery.makeArray( selector, this );
},
// Start with an empty selector
selector: "",
// The default length of a jQuery object is 0
length: 0,
// The number of elements contained in the matched element set
size: function() {
return this.length;
},
toArray: function() {
return core_slice.call( this );
},
// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function( num ) {
return num == null ?
// Return a 'clean' array
this.toArray() :
// Return just the object
( num < 0 ? this[ this.length + num ] : this[ num ] );
},
// Take an array of elements and push it onto the stack
// (returning the new matched element set)
pushStack: function( elems ) {
// Build a new jQuery matched element set
var ret = jQuery.merge( this.constructor(), elems );
// Add the old object onto the stack (as a reference)
ret.prevObject = this;
ret.context = this.context;
// Return the newly-formed element set
return ret;
},
// Execute a callback for every element in the matched set.
// (You can seed the arguments with an array of args, but this is
// only used internally.)
each: function( callback, args ) {
return jQuery.each( this, callback, args );
},
ready: function( fn ) {
// Add the callback
jQuery.ready.promise().done( fn );
return this;
},
slice: function() {
return this.pushStack( core_slice.apply( this, arguments ) );
},
first: function() {
return this.eq( 0 );
},
last: function() {
return this.eq( -1 );
},
eq: function( i ) {
var len = this.length,
j = +i + ( i < 0 ? len : 0 );
return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
},
map: function( callback ) {
return this.pushStack( jQuery.map(this, function( elem, i ) {
return callback.call( elem, i, elem );
}));
},
end: function() {
return this.prevObject || this.constructor(null);
},
// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
push: core_push,
sort: [].sort,
splice: [].splice
};
// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;
jQuery.extend = jQuery.fn.extend = function() {
var src, copyIsArray, copy, name, options, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;
// Handle a deep copy situation
if ( typeof target === "boolean" ) {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
i = 2;
}
// Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
target = {};
}
// extend jQuery itself if only one argument is passed
if ( length === i ) {
target = this;
--i;
}
for ( ; i < length; i++ ) {
// Only deal with non-null/undefined values
if ( (options = arguments[ i ]) != null ) {
// Extend the base object
for ( name in options ) {
src = target[ name ];
copy = options[ name ];
// Prevent never-ending loop
if ( target === copy ) {
continue;
}
// Recurse if we're merging plain objects or arrays
if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
if ( copyIsArray ) {
copyIsArray = false;
clone = src && jQuery.isArray(src) ? src : [];
} else {
clone = src && jQuery.isPlainObject(src) ? src : {};
}
// Never move original objects, clone them
target[ name ] = jQuery.extend( deep, clone, copy );
// Don't bring in undefined values
} else if ( copy !== undefined ) {
target[ name ] = copy;
}
}
}
}
// Return the modified object
return target;
};
jQuery.extend({
noConflict: function( deep ) {
if ( window.$ === jQuery ) {
window.$ = _$;
}
if ( deep && window.jQuery === jQuery ) {
window.jQuery = _jQuery;
}
return jQuery;
},
// Is the DOM ready to be used? Set to true once it occurs.
isReady: false,
// A counter to track how many items to wait for before
// the ready event fires. See #6781
readyWait: 1,
// Hold (or release) the ready event
holdReady: function( hold ) {
if ( hold ) {
jQuery.readyWait++;
} else {
jQuery.ready( true );
}
},
// Handle when the DOM is ready
ready: function( wait ) {
// Abort if there are pending holds or we're already ready
if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
return;
}
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
if ( !document.body ) {
return setTimeout( jQuery.ready );
}
// Remember that the DOM is ready
jQuery.isReady = true;
// If a normal DOM Ready event fired, decrement, and wait if need be
if ( wait !== true && --jQuery.readyWait > 0 ) {
return;
}
// If there are functions bound, to execute
readyList.resolveWith( document, [ jQuery ] );
// Trigger any bound ready events
if ( jQuery.fn.trigger ) {
jQuery( document ).trigger("ready").off("ready");
}
},
// See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
isFunction: function( obj ) {
return jQuery.type(obj) === "function";
},
isArray: Array.isArray || function( obj ) {
return jQuery.type(obj) === "array";
},
isWindow: function( obj ) {
return obj != null && obj == obj.window;
},
isNumeric: function( obj ) {
return !isNaN( parseFloat(obj) ) && isFinite( obj );
},
type: function( obj ) {
if ( obj == null ) {
return String( obj );
}
return typeof obj === "object" || typeof obj === "function" ?
class2type[ core_toString.call(obj) ] || "object" :
typeof obj;
},
isPlainObject: function( obj ) {
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false;
}
try {
// Not own constructor property must be Object
if ( obj.constructor &&
!core_hasOwn.call(obj, "constructor") &&
!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false;
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
var key;
for ( key in obj ) {}
return key === undefined || core_hasOwn.call( obj, key );
},
isEmptyObject: function( obj ) {
var name;
for ( name in obj ) {
return false;
}
return true;
},
error: function( msg ) {
throw new Error( msg );
},
// data: string of html
// context (optional): If specified, the fragment will be created in this context, defaults to document
// keepScripts (optional): If true, will include scripts passed in the html string
parseHTML: function( data, context, keepScripts ) {
if ( !data || typeof data !== "string" ) {
return null;
}
if ( typeof context === "boolean" ) {
keepScripts = context;
context = false;
}
context = context || document;
var parsed = rsingleTag.exec( data ),
scripts = !keepScripts && [];
// Single tag
if ( parsed ) {
return [ context.createElement( parsed[1] ) ];
}
parsed = jQuery.buildFragment( [ data ], context, scripts );
if ( scripts ) {
jQuery( scripts ).remove();
}
return jQuery.merge( [], parsed.childNodes );
},
parseJSON: function( data ) {
// Attempt to parse using the native JSON parser first
if ( window.JSON && window.JSON.parse ) {
return window.JSON.parse( data );
}
if ( data === null ) {
return data;
}
if ( typeof data === "string" ) {
// Make sure leading/trailing whitespace is removed (IE can't handle it)
data = jQuery.trim( data );
if ( data ) {
// Make sure the incoming data is actual JSON
// Logic borrowed from http://json.org/json2.js
if ( rvalidchars.test( data.replace( rvalidescape, "@" )
.replace( rvalidtokens, "]" )
.replace( rvalidbraces, "")) ) {
return ( new Function( "return " + data ) )();
}
}
}
jQuery.error( "Invalid JSON: " + data );
},
// Cross-browser xml parsing
parseXML: function( data ) {
var xml, tmp;
if ( !data || typeof data !== "string" ) {
return null;
}
try {
if ( window.DOMParser ) { // Standard
tmp = new DOMParser();
xml = tmp.parseFromString( data , "text/xml" );
} else { // IE
xml = new ActiveXObject( "Microsoft.XMLDOM" );
xml.async = "false";
xml.loadXML( data );
}
} catch( e ) {
xml = undefined;
}
if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
jQuery.error( "Invalid XML: " + data );
}
return xml;
},
noop: function() {},
// Evaluates a script in a global context
// Workarounds based on findings by Jim Driscoll
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
globalEval: function( data ) {
if ( data && jQuery.trim( data ) ) {
// We use execScript on Internet Explorer
// We use an anonymous function so that context is window
// rather than jQuery in Firefox
( window.execScript || function( data ) {
window[ "eval" ].call( window, data );
} )( data );
}
},
// Convert dashed to camelCase; used by the css and data modules
// Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
},
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
},
// args is for internal usage only
each: function( obj, callback, args ) {
var value,
i = 0,
length = obj.length,
isArray = isArraylike( obj );
if ( args ) {
if ( isArray ) {
for ( ; i < length; i++ ) {
value = callback.apply( obj[ i ], args );
if ( value === false ) {
break;
}
}
} else {
for ( i in obj ) {
value = callback.apply( obj[ i ], args );
if ( value === false ) {
break;
}
}
}
// A special, fast, case for the most common use of each
} else {
if ( isArray ) {
for ( ; i < length; i++ ) {
value = callback.call( obj[ i ], i, obj[ i ] );
if ( value === false ) {
break;
}
}
} else {
for ( i in obj ) {
value = callback.call( obj[ i ], i, obj[ i ] );
if ( value === false ) {
break;
}
}
}
}
return obj;
},
// Use native String.trim function wherever possible
trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
function( text ) {
return text == null ?
"" :
core_trim.call( text );
} :
// Otherwise use our own trimming functionality
function( text ) {
return text == null ?
"" :
( text + "" ).replace( rtrim, "" );
},
// results is for internal usage only
makeArray: function( arr, results ) {
var ret = results || [];
if ( arr != null ) {
if ( isArraylike( Object(arr) ) ) {
jQuery.merge( ret,
typeof arr === "string" ?
[ arr ] : arr
);
} else {
core_push.call( ret, arr );
}
}
return ret;
},
inArray: function( elem, arr, i ) {
var len;
if ( arr ) {
if ( core_indexOf ) {
return core_indexOf.call( arr, elem, i );
}
len = arr.length;
i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
for ( ; i < len; i++ ) {
// Skip accessing in sparse arrays
if ( i in arr && arr[ i ] === elem ) {
return i;
}
}
}
return -1;
},
merge: function( first, second ) {
var l = second.length,
i = first.length,
j = 0;
if ( typeof l === "number" ) {
for ( ; j < l; j++ ) {
first[ i++ ] = second[ j ];
}
} else {
while ( second[j] !== undefined ) {
first[ i++ ] = second[ j++ ];
}
}
first.length = i;
return first;
},
grep: function( elems, callback, inv ) {
var retVal,
ret = [],
i = 0,
length = elems.length;
inv = !!inv;
// Go through the array, only saving the items
// that pass the validator function
for ( ; i < length; i++ ) {
retVal = !!callback( elems[ i ], i );
if ( inv !== retVal ) {
ret.push( elems[ i ] );
}
}
return ret;
},
// arg is for internal usage only
map: function( elems, callback, arg ) {
var value,
i = 0,
length = elems.length,
isArray = isArraylike( elems ),
ret = [];
// Go through the array, translating each of the items to their
if ( isArray ) {
for ( ; i < length; i++ ) {
value = callback( elems[ i ], i, arg );
if ( value != null ) {
ret[ ret.length ] = value;
}
}
// Go through every key on the object,
} else {
for ( i in elems ) {
value = callback( elems[ i ], i, arg );
if ( value != null ) {
ret[ ret.length ] = value;
}
}
}
// Flatten any nested arrays
return core_concat.apply( [], ret );
},
// A global GUID counter for objects
guid: 1,
// Bind a function to a context, optionally partially applying any
// arguments.
proxy: function( fn, context ) {
var args, proxy, tmp;
if ( typeof context === "string" ) {
tmp = fn[ context ];
context = fn;
fn = tmp;
}
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
if ( !jQuery.isFunction( fn ) ) {
return undefined;
}
// Simulated bind
args = core_slice.call( arguments, 2 );
proxy = function() {
return fn.apply( context || this, args.concat( core_slice.call( arguments ) ) );
};
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || jQuery.guid++;
return proxy;
},
// Multifunctional method to get and set values of a collection
// The value/s can optionally be executed if it's a function
access: function( elems, fn, key, value, chainable, emptyGet, raw ) {
var i = 0,
length = elems.length,
bulk = key == null;
// Sets many values
if ( jQuery.type( key ) === "object" ) {
chainable = true;
for ( i in key ) {
jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
}
// Sets one value
} else if ( value !== undefined ) {
chainable = true;
if ( !jQuery.isFunction( value ) ) {
raw = true;
}
if ( bulk ) {
// Bulk operations run against the entire set
if ( raw ) {
fn.call( elems, value );
fn = null;
// ...except when executing function values
} else {
bulk = fn;
fn = function( elem, key, value ) {
return bulk.call( jQuery( elem ), value );
};
}
}
if ( fn ) {
for ( ; i < length; i++ ) {
fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
}
}
}
return chainable ?
elems :
// Gets
bulk ?
fn.call( elems ) :
length ? fn( elems[0], key ) : emptyGet;
},
now: function() {
return ( new Date() ).getTime();
}
});
jQuery.ready.promise = function( obj ) {
if ( !readyList ) {
readyList = jQuery.Deferred();
// Catch cases where $(document).ready() is called after the browser event has already occurred.
// we once tried to use readyState "interactive" here, but it caused issues like the one
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready
setTimeout( jQuery.ready );
// Standards-based browsers support DOMContentLoaded
} else if ( document.addEventListener ) {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", completed, false );
// A fallback to window.onload, that will always work
window.addEventListener( "load", completed, false );
// If IE event model is used
} else {
// Ensure firing before onload, maybe late but safe also for iframes
document.attachEvent( "onreadystatechange", completed );
// A fallback to window.onload, that will always work
window.attachEvent( "onload", completed );
// If IE and not a frame
// continually check to see if the document is ready
var top = false;
try {
top = window.frameElement == null && document.documentElement;
} catch(e) {}
if ( top && top.doScroll ) {
(function doScrollCheck() {
if ( !jQuery.isReady ) {
try {
// Use the trick by Diego Perini
// http://javascript.nwbox.com/IEContentLoaded/
top.doScroll("left");
} catch(e) {
return setTimeout( doScrollCheck, 50 );
}
// detach all dom ready events
detach();
// and execute any waiting functions
jQuery.ready();
}
})();
}
}
}
return readyList.promise( obj );
};
// Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
class2type[ "[object " + name + "]" ] = name.toLowerCase();
});
function isArraylike( obj ) {
var length = obj.length,
type = jQuery.type( obj );
if ( jQuery.isWindow( obj ) ) {
return false;
}
if ( obj.nodeType === 1 && length ) {
return true;
}
return type === "array" || type !== "function" &&
( length === 0 ||
typeof length === "number" && length > 0 && ( length - 1 ) in obj );
}
// All jQuery objects should point back to these
rootjQuery = jQuery(document);
// String to Object options format cache
var optionsCache = {};
// Convert String-formatted options into Object-formatted ones and store in cache
function createOptions( options ) {
var object = optionsCache[ options ] = {};
jQuery.each( options.match( core_rnotwhite ) || [], function( _, flag ) {
object[ flag ] = true;
});
return object;
}
/*
* Create a callback list using the following parameters:
*
* options: an optional list of space-separated options that will change how
* the callback list behaves or a more traditional option object
*
* By default a callback list will act like an event callback list and can be
* "fired" multiple times.
*
* Possible options:
*
* once: will ensure the callback list can only be fired once (like a Deferred)
*
* memory: will keep track of previous values and will call any callback added
* after the list has been fired right away with the latest "memorized"
* values (like a Deferred)
*
* unique: will ensure a callback can only be added once (no duplicate in the list)
*
* stopOnFalse: interrupt callings when a callback returns false
*
*/
jQuery.Callbacks = function( options ) {
// Convert options from String-formatted to Object-formatted if needed
// (we check in cache first)
options = typeof options === "string" ?
( optionsCache[ options ] || createOptions( options ) ) :
jQuery.extend( {}, options );
var // Flag to know if list is currently firing
firing,
// Last fire value (for non-forgettable lists)
memory,
// Flag to know if list was already fired
fired,
// End of the loop when firing
firingLength,
// Index of currently firing callback (modified by remove if needed)
firingIndex,
// First callback to fire (used internally by add and fireWith)
firingStart,
// Actual callback list
list = [],
// Stack of fire calls for repeatable lists
stack = !options.once && [],
// Fire callbacks
fire = function( data ) {
memory = options.memory && data;
fired = true;
firingIndex = firingStart || 0;
firingStart = 0;
firingLength = list.length;
firing = true;
for ( ; list && firingIndex < firingLength; firingIndex++ ) {
if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
memory = false; // To prevent further calls using add
break;
}
}
firing = false;
if ( list ) {
if ( stack ) {
if ( stack.length ) {
fire( stack.shift() );
}
} else if ( memory ) {
list = [];
} else {
self.disable();
}
}
},
// Actual Callbacks object
self = {
// Add a callback or a collection of callbacks to the list
add: function() {
if ( list ) {
// First, we save the current length
var start = list.length;
(function add( args ) {
jQuery.each( args, function( _, arg ) {
var type = jQuery.type( arg );
if ( type === "function" ) {
if ( !options.unique || !self.has( arg ) ) {
list.push( arg );
}
} else if ( arg && arg.length && type !== "string" ) {
// Inspect recursively
add( arg );
}
});
})( arguments );
// Do we need to add the callbacks to the
// current firing batch?
if ( firing ) {
firingLength = list.length;
// With memory, if we're not firing then
// we should call right away
} else if ( memory ) {
firingStart = start;
fire( memory );
}
}
return this;
},
// Remove a callback from the list
remove: function() {
if ( list ) {
jQuery.each( arguments, function( _, arg ) {
var index;
while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
list.splice( index, 1 );
// Handle firing indexes
if ( firing ) {
if ( index <= firingLength ) {
firingLength--;
}
if ( index <= firingIndex ) {
firingIndex--;
}
}
}
});
}
return this;
},
// Check if a given callback is in the list.
// If no argument is given, return whether or not list has callbacks attached.
has: function( fn ) {
return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
},
// Remove all callbacks from the list
empty: function() {
list = [];
return this;
},
// Have the list do nothing anymore
disable: function() {
list = stack = memory = undefined;
return this;
},
// Is it disabled?
disabled: function() {
return !list;
},
// Lock the list in its current state
lock: function() {
stack = undefined;
if ( !memory ) {
self.disable();
}
return this;
},
// Is it locked?
locked: function() {
return !stack;
},
// Call all callbacks with the given context and arguments
fireWith: function( context, args ) {
args = args || [];
args = [ context, args.slice ? args.slice() : args ];
if ( list && ( !fired || stack ) ) {
if ( firing ) {
stack.push( args );
} else {
fire( args );
}
}
return this;
},
// Call all the callbacks with the given arguments
fire: function() {
self.fireWith( this, arguments );
return this;
},
// To know if the callbacks have already been called at least once
fired: function() {
return !!fired;
}
};
return self;
};
jQuery.extend({
Deferred: function( func ) {
var tuples = [
// action, add listener, listener list, final state
[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
[ "notify", "progress", jQuery.Callbacks("memory") ]
],
state = "pending",
promise = {
state: function() {
return state;
},
always: function() {
deferred.done( arguments ).fail( arguments );
return this;
},
then: function( /* fnDone, fnFail, fnProgress */ ) {
var fns = arguments;
return jQuery.Deferred(function( newDefer ) {
jQuery.each( tuples, function( i, tuple ) {
var action = tuple[ 0 ],
fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
// deferred[ done | fail | progress ] for forwarding actions to newDefer
deferred[ tuple[1] ](function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) {
returned.promise()
.done( newDefer.resolve )
.fail( newDefer.reject )
.progress( newDefer.notify );
} else {
newDefer[ action + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
}
});
});
fns = null;
}).promise();
},
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise: function( obj ) {
return obj != null ? jQuery.extend( obj, promise ) : promise;
}
},
deferred = {};
// Keep pipe for back-compat
promise.pipe = promise.then;
// Add list-specific methods
jQuery.each( tuples, function( i, tuple ) {
var list = tuple[ 2 ],
stateString = tuple[ 3 ];
// promise[ done | fail | progress ] = list.add
promise[ tuple[1] ] = list.add;
// Handle state
if ( stateString ) {
list.add(function() {
// state = [ resolved | rejected ]
state = stateString;
// [ reject_list | resolve_list ].disable; progress_list.lock
}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
}
// deferred[ resolve | reject | notify ]
deferred[ tuple[0] ] = function() {
deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
return this;
};
deferred[ tuple[0] + "With" ] = list.fireWith;
});
// Make the deferred a promise
promise.promise( deferred );
// Call given func if any
if ( func ) {
func.call( deferred, deferred );
}
// All done!
return deferred;
},
// Deferred helper
when: function( subordinate /* , ..., subordinateN */ ) {
var i = 0,
resolveValues = core_slice.call( arguments ),
length = resolveValues.length,
// the count of uncompleted subordinates
remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
// the master Deferred. If resolveValues consist of only a single Deferred, just use that.
deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
// Update function for both resolve and progress values
updateFunc = function( i, contexts, values ) {
return function( value ) {
contexts[ i ] = this;
values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
if( values === progressValues ) {
deferred.notifyWith( contexts, values );
} else if ( !( --remaining ) ) {
deferred.resolveWith( contexts, values );
}
};
},
progressValues, progressContexts, resolveContexts;
// add listeners to Deferred subordinates; treat others as resolved
if ( length > 1 ) {
progressValues = new Array( length );
progressContexts = new Array( length );
resolveContexts = new Array( length );
for ( ; i < length; i++ ) {
if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
resolveValues[ i ].promise()
.done( updateFunc( i, resolveContexts, resolveValues ) )
.fail( deferred.reject )
.progress( updateFunc( i, progressContexts, progressValues ) );
} else {
--remaining;
}
}
}
// if we're not waiting on anything, resolve the master
if ( !remaining ) {
deferred.resolveWith( resolveContexts, resolveValues );
}
return deferred.promise();
}
});
jQuery.support = (function() {
var support, all, a,
input, select, fragment,
opt, eventName, isSupported, i,
div = document.createElement("div");
// Setup
div.setAttribute( "className", "t" );
div.innerHTML = "
a";
// Support tests won't run in some limited or non-browser environments
all = div.getElementsByTagName("*");
a = div.getElementsByTagName("a")[ 0 ];
if ( !all || !a || !all.length ) {
return {};
}
// First batch of tests
select = document.createElement("select");
opt = select.appendChild( document.createElement("option") );
input = div.getElementsByTagName("input")[ 0 ];
a.style.cssText = "top:1px;float:left;opacity:.5";
support = {
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
getSetAttribute: div.className !== "t",
// IE strips leading whitespace when .innerHTML is used
leadingWhitespace: div.firstChild.nodeType === 3,
// Make sure that tbody elements aren't automatically inserted
// IE will insert them into empty tables
tbody: !div.getElementsByTagName("tbody").length,
// Make sure that link elements get serialized correctly by innerHTML
// This requires a wrapper element in IE
htmlSerialize: !!div.getElementsByTagName("link").length,
// Get the style information from getAttribute
// (IE uses .cssText instead)
style: /top/.test( a.getAttribute("style") ),
// Make sure that URLs aren't manipulated
// (IE normalizes it by default)
hrefNormalized: a.getAttribute("href") === "/a",
// Make sure that element opacity exists
// (IE uses filter instead)
// Use a regex to work around a WebKit issue. See #5145
opacity: /^0.5/.test( a.style.opacity ),
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
cssFloat: !!a.style.cssFloat,
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
checkOn: !!input.value,
// Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
optSelected: opt.selected,
// Tests for enctype support on a form (#6743)
enctype: !!document.createElement("form").enctype,
// Makes sure cloning an html5 element does not cause problems
// Where outerHTML is undefined, this still works
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav>",
// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
boxModel: document.compatMode === "CSS1Compat",
// Will be defined later
deleteExpando: true,
noCloneEvent: true,
inlineBlockNeedsLayout: false,
shrinkWrapBlocks: false,
reliableMarginRight: true,
boxSizingReliable: true,
pixelPosition: false
};
// Make sure checked status is properly cloned
input.checked = true;
support.noCloneChecked = input.cloneNode( true ).checked;
// Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as disabled)
select.disabled = true;
support.optDisabled = !opt.disabled;
// Support: IE<9
try {
delete div.test;
} catch( e ) {
support.deleteExpando = false;
}
// Check if we can trust getAttribute("value")
input = document.createElement("input");
input.setAttribute( "value", "" );
support.input = input.getAttribute( "value" ) === "";
// Check if an input maintains its value after becoming a radio
input.value = "t";
input.setAttribute( "type", "radio" );
support.radioValue = input.value === "t";
// #11217 - WebKit loses check when the name is after the checked attribute
input.setAttribute( "checked", "t" );
input.setAttribute( "name", "t" );
fragment = document.createDocumentFragment();
fragment.appendChild( input );
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
support.appendChecked = input.checked;
// WebKit doesn't clone checked state correctly in fragments
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: IE<9
// Opera does not clone events (and typeof div.attachEvent === undefined).
// IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
if ( div.attachEvent ) {
div.attachEvent( "onclick", function() {
support.noCloneEvent = false;
});
div.cloneNode( true ).click();
}
// Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP), test/csp.php
for ( i in { submit: true, change: true, focusin: true }) {
div.setAttribute( eventName = "on" + i, "t" );
support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
}
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
// Run tests that need a body at doc ready
jQuery(function() {
var container, marginDiv, tds,
divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
body = document.getElementsByTagName("body")[0];
if ( !body ) {
// Return for frameset docs that don't have a body
return;
}
container = document.createElement("div");
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
body.appendChild( container ).appendChild( div );
// Support: IE8
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// table row; if so, offsetWidth/Height are not reliable for use when
// determining if an element has been hidden directly using
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
div.innerHTML = "
t
";
tds = div.getElementsByTagName("td");
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
isSupported = ( tds[ 0 ].offsetHeight === 0 );
tds[ 0 ].style.display = "";
tds[ 1 ].style.display = "none";
// Support: IE8
// Check if empty table cells still have offsetWidth/Height
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
// Check box-sizing and margin behavior
div.innerHTML = "";
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
support.boxSizing = ( div.offsetWidth === 4 );
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );
// Use window.getComputedStyle because jsdom on node.js will break without it.
if ( window.getComputedStyle ) {
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
marginDiv = div.appendChild( document.createElement("div") );
marginDiv.style.cssText = div.style.cssText = divReset;
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
support.reliableMarginRight =
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
}
if ( typeof div.style.zoom !== core_strundefined ) {
// Support: IE<8
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// them layout
div.innerHTML = "";
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
// Support: IE6
// Check if elements with layout shrink-wrap their children
div.style.display = "block";
div.innerHTML = "";
div.firstChild.style.width = "5px";
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
if ( support.inlineBlockNeedsLayout ) {
// Prevent IE 6 from affecting layout for positioned elements #11048
// Prevent IE from shrinking the body in IE 7 mode #12869
// Support: IE<8
body.style.zoom = 1;
}
}
body.removeChild( container );
// Null elements to avoid leaks in IE
container = div = tds = marginDiv = null;
});
// Null elements to avoid leaks in IE
all = select = fragment = opt = a = input = null;
return support;
})();
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
rmultiDash = /([A-Z])/g;
function internalData( elem, name, data, pvt /* Internal Use Only */ ){
if ( !jQuery.acceptData( elem ) ) {
return;
}
var thisCache, ret,
internalKey = jQuery.expando,
getByName = typeof name === "string",
// We have to handle DOM nodes and JS objects differently because IE6-7
// can't GC object references properly across the DOM-JS boundary
isNode = elem.nodeType,
// Only DOM nodes need the global jQuery cache; JS object data is
// attached directly to the object so GC can occur automatically
cache = isNode ? jQuery.cache : elem,
// Only defining an ID for JS objects if its cache already exists allows
// the code to shortcut on the same path as a DOM node with no cache
id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
// Avoid doing any more work than we need to when trying to get data on an
// object that has no data at all
if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
return;
}
if ( !id ) {
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
if ( isNode ) {
elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++;
} else {
id = internalKey;
}
}
if ( !cache[ id ] ) {
cache[ id ] = {};
// Avoids exposing jQuery metadata on plain JS objects when the object
// is serialized using JSON.stringify
if ( !isNode ) {
cache[ id ].toJSON = jQuery.noop;
}
}
// An object can be passed to jQuery.data instead of a key/value pair; this gets
// shallow copied over onto the existing cache
if ( typeof name === "object" || typeof name === "function" ) {
if ( pvt ) {
cache[ id ] = jQuery.extend( cache[ id ], name );
} else {
cache[ id ].data = jQuery.extend( cache[ id ].data, name );
}
}
thisCache = cache[ id ];
// jQuery data() is stored in a separate object inside the object's internal data
// cache in order to avoid key collisions between internal data and user-defined
// data.
if ( !pvt ) {
if ( !thisCache.data ) {
thisCache.data = {};
}
thisCache = thisCache.data;
}
if ( data !== undefined ) {
thisCache[ jQuery.camelCase( name ) ] = data;
}
// Check for both converted-to-camel and non-converted data property names
// If a data property was specified
if ( getByName ) {
// First Try to find as-is property data
ret = thisCache[ name ];
// Test for null|undefined property data
if ( ret == null ) {
// Try to find the camelCased property
ret = thisCache[ jQuery.camelCase( name ) ];
}
} else {
ret = thisCache;
}
return ret;
}
function internalRemoveData( elem, name, pvt ) {
if ( !jQuery.acceptData( elem ) ) {
return;
}
var i, l, thisCache,
isNode = elem.nodeType,
// See jQuery.data for more information
cache = isNode ? jQuery.cache : elem,
id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
// If there is already no cache entry for this object, there is no
// purpose in continuing
if ( !cache[ id ] ) {
return;
}
if ( name ) {
thisCache = pvt ? cache[ id ] : cache[ id ].data;
if ( thisCache ) {
// Support array or space separated string names for data keys
if ( !jQuery.isArray( name ) ) {
// try the string as a key before any manipulation
if ( name in thisCache ) {
name = [ name ];
} else {
// split the camel cased version by spaces unless a key with the spaces exists
name = jQuery.camelCase( name );
if ( name in thisCache ) {
name = [ name ];
} else {
name = name.split(" ");
}
}
} else {
// If "name" is an array of keys...
// When data is initially created, via ("key", "val") signature,
// keys will be converted to camelCase.
// Since there is no way to tell _how_ a key was added, remove
// both plain key and camelCase key. #12786
// This will only penalize the array argument path.
name = name.concat( jQuery.map( name, jQuery.camelCase ) );
}
for ( i = 0, l = name.length; i < l; i++ ) {
delete thisCache[ name[i] ];
}
// If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed
if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
return;
}
}
}
// See jQuery.data for more information
if ( !pvt ) {
delete cache[ id ].data;
// Don't destroy the parent cache unless the internal data object
// had been the only thing left in it
if ( !isEmptyDataObject( cache[ id ] ) ) {
return;
}
}
// Destroy the cache
if ( isNode ) {
jQuery.cleanData( [ elem ], true );
// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
} else if ( jQuery.support.deleteExpando || cache != cache.window ) {
delete cache[ id ];
// When all else fails, null
} else {
cache[ id ] = null;
}
}
jQuery.extend({
cache: {},
// Unique for each copy of jQuery on the page
// Non-digits removed to match rinlinejQuery
expando: "jQuery" + ( core_version + Math.random() ).replace( /\D/g, "" ),
// The following elements throw uncatchable exceptions if you
// attempt to add expando properties to them.
noData: {
"embed": true,
// Ban all objects except for Flash (which handle expandos)
"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
"applet": true
},
hasData: function( elem ) {
elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
return !!elem && !isEmptyDataObject( elem );
},
data: function( elem, name, data ) {
return internalData( elem, name, data );
},
removeData: function( elem, name ) {
return internalRemoveData( elem, name );
},
// For internal use only.
_data: function( elem, name, data ) {
return internalData( elem, name, data, true );
},
_removeData: function( elem, name ) {
return internalRemoveData( elem, name, true );
},
// A method for determining if a DOM node can handle the data expando
acceptData: function( elem ) {
// Do not set data on non-element because it will not be cleared (#8335).
if ( elem.nodeType && elem.nodeType !== 1 && elem.nodeType !== 9 ) {
return false;
}
var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];
// nodes accept data unless otherwise specified; rejection can be conditional
return !noData || noData !== true && elem.getAttribute("classid") === noData;
}
});
jQuery.fn.extend({
data: function( key, value ) {
var attrs, name,
elem = this[0],
i = 0,
data = null;
// Gets all values
if ( key === undefined ) {
if ( this.length ) {
data = jQuery.data( elem );
if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
attrs = elem.attributes;
for ( ; i < attrs.length; i++ ) {
name = attrs[i].name;
if ( !name.indexOf( "data-" ) ) {
name = jQuery.camelCase( name.slice(5) );
dataAttr( elem, name, data[ name ] );
}
}
jQuery._data( elem, "parsedAttrs", true );
}
}
return data;
}
// Sets multiple values
if ( typeof key === "object" ) {
return this.each(function() {
jQuery.data( this, key );
});
}
return jQuery.access( this, function( value ) {
if ( value === undefined ) {
// Try to fetch any internally stored data first
return elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : null;
}
this.each(function() {
jQuery.data( this, key, value );
});
}, null, value, arguments.length > 1, null, true );
},
removeData: function( key ) {
return this.each(function() {
jQuery.removeData( this, key );
});
}
});
function dataAttr( elem, key, data ) {
// If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) {
var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
data = elem.getAttribute( name );
if ( typeof data === "string" ) {
try {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
// Only convert to a number if it doesn't change the string
+data + "" === data ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
data;
} catch( e ) {}
// Make sure we set the data so it isn't changed later
jQuery.data( elem, key, data );
} else {
data = undefined;
}
}
return data;
}
// checks a cache object for emptiness
function isEmptyDataObject( obj ) {
var name;
for ( name in obj ) {
// if the public data object is empty, the private is still empty
if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
continue;
}
if ( name !== "toJSON" ) {
return false;
}
}
return true;
}
jQuery.extend({
queue: function( elem, type, data ) {
var queue;
if ( elem ) {
type = ( type || "fx" ) + "queue";
queue = jQuery._data( elem, type );
// Speed up dequeue by getting out quickly if this is just a lookup
if ( data ) {
if ( !queue || jQuery.isArray(data) ) {
queue = jQuery._data( elem, type, jQuery.makeArray(data) );
} else {
queue.push( data );
}
}
return queue || [];
}
},
dequeue: function( elem, type ) {
type = type || "fx";
var queue = jQuery.queue( elem, type ),
startLength = queue.length,
fn = queue.shift(),
hooks = jQuery._queueHooks( elem, type ),
next = function() {
jQuery.dequeue( elem, type );
};
// If the fx queue is dequeued, always remove the progress sentinel
if ( fn === "inprogress" ) {
fn = queue.shift();
startLength--;
}
hooks.cur = fn;
if ( fn ) {
// Add a progress sentinel to prevent the fx queue from being
// automatically dequeued
if ( type === "fx" ) {
queue.unshift( "inprogress" );
}
// clear up the last queue stop function
delete hooks.stop;
fn.call( elem, next, hooks );
}
if ( !startLength && hooks ) {
hooks.empty.fire();
}
},
// not intended for public consumption - generates a queueHooks object, or returns the current one
_queueHooks: function( elem, type ) {
var key = type + "queueHooks";
return jQuery._data( elem, key ) || jQuery._data( elem, key, {
empty: jQuery.Callbacks("once memory").add(function() {
jQuery._removeData( elem, type + "queue" );
jQuery._removeData( elem, key );
})
});
}
});
jQuery.fn.extend({
queue: function( type, data ) {
var setter = 2;
if ( typeof type !== "string" ) {
data = type;
type = "fx";
setter--;
}
if ( arguments.length < setter ) {
return jQuery.queue( this[0], type );
}
return data === undefined ?
this :
this.each(function() {
var queue = jQuery.queue( this, type, data );
// ensure a hooks for this queue
jQuery._queueHooks( this, type );
if ( type === "fx" && queue[0] !== "inprogress" ) {
jQuery.dequeue( this, type );
}
});
},
dequeue: function( type ) {
return this.each(function() {
jQuery.dequeue( this, type );
});
},
// Based off of the plugin by Clint Helfers, with permission.
// http://blindsignals.com/index.php/2009/07/jquery-delay/
delay: function( time, type ) {
time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
type = type || "fx";
return this.queue( type, function( next, hooks ) {
var timeout = setTimeout( next, time );
hooks.stop = function() {
clearTimeout( timeout );
};
});
},
clearQueue: function( type ) {
return this.queue( type || "fx", [] );
},
// Get a promise resolved when queues of a certain type
// are emptied (fx is the type by default)
promise: function( type, obj ) {
var tmp,
count = 1,
defer = jQuery.Deferred(),
elements = this,
i = this.length,
resolve = function() {
if ( !( --count ) ) {
defer.resolveWith( elements, [ elements ] );
}
};
if ( typeof type !== "string" ) {
obj = type;
type = undefined;
}
type = type || "fx";
while( i-- ) {
tmp = jQuery._data( elements[ i ], type + "queueHooks" );
if ( tmp && tmp.empty ) {
count++;
tmp.empty.add( resolve );
}
}
resolve();
return defer.promise( obj );
}
});
var nodeHook, boolHook,
rclass = /[\t\r\n]/g,
rreturn = /\r/g,
rfocusable = /^(?:input|select|textarea|button|object)$/i,
rclickable = /^(?:a|area)$/i,
rboolean = /^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,
ruseDefault = /^(?:checked|selected)$/i,
getSetAttribute = jQuery.support.getSetAttribute,
getSetInput = jQuery.support.input;
jQuery.fn.extend({
attr: function( name, value ) {
return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
},
removeAttr: function( name ) {
return this.each(function() {
jQuery.removeAttr( this, name );
});
},
prop: function( name, value ) {
return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
},
removeProp: function( name ) {
name = jQuery.propFix[ name ] || name;
return this.each(function() {
// try/catch handles cases where IE balks (such as removing a property on window)
try {
this[ name ] = undefined;
delete this[ name ];
} catch( e ) {}
});
},
addClass: function( value ) {
var classes, elem, cur, clazz, j,
i = 0,
len = this.length,
proceed = typeof value === "string" && value;
if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
jQuery( this ).addClass( value.call( this, j, this.className ) );
});
}
if ( proceed ) {
// The disjunction here is for better compressibility (see removeClass)
classes = ( value || "" ).match( core_rnotwhite ) || [];
for ( ; i < len; i++ ) {
elem = this[ i ];
cur = elem.nodeType === 1 && ( elem.className ?
( " " + elem.className + " " ).replace( rclass, " " ) :
" "
);
if ( cur ) {
j = 0;
while ( (clazz = classes[j++]) ) {
if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
cur += clazz + " ";
}
}
elem.className = jQuery.trim( cur );
}
}
}
return this;
},
removeClass: function( value ) {
var classes, elem, cur, clazz, j,
i = 0,
len = this.length,
proceed = arguments.length === 0 || typeof value === "string" && value;
if ( jQuery.isFunction( value ) ) {
return this.each(function( j ) {
jQuery( this ).removeClass( value.call( this, j, this.className ) );
});
}
if ( proceed ) {
classes = ( value || "" ).match( core_rnotwhite ) || [];
for ( ; i < len; i++ ) {
elem = this[ i ];
// This expression is here for better compressibility (see addClass)
cur = elem.nodeType === 1 && ( elem.className ?
( " " + elem.className + " " ).replace( rclass, " " ) :
""
);
if ( cur ) {
j = 0;
while ( (clazz = classes[j++]) ) {
// Remove *all* instances
while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
cur = cur.replace( " " + clazz + " ", " " );
}
}
elem.className = value ? jQuery.trim( cur ) : "";
}
}
}
return this;
},
toggleClass: function( value, stateVal ) {
var type = typeof value,
isBool = typeof stateVal === "boolean";
if ( jQuery.isFunction( value ) ) {
return this.each(function( i ) {
jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
});
}
return this.each(function() {
if ( type === "string" ) {
// toggle individual class names
var className,
i = 0,
self = jQuery( this ),
state = stateVal,
classNames = value.match( core_rnotwhite ) || [];
while ( (className = classNames[ i++ ]) ) {
// check each className given, space separated list
state = isBool ? state : !self.hasClass( className );
self[ state ? "addClass" : "removeClass" ]( className );
}
// Toggle whole class name
} else if ( type === core_strundefined || type === "boolean" ) {
if ( this.className ) {
// store className if set
jQuery._data( this, "__className__", this.className );
}
// If the element has a class name or if we're passed "false",
// then remove the whole classname (if there was one, the above saved it).
// Otherwise bring back whatever was previously saved (if anything),
// falling back to the empty string if nothing was stored.
this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
}
});
},
hasClass: function( selector ) {
var className = " " + selector + " ",
i = 0,
l = this.length;
for ( ; i < l; i++ ) {
if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
return true;
}
}
return false;
},
val: function( value ) {
var ret, hooks, isFunction,
elem = this[0];
if ( !arguments.length ) {
if ( elem ) {
hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
return ret;
}
ret = elem.value;
return typeof ret === "string" ?
// handle most common string cases
ret.replace(rreturn, "") :
// handle cases where value is null/undef or number
ret == null ? "" : ret;
}
return;
}
isFunction = jQuery.isFunction( value );
return this.each(function( i ) {
var val,
self = jQuery(this);
if ( this.nodeType !== 1 ) {
return;
}
if ( isFunction ) {
val = value.call( this, i, self.val() );
} else {
val = value;
}
// Treat null/undefined as ""; convert numbers to string
if ( val == null ) {
val = "";
} else if ( typeof val === "number" ) {
val += "";
} else if ( jQuery.isArray( val ) ) {
val = jQuery.map(val, function ( value ) {
return value == null ? "" : value + "";
});
}
hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
this.value = val;
}
});
}
});
jQuery.extend({
valHooks: {
option: {
get: function( elem ) {
// attributes.value is undefined in Blackberry 4.7 but
// uses .value. See #6932
var val = elem.attributes.value;
return !val || val.specified ? elem.value : elem.text;
}
},
select: {
get: function( elem ) {
var value, option,
options = elem.options,
index = elem.selectedIndex,
one = elem.type === "select-one" || index < 0,
values = one ? null : [],
max = one ? index + 1 : options.length,
i = index < 0 ?
max :
one ? index : 0;
// Loop through all the selected options
for ( ; i < max; i++ ) {
option = options[ i ];
// oldIE doesn't update selected after form reset (#2551)
if ( ( option.selected || i === index ) &&
// Don't return options that are disabled or in a disabled optgroup
( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option
value = jQuery( option ).val();
// We don't need an array for one selects
if ( one ) {
return value;
}
// Multi-Selects return an array
values.push( value );
}
}
return values;
},
set: function( elem, value ) {
var values = jQuery.makeArray( value );
jQuery(elem).find("option").each(function() {
this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
});
if ( !values.length ) {
elem.selectedIndex = -1;
}
return values;
}
}
},
attr: function( elem, name, value ) {
var hooks, notxml, ret,
nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return;
}
// Fallback to prop when attributes are not supported
if ( typeof elem.getAttribute === core_strundefined ) {
return jQuery.prop( elem, name, value );
}
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// All attributes are lowercase
// Grab necessary hook if one is defined
if ( notxml ) {
name = name.toLowerCase();
hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
}
if ( value !== undefined ) {
if ( value === null ) {
jQuery.removeAttr( elem, name );
} else if ( hooks && notxml && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret;
} else {
elem.setAttribute( name, value + "" );
return value;
}
} else if ( hooks && notxml && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
return ret;
} else {
// In IE9+, Flash objects don't have .getAttribute (#12945)
// Support: IE9+
if ( typeof elem.getAttribute !== core_strundefined ) {
ret = elem.getAttribute( name );
}
// Non-existent attributes return null, we normalize to undefined
return ret == null ?
undefined :
ret;
}
},
removeAttr: function( elem, value ) {
var name, propName,
i = 0,
attrNames = value && value.match( core_rnotwhite );
if ( attrNames && elem.nodeType === 1 ) {
while ( (name = attrNames[i++]) ) {
propName = jQuery.propFix[ name ] || name;
// Boolean attributes get special treatment (#10870)
if ( rboolean.test( name ) ) {
// Set corresponding property to false for boolean attributes
// Also clear defaultChecked/defaultSelected (if appropriate) for IE<8
if ( !getSetAttribute && ruseDefault.test( name ) ) {
elem[ jQuery.camelCase( "default-" + name ) ] =
elem[ propName ] = false;
} else {
elem[ propName ] = false;
}
// See #9699 for explanation of this approach (setting first, then removal)
} else {
jQuery.attr( elem, name, "" );
}
elem.removeAttribute( getSetAttribute ? name : propName );
}
}
},
attrHooks: {
type: {
set: function( elem, value ) {
if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
// Setting the type on a radio button after the value resets the value in IE6-9
// Reset value to default in case type is set after value during creation
var val = elem.value;
elem.setAttribute( "type", value );
if ( val ) {
elem.value = val;
}
return value;
}
}
}
},
propFix: {
tabindex: "tabIndex",
readonly: "readOnly",
"for": "htmlFor",
"class": "className",
maxlength: "maxLength",
cellspacing: "cellSpacing",
cellpadding: "cellPadding",
rowspan: "rowSpan",
colspan: "colSpan",
usemap: "useMap",
frameborder: "frameBorder",
contenteditable: "contentEditable"
},
prop: function( elem, name, value ) {
var ret, hooks, notxml,
nType = elem.nodeType;
// don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return;
}
notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
if ( notxml ) {
// Fix name and attach hooks
name = jQuery.propFix[ name ] || name;
hooks = jQuery.propHooks[ name ];
}
if ( value !== undefined ) {
if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret;
} else {
return ( elem[ name ] = value );
}
} else {
if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
return ret;
} else {
return elem[ name ];
}
}
},
propHooks: {
tabIndex: {
get: function( elem ) {
// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
var attributeNode = elem.getAttributeNode("tabindex");
return attributeNode && attributeNode.specified ?
parseInt( attributeNode.value, 10 ) :
rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
0 :
undefined;
}
}
}
});
// Hook for boolean attributes
boolHook = {
get: function( elem, name ) {
var
// Use .prop to determine if this attribute is understood as boolean
prop = jQuery.prop( elem, name ),
// Fetch it accordingly
attr = typeof prop === "boolean" && elem.getAttribute( name ),
detail = typeof prop === "boolean" ?
getSetInput && getSetAttribute ?
attr != null :
// oldIE fabricates an empty string for missing boolean attributes
// and conflates checked/selected into attroperties
ruseDefault.test( name ) ?
elem[ jQuery.camelCase( "default-" + name ) ] :
!!attr :
// fetch an attribute node for properties not recognized as boolean
elem.getAttributeNode( name );
return detail && detail.value !== false ?
name.toLowerCase() :
undefined;
},
set: function( elem, value, name ) {
if ( value === false ) {
// Remove boolean attributes when set to false
jQuery.removeAttr( elem, name );
} else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
// IE<8 needs the *property* name
elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
// Use defaultChecked and defaultSelected for oldIE
} else {
elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
}
return name;
}
};
// fix oldIE value attroperty
if ( !getSetInput || !getSetAttribute ) {
jQuery.attrHooks.value = {
get: function( elem, name ) {
var ret = elem.getAttributeNode( name );
return jQuery.nodeName( elem, "input" ) ?
// Ignore the value *property* by using defaultValue
elem.defaultValue :
ret && ret.specified ? ret.value : undefined;
},
set: function( elem, value, name ) {
if ( jQuery.nodeName( elem, "input" ) ) {
// Does not return so that setAttribute is also used
elem.defaultValue = value;
} else {
// Use nodeHook if defined (#1954); otherwise setAttribute is fine
return nodeHook && nodeHook.set( elem, value, name );
}
}
};
}
// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !getSetAttribute ) {
// Use this for any attribute in IE6/7
// This fixes almost every IE6/7 issue
nodeHook = jQuery.valHooks.button = {
get: function( elem, name ) {
var ret = elem.getAttributeNode( name );
return ret && ( name === "id" || name === "name" || name === "coords" ? ret.value !== "" : ret.specified ) ?
ret.value :
undefined;
},
set: function( elem, value, name ) {
// Set the existing or create a new attribute node
var ret = elem.getAttributeNode( name );
if ( !ret ) {
elem.setAttributeNode(
(ret = elem.ownerDocument.createAttribute( name ))
);
}
ret.value = value += "";
// Break association with cloned elements by also using setAttribute (#9646)
return name === "value" || value === elem.getAttribute( name ) ?
value :
undefined;
}
};
// Set contenteditable to false on removals(#10429)
// Setting to empty string throws an error as an invalid value
jQuery.attrHooks.contenteditable = {
get: nodeHook.get,
set: function( elem, value, name ) {
nodeHook.set( elem, value === "" ? false : value, name );
}
};
// Set width and height to auto instead of 0 on empty string( Bug #8150 )
// This is for removals
jQuery.each([ "width", "height" ], function( i, name ) {
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
set: function( elem, value ) {
if ( value === "" ) {
elem.setAttribute( name, "auto" );
return value;
}
}
});
});
}
// Some attributes require a special call on IE
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
if ( !jQuery.support.hrefNormalized ) {
jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
get: function( elem ) {
var ret = elem.getAttribute( name, 2 );
return ret == null ? undefined : ret;
}
});
});
// href/src property should get the full normalized URL (#10299/#12915)
jQuery.each([ "href", "src" ], function( i, name ) {
jQuery.propHooks[ name ] = {
get: function( elem ) {
return elem.getAttribute( name, 4 );
}
};
});
}
if ( !jQuery.support.style ) {
jQuery.attrHooks.style = {
get: function( elem ) {
// Return undefined in the case of empty string
// Note: IE uppercases css property names, but if we were to .toLowerCase()
// .cssText, that would destroy case senstitivity in URL's, like in "background"
return elem.style.cssText || undefined;
},
set: function( elem, value ) {
return ( elem.style.cssText = value + "" );
}
};
}
// Safari mis-reports the default selected property of an option
// Accessing the parent's selectedIndex property fixes it
if ( !jQuery.support.optSelected ) {
jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
get: function( elem ) {
var parent = elem.parentNode;
if ( parent ) {
parent.selectedIndex;
// Make sure that it also works with optgroups, see #5701
if ( parent.parentNode ) {
parent.parentNode.selectedIndex;
}
}
return null;
}
});
}
// IE6/7 call enctype encoding
if ( !jQuery.support.enctype ) {
jQuery.propFix.enctype = "encoding";
}
// Radios and checkboxes getter/setter
if ( !jQuery.support.checkOn ) {
jQuery.each([ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = {
get: function( elem ) {
// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
return elem.getAttribute("value") === null ? "on" : elem.value;
}
};
});
}
jQuery.each([ "radio", "checkbox" ], function() {
jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
set: function( elem, value ) {
if ( jQuery.isArray( value ) ) {
return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
}
}
});
});
var rformElems = /^(?:input|select|textarea)$/i,
rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
function returnTrue() {
return true;
}
function returnFalse() {
return false;
}
/*
* Helper functions for managing events -- not part of the public interface.
* Props to Dean Edwards' addEvent library for many of the ideas.
*/
jQuery.event = {
global: {},
add: function( elem, types, handler, data, selector ) {
var tmp, events, t, handleObjIn,
special, eventHandle, handleObj,
handlers, type, namespaces, origType,
elemData = jQuery._data( elem );
// Don't attach events to noData or text/comment nodes (but allow plain objects)
if ( !elemData ) {
return;
}
// Caller can pass in an object of custom data in lieu of the handler
if ( handler.handler ) {
handleObjIn = handler;
handler = handleObjIn.handler;
selector = handleObjIn.selector;
}
// Make sure that the handler has a unique ID, used to find/remove it later
if ( !handler.guid ) {
handler.guid = jQuery.guid++;
}
// Init the element's event structure and main handler, if this is the first
if ( !(events = elemData.events) ) {
events = elemData.events = {};
}
if ( !(eventHandle = elemData.handle) ) {
eventHandle = elemData.handle = function( e ) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
undefined;
};
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
eventHandle.elem = elem;
}
// Handle multiple events separated by a space
// jQuery(...).bind("mouseover mouseout", fn);
types = ( types || "" ).match( core_rnotwhite ) || [""];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || [];
type = origType = tmp[1];
namespaces = ( tmp[2] || "" ).split( "." ).sort();
// If event changes its type, use the special event handlers for the changed type
special = jQuery.event.special[ type ] || {};
// If selector defined, determine special event api type, otherwise given type
type = ( selector ? special.delegateType : special.bindType ) || type;
// Update special based on newly reset type
special = jQuery.event.special[ type ] || {};
// handleObj is passed to all event handlers
handleObj = jQuery.extend({
type: type,
origType: origType,
data: data,
handler: handler,
guid: handler.guid,
selector: selector,
needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join(".")
}, handleObjIn );
// Init the event handler queue if we're the first
if ( !(handlers = events[ type ]) ) {
handlers = events[ type ] = [];
handlers.delegateCount = 0;
// Only use addEventListener/attachEvent if the special events handler returns false
if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
// Bind the global event handler to the element
if ( elem.addEventListener ) {
elem.addEventListener( type, eventHandle, false );
} else if ( elem.attachEvent ) {
elem.attachEvent( "on" + type, eventHandle );
}
}
}
if ( special.add ) {
special.add.call( elem, handleObj );
if ( !handleObj.handler.guid ) {
handleObj.handler.guid = handler.guid;
}
}
// Add to the element's handler list, delegates in front
if ( selector ) {
handlers.splice( handlers.delegateCount++, 0, handleObj );
} else {
handlers.push( handleObj );
}
// Keep track of which events have ever been used, for event optimization
jQuery.event.global[ type ] = true;
}
// Nullify elem to prevent memory leaks in IE
elem = null;
},
// Detach an event or set of events from an element
remove: function( elem, types, handler, selector, mappedTypes ) {
var j, handleObj, tmp,
origCount, t, events,
special, handlers, type,
namespaces, origType,
elemData = jQuery.hasData( elem ) && jQuery._data( elem );
if ( !elemData || !(events = elemData.events) ) {
return;
}
// Once for each type.namespace in types; type may be omitted
types = ( types || "" ).match( core_rnotwhite ) || [""];
t = types.length;
while ( t-- ) {
tmp = rtypenamespace.exec( types[t] ) || [];
type = origType = tmp[1];
namespaces = ( tmp[2] || "" ).split( "." ).sort();
// Unbind all events (on this namespace, if provided) for the element
if ( !type ) {
for ( type in events ) {
jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
}
continue;
}
special = jQuery.event.special[ type ] || {};
type = ( selector ? special.delegateType : special.bindType ) || type;
handlers = events[ type ] || [];
tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
// Remove matching events
origCount = j = handlers.length;
while ( j-- ) {
handleObj = handlers[ j ];
if ( ( mappedTypes || origType === handleObj.origType ) &&
( !handler || handler.guid === handleObj.guid ) &&
( !tmp || tmp.test( handleObj.namespace ) ) &&
( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
handlers.splice( j, 1 );
if ( handleObj.selector ) {
handlers.delegateCount--;
}
if ( special.remove ) {
special.remove.call( elem, handleObj );
}
}
}
// Remove generic event handler if we removed something and no more handlers exist
// (avoids potential for endless recursion during removal of special event handlers)
if ( origCount && !handlers.length ) {
if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
jQuery.removeEvent( elem, type, elemData.handle );
}
delete events[ type ];
}
}
// Remove the expando if it's no longer used
if ( jQuery.isEmptyObject( events ) ) {
delete elemData.handle;
// removeData also checks for emptiness and clears the expando if empty
// so use it instead of delete
jQuery._removeData( elem, "events" );
}
},
trigger: function( event, data, elem, onlyHandlers ) {
var handle, ontype, cur,
bubbleType, special, tmp, i,
eventPath = [ elem || document ],
type = core_hasOwn.call( event, "type" ) ? event.type : event,
namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
cur = tmp = elem = elem || document;
// Don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
// focus/blur morphs to focusin/out; ensure we're not firing them right now
if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
return;
}
if ( type.indexOf(".") >= 0 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split(".");
type = namespaces.shift();
namespaces.sort();
}
ontype = type.indexOf(":") < 0 && "on" + type;
// Caller can pass in a jQuery.Event object, Object, or just an event type string
event = event[ jQuery.expando ] ?
event :
new jQuery.Event( type, typeof event === "object" && event );
event.isTrigger = true;
event.namespace = namespaces.join(".");
event.namespace_re = event.namespace ?
new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
null;
// Clean up the event in case it is being reused
event.result = undefined;
if ( !event.target ) {
event.target = elem;
}
// Clone any incoming data and prepend the event, creating the handler arg list
data = data == null ?
[ event ] :
jQuery.makeArray( data, [ event ] );
// Allow special events to draw outside the lines
special = jQuery.event.special[ type ] || {};
if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
return;
}
// Determine event propagation path in advance, per W3C events spec (#9951)
// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
bubbleType = special.delegateType || type;
if ( !rfocusMorph.test( bubbleType + type ) ) {
cur = cur.parentNode;
}
for ( ; cur; cur = cur.parentNode ) {
eventPath.push( cur );
tmp = cur;
}
// Only add window if we got to document (e.g., not plain obj or detached DOM)
if ( tmp === (elem.ownerDocument || document) ) {
eventPath.push( tmp.defaultView || tmp.parentWindow || window );
}
}
// Fire handlers on the event path
i = 0;
while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
event.type = i > 1 ?
bubbleType :
special.bindType || type;
// jQuery handler
handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
if ( handle ) {
handle.apply( cur, data );
}
// Native handler
handle = ontype && cur[ ontype ];
if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
event.preventDefault();
}
}
event.type = type;
// If nobody prevented the default action, do it now
if ( !onlyHandlers && !event.isDefaultPrevented() ) {
if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
// Call a native DOM method on the target with the same name name as the event.
// Can't use an .isFunction() check here because IE6/7 fails that test.
// Don't do default actions on window, that's where global variables be (#6170)
if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
// Don't re-trigger an onFOO event when we call its FOO() method
tmp = elem[ ontype ];
if ( tmp ) {
elem[ ontype ] = null;
}
// Prevent re-triggering of the same event, since we already bubbled it above
jQuery.event.triggered = type;
try {
elem[ type ]();
} catch ( e ) {
// IE<9 dies on focus/blur to hidden element (#1486,#12518)
// only reproducible on winXP IE8 native, not IE9 in IE8 mode
}
jQuery.event.triggered = undefined;
if ( tmp ) {
elem[ ontype ] = tmp;
}
}
}
}
return event.result;
},
dispatch: function( event ) {
// Make a writable jQuery.Event from the native event object
event = jQuery.event.fix( event );
var i, ret, handleObj, matched, j,
handlerQueue = [],
args = core_slice.call( arguments ),
handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[0] = event;
event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired
if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
return;
}
// Determine handlers
handlerQueue = jQuery.event.handlers.call( this, event, handlers );
// Run delegates first; they may want to stop propagation beneath us
i = 0;
while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
event.currentTarget = matched.elem;
j = 0;
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
event.handleObj = handleObj;
event.data = handleObj.data;
ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
.apply( matched.elem, args );
if ( ret !== undefined ) {
if ( (event.result = ret) === false ) {
event.preventDefault();
event.stopPropagation();
}
}
}
}
}
// Call the postDispatch hook for the mapped type
if ( special.postDispatch ) {
special.postDispatch.call( this, event );
}
return event.result;
},
handlers: function( event, handlers ) {
var sel, handleObj, matches, i,
handlerQueue = [],
delegateCount = handlers.delegateCount,
cur = event.target;
// Find delegate handlers
// Black-hole SVG