jquery.yoxview 2.21.js
À propos du fichier
- Type de fichier
- Fichier JS de 85 Ko (text/plain)
- Confidentialité
- Fichier public, envoyé le 2 février 2012 à 22:53, depuis l'adresse IP 78.249.x.x (France)
- Sécurité
- Ne contient aucun Virus ou Malware connus - Dernière vérification: 2 jours
- Statistiques
- La présente page de téléchargement a été vue 986 fois depuis l'envoi du fichier
- Page de téléchargement
-
Aperçu du fichier
/*!
* jquery.yoxview
* jQuery image gallery viewer
* http://yoxigen.com/yoxview
*
* Copyright (c) 2010 Yossi Kolesnicov
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Date: 13th November, 2010
* Version : 2.2
*/
(function($){
if (!$.yoxview)
$.yoxview = new YoxView();
$.fn.yoxview = function(options)
{
if (this.length != 0)
{
if ($.yoxview[options])
return $.yoxview[options].apply(this, Array.prototype.slice.call(arguments, 1));
else if (typeof options === 'object' || !options)
$.yoxview.init(this, options);
else
$.error( 'Method ' + options + ' does not exist on YoxView.' );
}
return this;
};
$(Yox.getTopWindow()).unload(function(){
if ($.yoxview)
{
$.yoxview.unload();
delete $.yoxview;
}
});
function YoxView()
{
var yoxviewPath = (yoxviewPath || Yox.getPath(/(.*\/)jquery\.yoxview/i));
var defaults = {
autoHideInfo: true, // If false, the info bar (with image count and title) is always displayed.
autoPlay: false, // If true, slideshow mode starts when the popup opens
backgroundColor: "#000000",
backgroundOpacity: 0.8,
buttonsFadeTime: 300, // The time, in milliseconds, it takes the buttons to fade in/out when hovered on. Set to 0 to force the Prev/Next buttons to remain visible.
cacheBuffer: 5, // The number of images to cache after the current image (directional, depends on the current viewing direction)
cacheImagesInBackground: true, // If true, full-size images are cached even while the gallery hasn't been opened yet.
controlsInitialFadeTime: 1500, // The time, in milliseconds, it takes the menu and prev/next buttons to fade in and out when the popup is opened.
controlsInitialDisplayTime: 1000, // The time, in milliseconds, to display the menu and prev/next buttons when the popup is opened. Set to 0 to not display them by default
dataFolder: yoxviewPath + "data/",
defaultDimensions: { // Default sizes for different types of media, in case none was specified
flash: { width: 720, height: 560 },
iframe: { width: 1024 }
},
flashVideoPlayer: "jwplayer", // The default player for Flash video files
imagesFolder: yoxviewPath + "images/",
infoBackColor: "#000000",
infoBackOpacity: 0.5,
isRTL : false, // Switch direction. For RTL languages such as Hebrew or Arabic, for example.
lang: "en", // The language for texts. The relevant language file should exist in the lang folder.
langFolder: yoxviewPath + "lang/",
loopPlay: true, // If true, slideshow play starts over after the last image
playDelay: 3000, // Time in milliseconds to display each image
popupMargin: 20, // the minimum margin between the popup and the window
popupResizeTime: 600, // The time in milliseconds it takes to make the resize transition from one image to the next.
renderButtons: true, // Set to false if you want to implement your own Next/Prev buttons, using the API.
renderMenu: true, // Set to false if you want to implement you own menu (Play/Help/Close).
showBarsOnOpen: true, // If true, displays the top (help) bar and bottom (info) bar momentarily when the popup opens.
showButtonsOnOpen: true, // If true, displays the Prev/Next buttons momentarily when the popup opens.
showDescription: true, // Set to false to not show the description text (the title will still show).
textLinksSelector: ".yoxviewLink", // A jQuery selector to identify links that are not thumbnails, which YoxView should try to open.
thumbnailsOptions: { thumbnailsClass: "yoxview_thumbnail" }, // Options for thumbnails generated by YoxView
titleAttribute: "title", // The attribute of an img used for the text in YoxView. Use either "title" or "alt".
titleDisplayDuration: 2000 // The time in ms to display the image's title, after which it fades out.
};
this.infoButtons = {};
this.isOpen = false;
this.yoxviewSkins = {};
var ajaxLoader,
cacheVars = {},
cacheImg = new Image(),
countDisplay,
ctlButtons, // next and prev buttons
elementCount = 0,
currentItemIndex = 0,
currentLanguage = {},
currentMaxSize = {},
currentOptionsSetIndex,
currentViewIndex = 0,
currentViewIsInFrame = window != window.parent,
disableInfo = false,
flashDefaults = { wmode: "transparent", width: "100%", height: "100%", allowfullscreen: "true", allowscriptaccess: "true", hasVersion: 9 },
firstImage = true,
frameOffset,
helpPanel,
hideInfoTimeout,
hideMenuTimeout,
image1, image2,
images,
imagesCount = 0,
infoPanel,
infoPanelContent,
infoPanelLink,
infoPanelMinHeight = 30,
infoPanelWrap,
infoPinLink,
infoPinLinkImg,
infoText,
isFirstPanel = false,
isImageMode = true,
isPlaying = false,
isResizing = false,
itemVar,
loadedViews = [],
loaderTimeout,
loading = false,
mediaButtonsSize = {width: 100, height: 100},
mediaLoader,
mediaPanelClass = "yoxview_mediaPanel",
mediaProviderUrls = {
vimeo: "http://vimeo.com/api/oembed.json",
myspace: "http://vids.myspace.com/index.cfm?fuseaction=oembed"
},
menuHidePosition = -42,
menuPanel,
nextBtn,
notification,
onOpenCallback,
options, optionsSets = [],
panel1, panel2,
playBtnText,
popup,
popupBackground,
popupMargins = {}, defaultPopupMargins = {},
popupTimeout,
popupWindow = $(Yox.getTopWindow()), // the window in which to create the YoxView popup (for use with frames)
popupWrap,
prevBtn,
resumePlay = false,
sprites,
tempImg = new Image(),
thumbnail,
thumbnailImg,
thumbnailPos,
thumbnailProperties,
windowDimensions,
yoxviewLanguages = {},
keyCodes = {
40: 'DOWN',
35: 'END',
13: 'ENTER',
36: 'HOME',
37: 'LEFT',
39: 'RIGHT',
32: 'SPACE',
38: 'UP',
72: 'h',
27: 'ESCAPE'
},
keyMappings;
// If the given options object is equal to any in the options set, return the existing set's index. Otherwise, add the new set and return its index:
function initOptionsSet(options){
var optionsSetsLength = optionsSets.length;
for(var i=0; i<optionsSetsLength; i++)
{
if (Yox.compare(optionsSets[i], options))
return i;
}
optionsSets.push(options);
return optionsSetsLength;
}
function getAllowedThumbnailsSelector(options){
return "a:has(img)" + (options.textLinksSelector !== null ? ",a" + options.textLinksSelector : "");
}
this.init = function(views, opt)
{
var options = $.extend(true, {}, defaults, opt);
var optionsSetIndex;
if (optionsSets.length == 0)
{
optionsSets.push(options);
optionsSetIndex = 0;
}
else
optionsSetIndex = opt ? initOptionsSet(options) : null;
function loadContents(){
views.each(function(i, view){
view = $(view);
var viewIndex = loadedViews.length;
view.data("yoxview", {
viewIndex : viewIndex,
cacheVars: {cachedImagesCount: 0, cacheDirectionForward: true, cacheBufferLastIndex: null, currentCacheImg: 0 }
});
var viewData = view.data("yoxview");
if (optionsSetIndex)
viewData.optionsSet = optionsSetIndex;
options.allowedImageUrls = [Yox.Regex.image];
if (options.allowedUrls)
options.allowedImageUrls = options.allowedImageUrls.concat(options.allowedUrls);
// First, get image data from thumbnails:
var isSingleLink = view[0].tagName == "A";
var thumbnails = isSingleLink ? view : view.find(getAllowedThumbnailsSelector(options));
var viewImages = [];
var imageIndex = 0;
thumbnails.each(function(i, thumbnail){
var $thumbnail = $(thumbnail);
var imageData = getImageDataFromThumbnail($thumbnail, options);
if (imageData)
{
viewImages.push(imageData);
if (isSingleLink)
$thumbnail.data("yoxview").imageIndex = imageIndex;
else
$thumbnail.data("yoxview", { imageIndex: imageIndex, viewIndex: viewIndex });
imageIndex++;
}
});
if (options.images)
viewImages = viewImages.concat(options.images);
if (options.dataSource)
{
Yox.dataSources[options.dataSource].getImagesData(options, function(data){
viewImages = viewImages.concat(data.images);
viewData.images = viewImages;
if (data.title && options.thumbnailsOptions && options.thumbnailsOptions.setHeader){
$(options.thumbnailsOptions.headerElement || "<h2>", {
html: data.title,
className: options.thumbnailsOptions.headerClass
}).appendTo(view);
}
var thumbnailsData = data.isGroup
? [$.extend(data, {
media: {
title: data.title + " (" + data.images.length + " images)",
alt: data.title
}
})]
: data.images;
createThumbnails(view, options, isSingleLink ? null : thumbnailsData, !data.createGroups ? null :
function(e){
var viewData = $(e.currentTarget).data("yoxview");
var thumbnail = $(e.currentTarget);
var thumbnailData = thumbnail.data("yoxthumbs");
if (!viewData.imagesAreSet)
{
thumbnail.css("cursor", "wait");
var newOptions = $.extend({}, options);
if (!newOptions.dataSourceOptions)
newOptions.dataSourceOptions = thumbnailData;
else
$.extend(newOptions.dataSourceOptions, thumbnailData);
Yox.dataSources[options.dataSource].getImagesData(newOptions, function(data){
viewData.images = data.images;
viewData.imagesAreSet = true;
thumbnail.css("cursor", "");
$.yoxview.open(viewData.viewIndex);
});
}
else
{
$.yoxview.open(viewData.viewIndex);
}
}
);
if (data.createGroups)
$.each(view.yoxthumbs("thumbnails"), function(i, thumbnail){
thumbnail.data("yoxview", {viewIndex: ++viewIndex});
loadedViews.push($(thumbnail));
});
else
{
$.each(view.yoxthumbs("thumbnails"), function(i, thumbnail){
var currentViewIndex = imageIndex + i;
var thumbImg = thumbnail.children("img");
if (thumbImg.length == 0)
thumbImg = thumbnail;
viewImages[currentViewIndex].thumbnailImg = thumbImg;
thumbnail.data("yoxview", {imageIndex: i, viewIndex: viewIndex });
});
}
if (!$.yoxview.firstViewWithImages && data.images.length > 0)
{
$.yoxview.firstViewWithImages = view;
if (options.cacheImagesInBackground)
$.yoxview.startCache();
}
});
}
else
{
viewData.images = viewImages;
createThumbnails(view, options);
}
loadedViews.push(view);
if (!$.yoxview.firstViewWithImages && viewData.images && viewData.images != 0)
{
$.yoxview.firstViewWithImages = view;
loadViewImages(view);
if(options.cacheImagesInBackground && imagesCount != 0)
{
calculateCacheBuffer();
cacheImages(0);
}
}
});
}
// Init external files then proceed:
loadLanguage(options.lang, function(langData){
loadSkin(options, function(skin){
if (skin && skin.options)
$.extend(options, skin.options);
Yox.loadDataSource(options, loadContents);
});
});
}
function loadSkin(options, callback)
{
if (options.skin)
{
var skinName = options.skin;
if (!$.yoxview.yoxviewSkins[skinName])
{
var skinUrl = yoxviewPath + "skins/" + skinName + "/yoxview." + skinName;
$.ajax({
url: skinUrl + ".js",
dataType: "script",
success: function(data)
{
if ($.yoxview.yoxviewSkins[skinName].css !== false)
Yox.addStylesheet(top.document, skinUrl + ".css");
if (callback)
callback($.yoxview.yoxviewSkins[skinName]);
},
error: function(){
alert("Error loading skin file " + skinUrl + ".js");
}
});
}
else if (callback)
callback($.yoxview.yoxviewSkins[skinName]);
}
else if (callback)
callback($.yoxview.yoxviewSkins[skinName]);
}
// Load the language file if not already loaded:
function loadLanguage(langName, callback)
{
if (!yoxviewLanguages[langName])
{
yoxviewLanguages[langName] = {};
var langUrl = yoxviewPath + "lang/" + langName + ".js";
$.ajax({
url : langUrl,
async : false,
dataType : "json",
success: function(data){
yoxviewLanguages[langName] = data;
if (callback)
callback(data);
},
error: function(){
alert("Error loading language file " + langUrl);
}
});
}
else if (callback)
callback(yoxviewLanguages[langName]);
}
function resetPopup()
{
if (popup)
{
popupWrap.remove();
popup = undefined;
prevBtn = undefined;
nextBtn = undefined;
image1 = undefined;
image2 = undefined;
panel1 = undefined;
panel2 = undefined;
currentItemIndex = 0;
$.yoxview.infoButtons = {};
}
createPopup();
}
function loadViewImages(view)
{
var viewData = view.data("yoxview");
if (!images || currentViewIndex != viewData.viewIndex)
{
if (!viewData.cacheVars)
viewData.cacheVars = {cachedImagesCount: 0, cacheDirectionForward: true, cacheBufferLastIndex: null, currentCacheImg: 0 };
images = viewData.images;
imagesCount = images.length;
currentViewIndex = viewData.viewIndex;
var isResetPopup = false;
var changeOptions = !currentOptionsSetIndex || (currentOptionsSetIndex != viewData.optionsSet);
if (changeOptions)
{
currentOptionsSetIndex = viewData.optionsSet || 0;
options = optionsSets[currentOptionsSetIndex];
isResetPopup = true;
}
if (options.onLoadImages)
options.onLoadImages({ images: images, viewData: viewData });
else if ((prevBtn && imagesCount == 1) || (popup && !prevBtn && imagesCount > 0))
isResetPopup = true;
if (isResetPopup)
resetPopup();
cacheVars = viewData.cacheVars;
}
}
function getElementDimensions(type, originalDimensions, options)
{
var size = originalDimensions && (originalDimensions.width || originalDimensions.height)
? { width: parseInt(originalDimensions.width), height: parseInt(originalDimensions.height) }
: options.defaultDimensions[type];
if (isNaN(size.width))
size.width = null;
if (isNaN(size.height))
size.height = null;
return size;
}
var supportedTypes = {
image: function(thumbnail, thumbnailHref, thumbImg, options)
{
var imageData = null;
for(var i=0; i<options.allowedImageUrls.length && !imageData; i++)
{
if (thumbnailHref.match(options.allowedImageUrls[i]))
{
imageData = {
src: thumbnail.attr("href"),
title: thumbImg.attr(options.titleAttribute),
alt: thumbImg.attr("alt")
};
}
}
return imageData;
},
flash: function(thumbnail, thumbnailHref, thumbImg, options)
{
var imageData = null;
var matchFlash = thumbnailHref.match(Yox.Regex.flash);
var matchFlashVideo = matchFlash ? null : thumbnailHref.match(Yox.Regex.flashvideo);
if (matchFlash || matchFlashVideo)
{
var urlData = Yox.getUrlData(thumbnailHref);
var elementSize = getElementDimensions("flash", urlData.queryFields, options);
if (urlData.queryFields)
{
delete urlData.queryFields.width;
delete urlData.queryFields.height;
}
var flashPanel = $("<div>", {
className: "yoxview_element",
html: "<div class='yoxview_error'>Please install the latest version of the <a href='http://www.adobe.com/go/getflashplayer' target='_blank'>Flash player</a> to view content</div>"
});
var flashData = matchFlashVideo
? Yox.flashVideoPlayers[options.flashVideoPlayer](
options.flashVideoPlayerPath, urlData.path,
(urlData.queryFields && urlData.queryFields.image) ? urlData.queryFields.image :
thumbImg[0].nodeName == "IMG" ? thumbImg.attr("src") : null,
thumbImg.attr(options.titleAttribute))
: urlData.queryFields || {};
if (matchFlash)
flashData.swf = urlData.path;
$.extend(flashData, flashDefaults);
flashPanel.flash(flashData);
imageData = {
"element": flashPanel,
title: thumbImg.attr(options.titleAttribute)
};
$.extend(imageData, elementSize);
}
return imageData;
},
ooembed: function(thumbnail, thumbnailHref, thumbImg, options)
{
var imageData = null;
for(videoProvider in Yox.Regex.video)
{
if (thumbnailHref.match(Yox.Regex.video[videoProvider]))
{
imageData = {
provider: videoProvider,
url: thumbnailHref
};
break;
}
}
return imageData;
},
inline: function(thumbnail, thumbnailHref, thumbImg, options)
{
if (!options.allowInternalLinks)
return null;
var imageData = null;
var urlData = Yox.getUrlData(thumbnailHref);
if (urlData && urlData.anchor)
{
var element = $("#" + urlData.anchor);
if (element.length != 0)
{
var elementSize = { width: parseInt(element.css("width")), height: parseInt(element.css("height")) };
element.css({
position: "absolute",
top: 0,
left: 0,
width: "100%",
height: "100%",
display: "block"
});
imageData = {
type: "inlineElement",
"element": element,
title: element.attr("title")
};
var padding = {
horizontal: parseInt(element.css("padding-right")) + parseInt(element.css("padding-left")),
vertical: parseInt(element.css("padding-top")) + parseInt(element.css("padding-bottom"))
};
elementSize.width = isNaN(elementSize.width) ? null : elementSize.width + padding.horizontal;
elementSize.height = isNaN(elementSize.height) ? null : elementSize.height + padding.vertical;
$.extend(imageData, elementSize);
if (padding.horizontal != 0 || padding.vertical != 0)
imageData.padding = padding;
element.remove();
}
}
return imageData;
},
iframe: function(thumbnail, thumbnailHref, thumbImg, options)
{
var imageData = null;
var thumbnailTarget = thumbnail.attr("target");
if (thumbnailTarget && thumbnailTarget == "yoxview")
{
var urlData = Yox.getUrlData(thumbnailHref);
if (urlData && urlData.path)
{
var iframeSize = getElementDimensions("iframe", urlData.queryFields, options);
if (urlData.queryFields)
{
delete urlData.queryFields.width;
delete urlData.queryFields.height;
}
imageData = {
"element": $("<iframe>", {
src: Yox.urlDataToPath(urlData),
className: "yoxview_element"
}),
title: thumbImg.attr("title"),
frameborder: "0"
}
$.extend(imageData, iframeSize);
}
}
return imageData;
}
};
function getImageDataFromThumbnail(thumbnail, options)
{
var imageData = {};
var thumbnailHref = thumbnail.attr("href");
var thumbImg = thumbnail.children("img:first");
if (thumbImg.length == 0)
thumbImg = thumbnail;
var imageData = {};
for (supportedType in supportedTypes)
{
var media = supportedTypes[supportedType](thumbnail, thumbnailHref, thumbImg, options);
if (media)
{
$.extend(media, {
contentType: supportedType,
elementId: elementCount++
});
imageData.media = media;
break;
}
}
if (!imageData.media)
return null;
imageData.thumbnailImg = thumbImg;
return imageData;
}
function createThumbnails(view, options, additionalImages, onClick)
{
var clickHandler = function(e){
var data = $(e.currentTarget).data("yoxview");
if (!data || data.imageIndex === null)
return true;
else
{
e.preventDefault();
$.yoxview.open($(e.liveFired || e.currentTarget).data("yoxview").viewIndex, data.imageIndex);
}
};
if (view[0].tagName == "A")
view.bind("click.yoxview", clickHandler);
else if (!additionalImages)
view.delegate(getAllowedThumbnailsSelector(options), "click.yoxview", clickHandler);
else
view.yoxthumbs($.extend({
images: additionalImages,
enableOnlyMedia: false,
onClick: onClick || function(e){
e.preventDefault();
if (options.thumbnailsOptions && options.thumbnailsOptions.onClick)
options.thumbnailsOptions.onClick(
$(e.currentTarget).data("yoxview").imageIndex,
$(e.currentTarget),
$(e.liveFired).data("yoxview").viewIndex);
else
$.yoxview.open($(e.liveFired || e.currentTarget).data("yoxview").viewIndex,
$(e.currentTarget).data("yoxview").imageIndex);
return false;
}
}, options.thumbnailsOptions));
}
function setThumbnail(setToPopupImage)
{
var currentView = loadedViews[currentViewIndex];
thumbnail = currentView[0].tagName == "A"
? currentView
: images[currentItemIndex].thumbnailImg;
if (!thumbnail || thumbnail.length == 0)
thumbnail = images[0].thumbnailImg;
if (thumbnail)
{
var thumbnailSrc = thumbnail.attr("src");
if (setToPopupImage && image1 && thumbnailSrc)
image1.attr("src", thumbnailSrc);
if (currentViewIsInFrame && !frameOffset && window.name)
frameOffset = $(top.document).find("[name='" + window.name + "']").offset();
thumbnailPos = thumbnail.offset();
thumbnailProperties = {
width: thumbnail.width(),
height: thumbnail.height(),
top: Math.round(thumbnailPos.top - popupWindow.scrollTop() + (frameOffset ? frameOffset.top : 0)),
left: Math.round(thumbnailPos.left + (frameOffset ? frameOffset.left : 0))
};
}
}
// Opens the viewer popup.
// Arguments:
// viewIndex: The 0-based index of the view to open, in case there are multiple instances of YoxView on the same page. Default is 0.
// imageIndex: The 0-based index of the image to open, in the specified view. Default is 0.
// callback: A function to call after the gallery has opened.
this.open = function(viewIndex, initialItemIndex, callback)
{
var isJquery = this instanceof jQuery;
if (isJquery)
{
if (viewIndex && typeof(viewIndex) == 'function')
callback = viewIndex;
var itemData = this.data("yoxview");
viewIndex = itemData.viewIndex;
initialItemIndex = itemData.imageIndex;
}
else if (typeof(viewIndex) == 'function')
{
callback = viewIndex;
viewIndex = initialItemIndex = 0;
}
else if (typeof(initialItemIndex) == 'function')
{
callback = initialItemIndex;
initialItemIndex = 0;
}
viewIndex = viewIndex || 0;
initialItemIndex = initialItemIndex || 0;
$(document).bind('keydown.yoxview', catchPress);
loadViewImages(loadedViews[viewIndex]);
if (!popup && imagesCount != 0)
createPopup();
$.yoxview.selectImage(initialItemIndex);
popupWrap.stop().css({ opacity: 0, display: "block" }).animate({ opacity: 1}, "slow", function(){ popupWrap.css("opacity", "") });
if(options.cacheImagesInBackground)
cacheImages(initialItemIndex);
if (callback)
onOpenCallback = callback;
return isJquery ? this : false;
}
this.selectImage = function(itemIndex)
{
$.yoxview.currentImage = images[itemIndex];
currentItemIndex = itemIndex;
setThumbnail(true);
thumbnail.blur();
panel1.css({
"z-index" : "1",
width : "100%",
height : "100%"
});
panel2.css({
"display" : "none",
"z-index" : "2"
});
firstImage = true;
popup.css(thumbnailProperties);
this.select(itemIndex);
}
this.refresh = function()
{
resumePlay = isPlaying;
if (isPlaying)
stopPlay();
setImage(currentItemIndex);
if (resumePlay)
startPlay();
};
//var optionsRequiringUpdate =
this.options = function(opt, value){
if (!opt)
return this;
if (value && typeof(opt) === "string"){
var pName = opt;
opt = {};
opt[pName] = value;
}
if (this instanceof jQuery)
{
var yoxviewData = this.data("yoxview");
if (yoxviewData)
{
$.extend(optionsSets[yoxviewData.optionsSet || 0], opt);
this.yoxview("update");
}
return this;
}
else
{
$.each(optionsSets, function(i, optionsSet){
$.extend(optionsSet, opt);
});
$.yoxview.update();
}
};
// Displays the specified image and shows the (optionally) specified button. Use when the viewer is open.
// Arguments:
// imageIndex: The 0-based index of the image to display.
// pressedBtn: a jQuery element of a button to display momentarily in the viewer.
// For example, if the image has been selected by pressing the Next button
// on the keyboard, specify the Next button. If no button should be display, leave blank.
this.select = function(itemIndex, pressedBtn, viewIndex)
{
if (typeof pressedBtn === "number")
{
viewIndex = pressedBtn;
pressedBtn = undefined;
}
viewIndex = viewIndex || 0;
if (!isResizing)
{
if (itemIndex < 0)
{
itemIndex = imagesCount - 1;
if (options.onEnd)
{
options.onEnd();
return;
}
}
else if (itemIndex == imagesCount)
{
itemIndex = 0;
if (options.onEnd)
{
options.onEnd();
return;
}
}
if (!isPlaying && pressedBtn)
flicker(pressedBtn);
$.yoxview.currentImage = images[itemIndex];
currentItemIndex = itemIndex;
setImage(currentItemIndex);
// Set the cache buffer, if required:
calculateCacheBuffer();
// Handle event onSelect:
if (options.onSelect)
options.onSelect(itemIndex, images[itemIndex]);
}
}
this.prev = function(continuePlaying)
{
cacheVars.cacheDirectionForward = false;
this.select(currentItemIndex - 1, prevBtn);
if (isPlaying && continuePlaying !== true)
stopPlay();
}
this.next = function(continuePlaying)
{
cacheVars.cacheDirectionForward = true;
this.select(currentItemIndex + 1, nextBtn);
if (isPlaying && continuePlaying !== true)
stopPlay();
}
this.first = function()
{
if (!options.disableNotifications)
longFlicker("first");
this.select(0);
if (isPlaying)
stopPlay();
};
this.last = function()
{
if (!options.disableNotifications)
longFlicker("last");
this.select(imagesCount - 1);
if (isPlaying)
stopPlay();
};
this.setDefaults = function(options){
$.extend(true, defaults, options);
};
this.play = function()
{
if (!this.isOpen || imagesCount == 1)
return;
cacheVars.cacheDirectionForward = true;
if (!isPlaying)
{
if (!options.disableNotifications)
longFlicker("play");
startPlay();
}
else
{
if (!options.disableNotifications)
longFlicker("pause");
stopPlay();
}
};
function flicker(button)
{
if (button.css("opacity") == 0)
button.stop().animate({ opacity : 0 }, options.buttonsFadeTime, fadeOut(button));
}
function longFlicker(notificationName)
{
notification.css("background-position", sprites.getBackgroundPosition("notifications", notificationName));
notification.stop().fadeIn(options.buttonsFadeTime, function(){
$(this).delay(500)
.fadeOut(options.buttonsFadeTime);
});
}
function fadeIn(button)
{
$(button).stop().animate({ opacity : 0 }, options.buttonsFadeTime);
}
function fadeOut(button)
{
$(button).stop().animate({ opacity : 0.5 }, options.buttonsFadeTime);
}
this.close = function()
{
if (!this.isOpen)
return;
this.closeHelp();
setThumbnail(false);
resizePopup(thumbnailProperties, function(){ $.yoxview.isOpen = false; });
hideMenuPanel();
if (infoPanel)
hideInfoPanel(function(){
infoText.html("");
});
newPanel.animate({
width: thumbnailProperties.width,
height: thumbnailProperties.height
}, options.popupResizeTime, function(){
newPanel.css("opacity", 1);
});
popupWrap.stop().fadeOut(1000);
if (isPlaying)
stopPlay();
swipePanels();
if (options.onClose)
options.onClose();
$(document).unbind("keydown.yoxview");
isResizing = false;
}
this.help = function()
{
if (!this.isOpen)
return;
if (helpPanel.css("display") == "none")
helpPanel.css("display", "block").stop().animate({ opacity : 0.8 }, options.buttonsFadeTime);
Partager le fichier jquery.yoxview-2.21.js sur le Web et les réseaux sociaux:
Télécharger le fichier jquery.yoxview-2.21.js
Télécharger jquery.yoxview-2.21.js