...
), \r\nwhen option $ThumbnailNavigatorOptions.$AutoCenter set to 0, it should be specified in pixel (like
)");
// }
// }
//});
$Jssor$.$CssWidth(_SlidesContainer, slidesContainerWidth);
$Jssor$.$CssHeight(_SlidesContainer, (Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 75));
var slideItemElmts = [];
$Jssor$.$Each(items, function (item, index) {
var navigationItem = new NavigationItem(item, index);
var navigationItemWrapper = navigationItem.$Wrapper;
var columnIndex = Math.floor(index / _Lanes);
var laneIndex = index % _Lanes;
$Jssor$.$CssLeft(navigationItemWrapper, (_PrototypeWidth + _SpacingX) * laneIndex * (1 - horizontal));
$Jssor$.$CssTop(navigationItemWrapper, (_PrototypeHeight + _SpacingY) * laneIndex * horizontal);
if (!slideItemElmts[columnIndex]) {
slideItemElmts[columnIndex] = $Jssor$.$CreateDiv();
$Jssor$.$AppendChild(_SlidesContainer, slideItemElmts[columnIndex]);
}
$Jssor$.$AppendChild(slideItemElmts[columnIndex], navigationItemWrapper);
_NavigationItems.push(navigationItem);
});
var thumbnailSliderOptions = $Jssor$.$Extend({
$AutoPlay: false,
$NaviQuitDrag: false,
$SlideWidth: slideWidth,
$SlideHeight: slideHeight,
$SlideSpacing: _SpacingX * horizontal + _SpacingY * (1 - horizontal),
$MinDragOffsetToSlide: 12,
$SlideDuration: 200,
$PauseOnHover: 1,
$PlayOrientation: _Options.$Orientation,
$DragOrientation: _Options.$DisableDrag ? 0 : _Options.$Orientation
}, _Options);
_Slider = new $JssorSlider$(elmt, thumbnailSliderOptions);
_Initialized = true;
}
//_Self.$TriggerEvent($JssorNavigatorEvents$.$RESET);
};
//JssorThumbnailNavigator Constructor
{
_Self.$Options = _Options = $Jssor$.$Extend({
$SpacingX: 3,
$SpacingY: 3,
$DisplayPieces: 1,
$Orientation: 1,
$AutoCenter: 3,
$ActionMode: 1
}, options);
//Sodo statement for development time intellisence only
$JssorDebug$.$Execute(function () {
_Options = $Jssor$.$Extend({
$Lanes: undefined,
$Width: undefined,
$Height: undefined
}, _Options);
});
_Width = $Jssor$.$CssWidth(elmt);
_Height = $Jssor$.$CssHeight(elmt);
$JssorDebug$.$Execute(function () {
if (!_Width)
$JssorDebug$.$Fail("width of 'thumbnavigator' container not specified.");
if (!_Height)
$JssorDebug$.$Fail("height of 'thumbnavigator' container not specified.");
});
_SlidesContainer = $Jssor$.$FindChild(elmt, "slides", true);
_ThumbnailPrototype = $Jssor$.$FindChild(_SlidesContainer, "prototype");
$JssorDebug$.$Execute(function () {
if (!_ThumbnailPrototype)
$JssorDebug$.$Fail("prototype of 'thumbnavigator' not defined.");
});
_PrototypeWidth = $Jssor$.$CssWidth(_ThumbnailPrototype);
_PrototypeHeight = $Jssor$.$CssHeight(_ThumbnailPrototype);
$Jssor$.$RemoveChild(_SlidesContainer, _ThumbnailPrototype);
_Lanes = _Options.$Lanes || 1;
_SpacingX = _Options.$SpacingX;
_SpacingY = _Options.$SpacingY;
_DisplayPieces = _Options.$DisplayPieces;
}
};
//$JssorCaptionSliderBase$
function $JssorCaptionSliderBase$() {
$JssorAnimator$.call(this, 0, 0);
this.$Revert = $Jssor$.$EmptyFunction;
}
var $JssorCaptionSlider$ = window.$JssorCaptionSlider$ = function (container, captionSlideOptions, playIn) {
$JssorDebug$.$Execute(function () {
if (!captionSlideOptions.$CaptionTransitions) {
$JssorDebug$.$Error("'$CaptionSliderOptions' option error, '$CaptionSliderOptions.$CaptionTransitions' not specified.");
}
//else if (!$Jssor$.$IsArray(captionSlideOptions.$CaptionTransitions)) {
// $JssorDebug$.$Error("'$CaptionSliderOptions' option error, '$CaptionSliderOptions.$CaptionTransitions' is not an array.");
//}
});
var _Self = this;
var _ImmediateOutCaptionHanger;
var _PlayMode = playIn ? captionSlideOptions.$PlayInMode : captionSlideOptions.$PlayOutMode;
var _CaptionTransitions = captionSlideOptions.$CaptionTransitions;
var _CaptionTuningFetcher = { $Transition: "t", $Delay: "d", $Duration: "du", x: "x", y: "y", $Rotate: "r", $Zoom: "z", $Opacity: "f", $BeginTime: "b" };
var _CaptionTuningTransfer = {
$Default: function (value, tuningValue) {
if (!isNaN(tuningValue.$Value))
value = tuningValue.$Value;
else
value *= tuningValue.$Percent;
return value;
},
$Opacity: function (value, tuningValue) {
return this.$Default(value - 1, tuningValue);
}
};
_CaptionTuningTransfer.$Zoom = _CaptionTuningTransfer.$Opacity;
$JssorAnimator$.call(_Self, 0, 0);
function GetCaptionItems(element, level) {
var itemsToPlay = [];
var lastTransitionName;
var namedTransitions = [];
var namedTransitionOrders = [];
//$JssorDebug$.$Execute(function () {
// var debugInfoElement = $Jssor$.$GetElement("debugInfo");
// if (debugInfoElement && playIn) {
// var text = $Jssor.$InnerHtml(debugInfoElement) + "
";
// $Jssor$.$InnerHtml(debugInfoElement, text);
// }
//});
function FetchRawTransition(captionElmt, index) {
var rawTransition = {};
$Jssor$.$Each(_CaptionTuningFetcher, function (fetchAttribute, fetchProperty) {
var attributeValue = $Jssor$.$AttributeEx(captionElmt, fetchAttribute + (index || ""));
if (attributeValue) {
var propertyValue = {};
if (fetchAttribute == "t") {
//if (($Jssor$.$IsBrowserChrome() || $Jssor$.$IsBrowserSafari() || $Jssor$.$IsBrowserFireFox()) && attributeValue == "*") {
// attributeValue = Math.floor(Math.random() * captionSlideOptions.$CaptionTransitions.length);
// $Jssor$.$Attribute(captionElmt, fetchAttribute + (index || ""), attributeValue);
//}
propertyValue.$Value = attributeValue;
}
else if (attributeValue.indexOf("%") + 1)
propertyValue.$Percent = $Jssor$.$ParseFloat(attributeValue) / 100;
else
propertyValue.$Value = $Jssor$.$ParseFloat(attributeValue);
rawTransition[fetchProperty] = propertyValue;
}
});
return rawTransition;
}
function GetRandomTransition() {
return _CaptionTransitions[Math.floor(Math.random() * _CaptionTransitions.length)];
}
function EvaluateCaptionTransition(transitionName) {
var transition;
if (transitionName == "*") {
transition = GetRandomTransition();
}
else if (transitionName) {
//indexed transition allowed, just the same as named transition
var tempTransition = _CaptionTransitions[$Jssor$.$ParseInt(transitionName)] || _CaptionTransitions[transitionName];
if ($Jssor$.$IsArray(tempTransition)) {
if (transitionName != lastTransitionName) {
lastTransitionName = transitionName;
namedTransitionOrders[transitionName] = 0;
namedTransitions[transitionName] = tempTransition[Math.floor(Math.random() * tempTransition.length)];
}
else {
namedTransitionOrders[transitionName]++;
}
tempTransition = namedTransitions[transitionName];
if ($Jssor$.$IsArray(tempTransition)) {
tempTransition = tempTransition.length && tempTransition[namedTransitionOrders[transitionName] % tempTransition.length];
if ($Jssor$.$IsArray(tempTransition)) {
//got transition from array level 3, random for all captions
tempTransition = tempTransition[Math.floor(Math.random() * tempTransition.length)];
}
//else {
// //got transition from array level 2, in sequence for all adjacent captions with same name specified
// transition = tempTransition;
//}
}
//else {
// //got transition from array level 1, random but same for all adjacent captions with same name specified
// transition = tempTransition;
//}
}
//else {
// //got transition directly from a simple transition object
// transition = tempTransition;
//}
transition = tempTransition;
if ($Jssor$.$IsString(transition))
transition = EvaluateCaptionTransition(transition);
}
return transition;
}
var captionElmts = $Jssor$.$Children(element);
$Jssor$.$Each(captionElmts, function (captionElmt, i) {
var transitionsWithTuning = [];
transitionsWithTuning.$Elmt = captionElmt;
var isCaption = $Jssor$.$AttributeEx(captionElmt, "u") == "caption";
$Jssor$.$Each(playIn ? [0, 3] : [2], function (j, k) {
if (isCaption) {
var transition;
var rawTransition;
if (j != 2 || !$Jssor$.$AttributeEx(captionElmt, "t3")) {
rawTransition = FetchRawTransition(captionElmt, j);
if (j == 2 && !rawTransition.$Transition) {
rawTransition.$Delay = rawTransition.$Delay || { $Value: 0 };
rawTransition = $Jssor$.$Extend(FetchRawTransition(captionElmt, 0), rawTransition);
}
}
if (rawTransition && rawTransition.$Transition) {
transition = EvaluateCaptionTransition(rawTransition.$Transition.$Value);
if (transition) {
//var transitionWithTuning = $Jssor$.$Extend({ $Delay: 0, $ScaleHorizontal: 1, $ScaleVertical: 1 }, transition);
var transitionWithTuning = $Jssor$.$Extend({ $Delay: 0 }, transition);
$Jssor$.$Each(rawTransition, function (rawPropertyValue, propertyName) {
var tuningPropertyValue = (_CaptionTuningTransfer[propertyName] || _CaptionTuningTransfer.$Default).apply(_CaptionTuningTransfer, [transitionWithTuning[propertyName], rawTransition[propertyName]]);
if (!isNaN(tuningPropertyValue))
transitionWithTuning[propertyName] = tuningPropertyValue;
});
if (!k) {
if (rawTransition.$BeginTime)
transitionWithTuning.$BeginTime = rawTransition.$BeginTime.$Value || 0;
else if ((_PlayMode) & 2)
transitionWithTuning.$BeginTime = 0;
}
}
}
transitionsWithTuning.push(transitionWithTuning);
}
if ((level % 2) && !k) {
//transitionsWithTuning.$Children = GetCaptionItems(captionElmt, lastTransitionName, [].concat(namedTransitions), [].concat(namedTransitionOrders), level + 1);
transitionsWithTuning.$Children = GetCaptionItems(captionElmt, level + 1);
}
});
itemsToPlay.push(transitionsWithTuning);
});
return itemsToPlay;
}
function CreateAnimator(item, transition, immediateOut) {
var animatorOptions = {
$Easing: transition.$Easing,
$Round: transition.$Round,
$During: transition.$During,
$Reverse: playIn && !immediateOut,
$Optimize: true
};
$JssorDebug$.$Execute(function () {
animatorOptions.$CaptionAnimator = true;
});
var captionItem = item;
var captionParent = $Jssor$.$ParentNode(item);
var captionItemWidth = $Jssor$.$CssWidth(captionItem);
var captionItemHeight = $Jssor$.$CssHeight(captionItem);
var captionParentWidth = $Jssor$.$CssWidth(captionParent);
var captionParentHeight = $Jssor$.$CssHeight(captionParent);
var toStyles = {};
var fromStyles = {};
var scaleClip = transition.$ScaleClip || 1;
//Opacity
if (transition.$Opacity) {
toStyles.$Opacity = 2 - transition.$Opacity;
}
animatorOptions.$OriginalWidth = captionItemWidth;
animatorOptions.$OriginalHeight = captionItemHeight;
//Transform
if (transition.$Zoom || transition.$Rotate) {
toStyles.$Zoom = transition.$Zoom ? transition.$Zoom - 1 : 1;
if ($Jssor$.$IsBrowserIe9Earlier() || $Jssor$.$IsBrowserOpera())
toStyles.$Zoom = Math.min(toStyles.$Zoom, 2);
fromStyles.$Zoom = 1;
var rotate = transition.$Rotate || 0;
toStyles.$Rotate = rotate * 360;
fromStyles.$Rotate = 0;
}
//Clip
else if (transition.$Clip) {
var fromStyleClip = { $Top: 0, $Right: captionItemWidth, $Bottom: captionItemHeight, $Left: 0 };
var toStyleClip = $Jssor$.$Extend({}, fromStyleClip);
var blockOffset = toStyleClip.$Offset = {};
var topBenchmark = transition.$Clip & 4;
var bottomBenchmark = transition.$Clip & 8;
var leftBenchmark = transition.$Clip & 1;
var rightBenchmark = transition.$Clip & 2;
if (topBenchmark && bottomBenchmark) {
blockOffset.$Top = captionItemHeight / 2 * scaleClip;
blockOffset.$Bottom = -blockOffset.$Top;
}
else if (topBenchmark)
blockOffset.$Bottom = -captionItemHeight * scaleClip;
else if (bottomBenchmark)
blockOffset.$Top = captionItemHeight * scaleClip;
if (leftBenchmark && rightBenchmark) {
blockOffset.$Left = captionItemWidth / 2 * scaleClip;
blockOffset.$Right = -blockOffset.$Left;
}
else if (leftBenchmark)
blockOffset.$Right = -captionItemWidth * scaleClip;
else if (rightBenchmark)
blockOffset.$Left = captionItemWidth * scaleClip;
animatorOptions.$Move = transition.$Move;
toStyles.$Clip = toStyleClip;
fromStyles.$Clip = fromStyleClip;
}
//Fly
{
var toLeft = 0;
var toTop = 0;
if (transition.x)
toLeft -= captionParentWidth * transition.x;
if (transition.y)
toTop -= captionParentHeight * transition.y;
if (toLeft || toTop || animatorOptions.$Move) {
toStyles.$Left = toLeft + $Jssor$.$CssLeft(captionItem);
toStyles.$Top = toTop + $Jssor$.$CssTop(captionItem);
}
}
//duration
var duration = transition.$Duration;
fromStyles = $Jssor$.$Extend(fromStyles, $Jssor$.$GetStyles(captionItem, toStyles));
animatorOptions.$Setter = $Jssor$.$StyleSetterEx();
return new $JssorAnimator$(transition.$Delay, duration, animatorOptions, captionItem, fromStyles, toStyles);
}
function CreateAnimators(streamLineLength, captionItems) {
$Jssor$.$Each(captionItems, function (captionItem, i) {
$JssorDebug$.$Execute(function () {
if (captionItem.length) {
var top = $Jssor$.$CssTop(captionItem.$Elmt);
var left = $Jssor$.$CssLeft(captionItem.$Elmt);
var width = $Jssor$.$CssWidth(captionItem.$Elmt);
var height = $Jssor$.$CssHeight(captionItem.$Elmt);
var error = null;
if (isNaN(top))
error = "Style 'top' for caption not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
else if (isNaN(left))
error = "Style 'left' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
else if (isNaN(width))
error = "Style 'width' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
else if (isNaN(height))
error = "Style 'height' not specified. Please always specify caption like 'position: absolute; top: ...px; left: ...px; width: ...px; height: ...px;'.";
if (error)
$JssorDebug$.$Error("Caption " + (i + 1) + " definition error, \r\n" + error + "\r\n" + captionItem.$Elmt.outerHTML);
}
});
var animator;
var captionElmt = captionItem.$Elmt;
var transition = captionItem[0];
var transition3 = captionItem[1];
if (transition) {
animator = CreateAnimator(captionElmt, transition);
streamLineLength = animator.$Locate(transition.$BeginTime == undefined ? streamLineLength : transition.$BeginTime, 1);
}
streamLineLength = CreateAnimators(streamLineLength, captionItem.$Children);
if (transition3) {
var animator3 = CreateAnimator(captionElmt, transition3, 1);
animator3.$Locate(streamLineLength, 1);
_Self.$Combine(animator3);
_ImmediateOutCaptionHanger.$Combine(animator3);
}
if (animator)
_Self.$Combine(animator);
});
return streamLineLength;
}
_Self.$Revert = function () {
_Self.$GoToPosition(_Self.$GetPosition_OuterEnd() * (playIn || 0));
_ImmediateOutCaptionHanger.$GoToBegin();
};
//Constructor
{
_ImmediateOutCaptionHanger = new $JssorAnimator$(0, 0);
//var streamLineLength = 0;
//var captionItems = GetCaptionItems(container, null, [], [], 1);
CreateAnimators(0, _PlayMode ? GetCaptionItems(container, 1) : []);
}
};
//Event Table
//$EVT_CLICK = 21; function(slideIndex[, event])
//$EVT_DRAG_START = 22; function(position[, virtualPosition, event])
//$EVT_DRAG_END = 23; function(position, startPosition[, virtualPosition, virtualStartPosition, event])
//$EVT_SWIPE_START = 24; function(position[, virtualPosition])
//$EVT_SWIPE_END = 25; function(position[, virtualPosition])
//$EVT_LOAD_START = 26; function(slideIndex)
//$EVT_LOAD_END = 27; function(slideIndex)
//$EVT_POSITION_CHANGE = 202; function(position, fromPosition[, virtualPosition, virtualFromPosition])
//$EVT_PARK = 203; function(slideIndex, fromIndex)
//$EVT_PROGRESS_CHANGE = 208; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
//$EVT_STATE_CHANGE = 209; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
//$EVT_ROLLBACK_START = 210; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
//$EVT_ROLLBACK_END = 211; function(slideIndex, progress[, progressBegin, idleBegin, idleEnd, progressEnd])
//$EVT_SLIDESHOW_START = 206; function(slideIndex[, progressBegin, slideshowBegin, slideshowEnd, progressEnd])
//$EVT_SLIDESHOW_END = 207; function(slideIndex[, progressBegin, slideshowBegin, slideshowEnd, progressEnd])
//http://www.jssor.com/development/reference-api.html