(function($){
'use scrict';
function analyzeAmounts($recipe){
var servings=parseInt($recipe.find('.detail-item-adjustable-servings').data('original-servings') );
if(servings > 0){
$recipe.find('.ingredients-list .wpzoom-rcb-ingredient-amount, .ingredients-list .wpzoom-rcb-ingredient-alt-amount').each(function(){
if(0===$(this).find('.wpzoom-rcb-adjustable').length){
var amount=$(this),
amountValue=amount.text();
amount.html('<span class="wpzoom-rcb-adjustable">' + amountValue + '</span>');
}})
$recipe.find('.wpzoom-rcb-adjustable').each(function(){
if('undefined'==typeof $(this).data('original-amount') ){
var amount=parseAmount($(this).text());
amount /=servings;
var _amount=amount;
$(this)
.data('original-amount', $(this).text())
.data('per-one-serving', _amount);
}})
}}
function updateServingSize($recipe){
var $servingsElement=$recipe.find('.detail-item-adjustable-servings'),
servings=parseInt($servingsElement.data('servings') ),
originalServings=$servingsElement.data('original-servings');
var $adjustableAmount=$recipe.find('.wpzoom-rcb-adjustable');
if(0==$adjustableAmount.length){
analyzeAmounts($recipe);
$adjustableAmount=$recipe.find('.wpzoom-rcb-adjustable');
}
$adjustableAmount.each(function(){
var amountElement=$(this);
var numberPattern=/^-?\d+([.,]\d+)?$/;
var is_fraction=$(this).parent().data('fraction');
if(numberPattern.test(amountElement.text())||is_fraction){
if(servings==originalServings){
amountElement.text(amountElement.data('original-amount') );
}else{
var amount=parseFloat(amountElement.data('per-one-serving') ) * servings;
var is_fraction=$(this).parent().data('fraction');
var fraction_value=$(this).parent().data('fraction-value');
if(is_fraction){
var integerPart=parseInt(amount);
var leftAmount=amount - integerPart;
if(0 >=integerPart){
integerPart='';
}else{
integerPart='<div style="display:inline-block;">' + integerPart + '</div>';
}
if(0!==leftAmount&&leftAmount % 0.25==0){
var _amount=simplify(leftAmount.toString().substring(2), Math.pow(10, decimalPlaces(leftAmount) ));
_amount=integerPart + _amount.numerator + '&frasl;' + _amount.denominator;
}else{
_amount=roundNumber(amount);
}}else{
var _amount=amount;
}
if(is_fraction){
amountElement.html(_amount);
}else{
amountElement.text(roundNumber(_amount) );
}}
}});
$(document).find('.btn-print-link, .wp-block-wpzoom-recipe-card-block-print-recipe').data('servings-size', servings);
}
function initTextField(){
$('<div class="adjustable-quantity-nav"><div class="adjustable-quantity-button adjustable-quantity-up">+</div><div class="adjustable-quantity-button adjustable-quantity-down">-</div></div>').insertAfter('.adjustable-quantity input');
$(document).on('input change', 'input.detail-item-adjustable-servings', function(){
var $servingsElement=$(this),
servings=$servingsElement.val(),
$recipe=$servingsElement.parents('.wpzoom-recipe-card-block-adjustable-servings');
$servingsElement.data('servings', servings);
updateServingSize($recipe);
})
}
function parseAmount(amount){
if(undefined===amount){
return;
}
amount=amount.replace('⁄', '/');
amount=amount.replace(',', '.');
if(-1===amount.indexOf('/') ){
return amount;
}
var fractionsRegex=/(\u00BC|\u00BD|\u00BE|\u2150|\u2151|\u2152|\u2153|\u2154|\u2155|\u2156|\u2157|\u2158|\u2159|\u215A|\u215B|\u215C|\u215D|\u215E)/;
var fractionsMap={
'\u00BC': ' 1/4', '\u00BD': ' 1/2', '\u00BE': ' 3/4', '\u2150': ' 1/7',
'\u2151': ' 1/9', '\u2152': ' 1/10', '\u2153': ' 1/3', '\u2154': ' 2/3',
'\u2155': ' 1/5', '\u2156': ' 2/5', '\u2157': ' 3/5', '\u2158': ' 4/5',
'\u2159': ' 1/6', '\u215A': ' 5/6', '\u215B': ' 1/8', '\u215C': ' 3/8',
'\u215D': ' 5/8', '\u215E': ' 7/8'
};
amount=amount.replace(fractionsRegex, function(m, vf){
return fractionsMap[vf];
});
amount=amount.trim();
var parts=amount.split(' ');
var result=false;
if(''!==amount){
result=0;
for(var i=0; i < parts.length; i++){
if(''!==parts[i].trim()){
var divisionParts=parts[i].split('/', 2);
var partAmount=parseFloat(divisionParts[0]);
if(undefined!==divisionParts[1]){
var divisor=parseFloat(divisionParts[1]);
if(0!==divisor){
partAmount /=divisor;
}}
result +=partAmount;
}}
}
return result;
}
function buttonQuantityIncrementers(){
$('.adjustable-quantity').each(function(){
var $spinner=$(this),
$input=$spinner.find('input[type="number"]'),
$btnUp=$spinner.find('.adjustable-quantity-up'),
$btnDown=$spinner.find('.adjustable-quantity-down'),
min=$input.attr('min'),
max=$input.attr('max');
$btnUp.on('click', function(){
var oldValue=parseFloat($input.val());
if(oldValue >=max){
var newVal=oldValue;
}else{
var newVal=oldValue + 1;
}
$spinner.find("input").val(newVal);
$spinner.find("input").trigger("change");
$spinner.parent().find(".only-print-visible").text(newVal);
});
$btnDown.on('click', function(){
var oldValue=parseFloat($input.val());
if(oldValue <=min){
var newVal=oldValue;
}else{
var newVal=oldValue - 1;
}
$spinner.find("input").val(newVal);
$spinner.find("input").trigger("change");
$spinner.parent().find(".only-print-visible").text(newVal);
});
});
}
function identifyFractions(){
$recipe=$('.wpzoom-recipe-card-block-adjustable-servings');
$recipe.find('.ingredients-list .wpzoom-rcb-ingredient-amount, .ingredients-list .wpzoom-rcb-ingredient-alt-amount').each(function(){
if(0===$(this).find('.wpzoom-rcb-adjustable').length){
var amount=$(this),
amountValue=amount.text();
}
if(-1!==amountValue.indexOf('/') ){
$(this).attr('data-fraction', true);
$(this).attr('data-fraction-value', amountValue);
amountValue=amountValue.replace('/', '&frasl;');
$(this).html(amountValue);
}})
}
function roundNumber(value){
var with2Decimals=value.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0];
return with2Decimals;
}
function decimalPlaces(number){
var numberOfPlaces=0;
var foundFirstZero=false;
var foundDot=false;
for (var i=0; i < number.toString().length; i++){
if(number.toString()[i]=="0"&&!foundFirstZero){
foundFirstZero=true;
}else if(number.toString()[i]=="."){
foundDot=true;
}else if(number.toString()[i].match(/\d+/g)!=null&&foundDot){
numberOfPlaces++;
}}
return numberOfPlaces;
}
function simplify(numerator, denominator){
var fraction={
numerator: numerator,
denominator: denominator
};
for(var i=fraction.denominator; i > 0; i--){
if(fraction.denominator % i==0&&fraction.numerator % i==0){
fraction.numerator /=i;
fraction.denominator /=i;
}}
return fraction;
}
window.setPrintServings=(servings)=> {
if(servings > 0){
var $recipe=$(document).find('.wpzoom-rcb-print');
$('.detail-item-adjustable-servings').each(function(){
$(this).text(servings);
$(this).data('servings', servings);
$(this).parents('.detail-item').find('p.detail-item-value.only-print-visible').text(servings);
});
updateServingSize($recipe);
}}
window.showPrintAltUnit=(value)=> {
if(value){
var $recipe=$(document).find('.wpzoom-rcb-print');
$recipe.find('.wpzoom-rcb-ingredient').toggle();
$recipe.find('.wpzoom-rcb-alt-ingredient').toggle();
}}
$(function (){
$('.detail-item-adjustable-servings').each(function(){
var $servingsElement=$(this),
servings=$servingsElement.val();
if(servings > 0){
$servingsElement.data('servings', servings);
$servingsElement.data('original-servings', servings);
initTextField();
identifyFractions();
}});
buttonQuantityIncrementers();
})
})(jQuery);
!function(t,e){"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,(function(){function t(){}let e=t.prototype;return e.on=function(t,e){if(!t||!e)return this;let i=this._events=this._events||{},s=i[t]=i[t]||[];return s.includes(e)||s.push(e),this},e.once=function(t,e){if(!t||!e)return this;this.on(t,e);let i=this._onceEvents=this._onceEvents||{};return(i[t]=i[t]||{})[e]=!0,this},e.off=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;let s=i.indexOf(e);return-1!=s&&i.splice(s,1),this},e.emitEvent=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;i=i.slice(0),e=e||[];let s=this._onceEvents&&this._onceEvents[t];for(let n of i){s&&s[n]&&(this.off(t,n),delete s[n]),n.apply(this,e)}return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t})),
function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}("undefined"!=typeof window?window:this,(function(t,e){let i=t.jQuery,s=t.console;function n(t,e,o){if(!(this instanceof n))return new n(t,e,o);let r=t;var h;("string"==typeof t&&(r=document.querySelectorAll(t)),r)?(this.elements=(h=r,Array.isArray(h)?h:"object"==typeof h&&"number"==typeof h.length?[...h]:[h]),this.options={},"function"==typeof e?o=e:Object.assign(this.options,e),o&&this.on("always",o),this.getImages(),i&&(this.jqDeferred=new i.Deferred),setTimeout(this.check.bind(this))):s.error(`Bad element for imagesLoaded ${r||t}`)}n.prototype=Object.create(e.prototype),n.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)};const o=[1,9,11];n.prototype.addElementImages=function(t){"IMG"===t.nodeName&&this.addImage(t),!0===this.options.background&&this.addElementBackgroundImages(t);let{nodeType:e}=t;if(!e||!o.includes(e))return;let i=t.querySelectorAll("img");for(let t of i)this.addImage(t);if("string"==typeof this.options.background){let e=t.querySelectorAll(this.options.background);for(let t of e)this.addElementBackgroundImages(t)}};const r=/url\((['"])?(.*?)\1\)/gi;function h(t){this.img=t}function d(t,e){this.url=t,this.element=e,this.img=new Image}return n.prototype.addElementBackgroundImages=function(t){let e=getComputedStyle(t);if(!e)return;let i=r.exec(e.backgroundImage);for(;null!==i;){let s=i&&i[2];s&&this.addBackground(s,t),i=r.exec(e.backgroundImage)}},n.prototype.addImage=function(t){let e=new h(t);this.images.push(e)},n.prototype.addBackground=function(t,e){let i=new d(t,e);this.images.push(i)},n.prototype.check=function(){if(this.progressedCount=0,this.hasAnyBroken=!1,!this.images.length)return void this.complete();let t=(t,e,i)=>{setTimeout((()=>{this.progress(t,e,i)}))};this.images.forEach((function(e){e.once("progress",t),e.check()}))},n.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount===this.images.length&&this.complete(),this.options.debug&&s&&s.log(`progress: ${i}`,t,e)},n.prototype.complete=function(){let t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){let t=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[t](this)}},h.prototype=Object.create(e.prototype),h.prototype.check=function(){this.getIsImageComplete()?this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.img.crossOrigin&&(this.proxyImage.crossOrigin=this.img.crossOrigin),this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.proxyImage.src=this.img.currentSrc||this.img.src)},h.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},h.prototype.confirm=function(t,e){this.isLoaded=t;let{parentNode:i}=this.img,s="PICTURE"===i.nodeName?i:this.img;this.emitEvent("progress",[this,s,e])},h.prototype.handleEvent=function(t){let e="on"+t.type;this[e]&&this[e](t)},h.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},h.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},h.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},d.prototype=Object.create(h.prototype),d.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url,this.getIsImageComplete()&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},d.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},d.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},n.makeJQueryPlugin=function(e){(e=e||t.jQuery)&&(i=e,i.fn.imagesLoaded=function(t,e){return new n(this,t,e).jqDeferred.promise(i(this))})},n.makeJQueryPlugin(),n}));
(function($, wpzoomRecipeCard){
'use scrict';
const W=$(window);
const B=$('body');
const D=$(document);
let $gridGallery=$('.direction-step-gallery'),
$grid=$('.direction-step-gallery-grid[data-gallery-masonry-grid="true"]'),
desktopGridCol=$gridGallery.data('grid-columns'),
tabletGridCol=desktopGridCol > 2 ? 3:2,
mobileGridCol=2,
gridGutter=8;
const breakXLarge=1080;
const breakMobile=480;
function masonry(itemSelector, columnWidth){
$grid.imagesLoaded(function(){
$gridGallery.removeClass('is-loading');
$gridGallery.find('.direction-step-gallery-preloader').remove();
});
}
function rebuildMasonry(){
const columnWidth='.direction-step-gallery-item';
if(W.width() >=breakXLarge){
if(! $gridGallery.hasClass(`columns-${ desktopGridCol }`) ){
$gridGallery.removeClass(`columns-${ tabletGridCol } columns-${ mobileGridCol }`);
$gridGallery.addClass(`columns-${ desktopGridCol }`);
}}else if(W.width() < breakXLarge&&W.width() >=breakMobile){
if(! $gridGallery.hasClass(`columns-${ tabletGridCol }`) ){
$gridGallery.removeClass(`columns-${ desktopGridCol } columns-${ mobileGridCol }`);
$gridGallery.addClass(`columns-${ tabletGridCol }`);
}}else{
if(! $gridGallery.hasClass(`columns-${ mobileGridCol }`) ){
$gridGallery.removeClass(`columns-${ desktopGridCol } columns-${ tabletGridCol }`);
$gridGallery.addClass(`columns-${ mobileGridCol }`);
}}
masonry('.direction-step-gallery-item', columnWidth);
}
window.rebuildPrintMasonry=(print_window)=> {
let $gridGallery=$(document).find('.direction-step-gallery'),
$grid=$('.direction-step-gallery-grid[data-gallery-masonry-grid="true"]'),
gridCol=$gridGallery.data('grid-columns');
$gridGallery.removeClass('is-loading');
$gridGallery.find('.direction-step-gallery-preloader').remove();
setTimeout(function(){
print_window.print();
}, 500);
print_window.onfocus=function(){
setTimeout(function(){
print_window.close();
}, 500);
};};
W.on('resize load', function(){
rebuildMasonry();
});
$(function(){
rebuildMasonry();
});
}(jQuery, wpzoomRecipeCard) );
jQuery(function(){
const __slice=[].slice;
(function($, wpzoomRatingStars){
class WPZOOM_Rating_Star {
constructor($el, options){
let i,
_,
_ref,
_this=this;
this.$el=$el;
this.defaults={
rating: this.$el.parent().data('rating'),
rating_total: this.$el.parent().data('rating-total'),
recipe_id: this.$el.parent().data('recipe-id'),
user_rating: void 0,
numStars: 5,
change: function(e, value){ },
};
this.options=$.extend({}, this.defaults, options);
_ref=this.defaults;
for(i in _ref){
_=_ref[ i ];
if(this.$el.data(i)!=null){
this.options[ i ]=this.$el.data(i);
}}
this.$el
.next()
.find('small.wpzoom-rating-average')
.html(this.options.rating);
this.$el
.next()
.find('small.wpzoom-rating-total-votes')
.html(this.options.rating_total);
this.syncRating();
this.$el.on('mouseover.starrr', 'li', function(e){
return _this.syncRating(_this.$el.find('li').index(e.currentTarget) + 1
);
});
this.$el.on('mouseout.starrr', function(){
return _this.syncRating();
});
this.$el.on('click.starrr', 'li', function(e){
const element=$(this);
return _this.setRating(_this.$el.find('li').index(e.currentTarget) + 1,
element
);
});
this.$el.on('starrr:change', this.options.change);
}
setRating(rating, element){
if(element.parent().hasClass('wpzoom-recipe-user-rated') &&
parseInt(this.options.user_rating)===rating
){
return false;
}
let _this=this,
rating_avg=this.options.rating,
rating_total=this.options.rating_total,
recipe_id=this.options.recipe_id;
this.options.user_rating=rating;
const data={
action: 'wpzoom_user_vote_recipe',
rating: rating,
recipe_id: recipe_id,
security: wpzoomRatingStars.ajax_nonce,
};
element
.parents('.wpzoom-rating-stars-container')
.addClass('is-loading');
$.post(wpzoomRatingStars.ajaxurl, data, function(response){
const data=response.data;
if(response.success){
rating_avg=data.rating_avg;
rating_total=data.rating_total;
element.parent().next().find('small.wpzoom-rating-average').html(rating_avg);
element.parent().data('rating', rating_avg);
element.parent().next().find('small.wpzoom-rating-total-votes').html(rating_total);
element.parent().data('rating-total', rating_total);
element.parents('.wpzoom-rating-stars-container').removeClass('is-loading');
if(! element.parent().hasClass('wpzoom-recipe-user-rated') ){
element
.parent()
.addClass('wpzoom-recipe-user-rated');
}}else{
element.parents('.wpzoom-rating-stars-container').removeClass('is-loading');
element.parents('.wpzoom-rating-stars-container').attr('data-user-can-rate', '0');
element.parents('.wpzoom-rating-stars-container').find('.wpzoom-rating-stars-tooltip').html(data.message);
}}).done(function(response){
const data=response.data;
if(response.success){
_this.options.rating=data.rating_avg;
_this.options.rating_total=data.rating_total;
_this.syncRating();
return _this.$el.trigger('starrr:change', data.rating_avg);
}});
}
syncRating(rating){
let i, _i, _j, _ref;
if(rating){
rating=parseFloat(rating);
}else{
rating=parseFloat(this.options.rating);
}
this.$el
.find('li')
.removeClass('wpz-one-fourth-star')
.removeClass('wpz-one-half-star')
.removeClass('wpz-three-quarters-star');
let integer_average=Math.floor(rating),
float_average=rating - integer_average;
for(i=0, _ref=integer_average; i < _ref; i++){
this.$el
.find('li')
.eq(i)
.removeClass('wpz-empty-star')
.addClass('wpz-full-star');
}
if(float_average > 0){
if(0.05 < float_average&&0.35 >=float_average){
this.$el
.find('li')
.eq(integer_average)
.removeClass('wpz-empty-star')
.removeClass('wpz-full-star')
.addClass('wpz-one-fourth-star');
}
else if(0.35 < float_average&&0.6 > float_average){
this.$el
.find('li')
.eq(integer_average)
.removeClass('wpz-empty-star')
.removeClass('wpz-full-star')
.addClass('wpz-one-half-star');
}else if(0.6 < float_average&&0.75 >=float_average){
this.$el
.find('li')
.eq(integer_average)
.removeClass('wpz-empty-star')
.removeClass('wpz-full-star')
.addClass('wpz-three-quarters-star');
}else if(0.75 < float_average){
this.$el
.find('li')
.eq(integer_average)
.removeClass('wpz-empty-star')
.removeClass('wpz-full-star')
.addClass('wpz-full-star');
}}
if(rating&&rating < 5){
for (
_ref=Math.round(rating), i=_j=_ref;
_ref <=4 ? _j <=4:_j >=4;
i=_ref <=4 ? ++_j:--_j
){
this.$el
.find('li')
.eq(i)
.removeClass('wpz-full-star')
.addClass('wpz-empty-star');
}}
if(! rating){
return this.$el
.find('li')
.removeClass('wpz-full-star')
.addClass('wpz-empty-star');
}}
}
return $.fn.extend({
starrr: function(){
let args, option;
(option=arguments[ 0 ]),
(args=2 <=arguments.length ? __slice.call(arguments, 1):[]);
return this.each(function(){
let data;
data=$(this).data('star-rating');
if(! data){
$(this).data('star-rating',
(data=new WPZOOM_Rating_Star($(this), option) )
);
}
if(typeof option==='string'){
return data[ option ].apply(data, args);
}});
},
});
}(jQuery, wpzoomRatingStars) );
jQuery('ul.wpzoom-rating-stars').starrr();
});
(function($){
$(document).ready(function(){
$(document).on('click', 'a.gofollow', function(){
$.post(click_object.ajax_url, {'action':'adrotate_click','track':$(this).attr("data-track")});
});
});
}(jQuery));
(function (factory){
'use strict';
if(typeof define==='function'&&define.amd){
define(['./blueimp-helper'], factory);
}else{
window.blueimp=window.blueimp||{};
window.blueimp.Gallery=factory(
window.blueimp.helper||window.jQuery
);
}}(function ($){
'use strict';
function Gallery(list, options){
if(document.body.style.maxHeight===undefined){
return null;
}
if(!this||this.options!==Gallery.prototype.options){
return new Gallery(list, options);
}
if(!list||!list.length){
this.console.log('blueimp Gallery: No or empty list provided as first argument.',
list
);
return;
}
this.list=list;
this.num=list.length;
this.initOptions(options);
this.initialize();
}
$.extend(Gallery.prototype, {
options: {
container: '#blueimp-gallery',
slidesContainer: 'div',
titleElement: 'h3',
displayClass: 'blueimp-gallery-display',
controlsClass: 'blueimp-gallery-controls',
singleClass: 'blueimp-gallery-single',
leftEdgeClass: 'blueimp-gallery-left',
rightEdgeClass: 'blueimp-gallery-right',
playingClass: 'blueimp-gallery-playing',
slideClass: 'slide',
slideLoadingClass: 'slide-loading',
slideErrorClass: 'slide-error',
slideContentClass: 'slide-content',
toggleClass: 'toggle',
prevClass: 'prev',
nextClass: 'next',
closeClass: 'close',
playPauseClass: 'play-pause',
typeProperty: 'type',
titleProperty: 'title',
urlProperty: 'href',
displayTransition: true,
clearSlides: true,
stretchImages: false,
toggleControlsOnReturn: true,
toggleSlideshowOnSpace: true,
enableKeyboardNavigation: true,
closeOnEscape: true,
closeOnSlideClick: true,
closeOnSwipeUpOrDown: true,
emulateTouchEvents: true,
stopTouchEventsPropagation: false,
hidePageScrollbars: true,
disableScroll: true,
carousel: false,
continuous: true,
unloadElements: true,
startSlideshow: false,
slideshowInterval: 5000,
index: 0,
preloadRange: 2,
transitionSpeed: 400,
slideshowTransitionSpeed: undefined,
event: undefined,
onopen: undefined,
onopened: undefined,
onslide: undefined,
onslideend: undefined,
onslidecomplete: undefined,
onclose: undefined,
onclosed: undefined
},
carouselOptions: {
hidePageScrollbars: false,
toggleControlsOnReturn: false,
toggleSlideshowOnSpace: false,
enableKeyboardNavigation: false,
closeOnEscape: false,
closeOnSlideClick: false,
closeOnSwipeUpOrDown: false,
disableScroll: false,
startSlideshow: true
},
console: window.console&&typeof window.console.log==='function' ?
window.console :
{log: function (){}},
support: (function (element){
var support={
touch: window.ontouchstart!==undefined ||
(window.DocumentTouch&&document instanceof DocumentTouch)
},
transitions={
webkitTransition: {
end: 'webkitTransitionEnd',
prefix: '-webkit-'
},
MozTransition: {
end: 'transitionend',
prefix: '-moz-'
},
OTransition: {
end: 'otransitionend',
prefix: '-o-'
},
transition: {
end: 'transitionend',
prefix: ''
}},
elementTests=function (){
var transition=support.transition,
prop,
translateZ;
document.body.appendChild(element);
if(transition){
prop=transition.name.slice(0, -9) + 'ransform';
if(element.style[prop]!==undefined){
element.style[prop]='translateZ(0)';
translateZ=window.getComputedStyle(element)
.getPropertyValue(transition.prefix + 'transform');
support.transform={
prefix: transition.prefix,
name: prop,
translate: true,
translateZ: !!translateZ&&translateZ!=='none'
};}}
if(element.style.backgroundSize!==undefined){
support.backgroundSize={};
element.style.backgroundSize='contain';
support.backgroundSize.contain=window
.getComputedStyle(element)
.getPropertyValue('background-size')==='contain';
element.style.backgroundSize='cover';
support.backgroundSize.cover=window
.getComputedStyle(element)
.getPropertyValue('background-size')==='cover';
}
document.body.removeChild(element);
};
(function (support, transitions){
var prop;
for (prop in transitions){
if(transitions.hasOwnProperty(prop) &&
element.style[prop]!==undefined){
support.transition=transitions[prop];
support.transition.name=prop;
break;
}}
}(support, transitions));
if(document.body){
elementTests();
}else{
$(document).on('DOMContentLoaded', elementTests);
}
return support;
}(document.createElement('div'))),
requestAnimationFrame: window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame,
initialize: function (){
this.initStartIndex();
if(this.initWidget()===false){
return false;
}
this.initEventListeners();
this.onslide(this.index);
this.ontransitionend();
if(this.options.startSlideshow){
this.play();
}},
slide: function (to, speed){
window.clearTimeout(this.timeout);
var index=this.index,
direction,
naturalDirection,
diff;
if(index===to||this.num===1){
return;
}
if(!speed){
speed=this.options.transitionSpeed;
}
if(this.support.transition){
if(!this.options.continuous){
to=this.circle(to);
}
direction=Math.abs(index - to) / (index - to);
if(this.options.continuous){
naturalDirection=direction;
direction=-this.positions[this.circle(to)] / this.slideWidth;
if(direction!==naturalDirection){
to=-direction * this.num + to;
}}
diff=Math.abs(index - to) - 1;
while (diff){
diff -=1;
this.move(this.circle((to > index ? to:index) - diff - 1),
this.slideWidth * direction,
0
);
}
to=this.circle(to);
this.move(index, this.slideWidth * direction, speed);
this.move(to, 0, speed);
if(this.options.continuous){
this.move(this.circle(to - direction),
-(this.slideWidth * direction),
0
);
}}else{
to=this.circle(to);
this.animate(index * -this.slideWidth, to * -this.slideWidth, speed);
}
this.onslide(to);
},
getIndex: function (){
return this.index;
},
getNumber: function (){
return this.num;
},
prev: function (){
if(this.options.continuous||this.index){
this.slide(this.index - 1);
}},
next: function (){
if(this.options.continuous||this.index < this.num - 1){
this.slide(this.index + 1);
}},
play: function (time){
var that=this;
window.clearTimeout(this.timeout);
this.interval=time||this.options.slideshowInterval;
if(this.elements[this.index] > 1){
this.timeout=this.setTimeout((!this.requestAnimationFrame&&this.slide)||function (to, speed){
that.animationFrameId=that.requestAnimationFrame.call(window,
function (){
that.slide(to, speed);
}
);
},
[this.index + 1, this.options.slideshowTransitionSpeed],
this.interval
);
}
this.container.addClass(this.options.playingClass);
},
pause: function (){
window.clearTimeout(this.timeout);
this.interval=null;
this.container.removeClass(this.options.playingClass);
},
add: function (list){
var i;
if(!list.concat){
list=Array.prototype.slice.call(list);
}
if(!this.list.concat){
this.list=Array.prototype.slice.call(this.list);
}
this.list=this.list.concat(list);
this.num=this.list.length;
if(this.num > 2&&this.options.continuous===null){
this.options.continuous=true;
this.container.removeClass(this.options.leftEdgeClass);
}
this.container
.removeClass(this.options.rightEdgeClass)
.removeClass(this.options.singleClass);
for (i=this.num - list.length; i < this.num; i +=1){
this.addSlide(i);
this.positionSlide(i);
}
this.positions.length=this.num;
this.initSlides(true);
},
resetSlides: function (){
this.slidesContainer.empty();
this.slides=[];
},
handleClose: function (){
var options=this.options;
this.destroyEventListeners();
this.pause();
this.container[0].style.display='none';
this.container
.removeClass(options.displayClass)
.removeClass(options.singleClass)
.removeClass(options.leftEdgeClass)
.removeClass(options.rightEdgeClass);
if(options.hidePageScrollbars){
document.body.style.overflow=this.bodyOverflowStyle;
}
if(this.options.clearSlides){
this.resetSlides();
}
if(this.options.onclosed){
this.options.onclosed.call(this);
}},
close: function (){
var that=this,
closeHandler=function (event){
if(event.target===that.container[0]){
that.container.off(that.support.transition.end,
closeHandler
);
that.handleClose();
}};
if(this.options.onclose){
this.options.onclose.call(this);
}
if(this.support.transition&&this.options.displayTransition){
this.container.on(this.support.transition.end,
closeHandler
);
this.container.removeClass(this.options.displayClass);
}else{
this.handleClose();
}},
circle: function (index){
return (this.num + (index % this.num)) % this.num;
},
move: function (index, dist, speed){
this.translateX(index, dist, speed);
this.positions[index]=dist;
},
translate: function (index, x, y, speed){
var style=this.slides[index].style,
transition=this.support.transition,
transform=this.support.transform;
style[transition.name + 'Duration']=speed + 'ms';
style[transform.name]='translate(' + x + 'px, ' + y + 'px)' +
(transform.translateZ ? ' translateZ(0)':'');
},
translateX: function (index, x, speed){
this.translate(index, x, 0, speed);
},
translateY: function (index, y, speed){
this.translate(index, 0, y, speed);
},
animate: function (from, to, speed){
if(!speed){
this.slidesContainer[0].style.left=to + 'px';
return;
}
var that=this,
start=new Date().getTime(),
timer=window.setInterval(function (){
var timeElap=new Date().getTime() - start;
if(timeElap > speed){
that.slidesContainer[0].style.left=to + 'px';
that.ontransitionend();
window.clearInterval(timer);
return;
}
that.slidesContainer[0].style.left=(((to - from) *
(Math.floor((timeElap / speed) * 100) / 100)) +
from) + 'px';
}, 4);
},
preventDefault: function (event){
if(event.preventDefault){
event.preventDefault();
}else{
event.returnValue=false;
}},
stopPropagation: function (event){
if(event.stopPropagation){
event.stopPropagation();
}else{
event.cancelBubble=true;
}},
onresize: function (){
this.initSlides(true);
},
onmousedown: function (event){
if(event.which&&event.which===1 &&
event.target.nodeName!=='VIDEO'){
event.preventDefault();
(event.originalEvent||event).touches=[{
pageX: event.pageX,
pageY: event.pageY
}];
this.ontouchstart(event);
}},
onmousemove: function (event){
if(this.touchStart){
(event.originalEvent||event).touches=[{
pageX: event.pageX,
pageY: event.pageY
}];
this.ontouchmove(event);
}},
onmouseup: function (event){
if(this.touchStart){
this.ontouchend(event);
delete this.touchStart;
}},
onmouseout: function (event){
if(this.touchStart){
var target=event.target,
related=event.relatedTarget;
if(!related||(related!==target &&
!$.contains(target, related))){
this.onmouseup(event);
}}
},
ontouchstart: function (event){
if(this.options.stopTouchEventsPropagation){
this.stopPropagation(event);
}
var touches=(event.originalEvent||event).touches[0];
this.touchStart={
x: touches.pageX,
y: touches.pageY,
time: Date.now()
};
this.isScrolling=undefined;
this.touchDelta={};},
ontouchmove: function (event){
if(this.options.stopTouchEventsPropagation){
this.stopPropagation(event);
}
var touches=(event.originalEvent||event).touches[0],
scale=(event.originalEvent||event).scale,
index=this.index,
touchDeltaX,
indices;
if(touches.length > 1||(scale&&scale!==1)){
return;
}
if(this.options.disableScroll){
event.preventDefault();
}
this.touchDelta={
x: touches.pageX - this.touchStart.x,
y: touches.pageY - this.touchStart.y
};
touchDeltaX=this.touchDelta.x;
if(this.isScrolling===undefined){
this.isScrolling=this.isScrolling ||
Math.abs(touchDeltaX) < Math.abs(this.touchDelta.y);
}
if(!this.isScrolling){
event.preventDefault();
window.clearTimeout(this.timeout);
if(this.options.continuous){
indices=[
this.circle(index + 1),
index,
this.circle(index - 1)
];
}else{
this.touchDelta.x=touchDeltaX =
touchDeltaX /
(((!index&&touchDeltaX > 0) ||
(index===this.num - 1&&touchDeltaX < 0)) ?
(Math.abs(touchDeltaX) / this.slideWidth + 1):1);
indices=[index];
if(index){
indices.push(index - 1);
}
if(index < this.num - 1){
indices.unshift(index + 1);
}}
while (indices.length){
index=indices.pop();
this.translateX(index, touchDeltaX + this.positions[index], 0);
}}else if(this.options.closeOnSwipeUpOrDown){
this.translateY(index, this.touchDelta.y + this.positions[index], 0);
}},
ontouchend: function (event){
if(this.options.stopTouchEventsPropagation){
this.stopPropagation(event);
}
var index=this.index,
speed=this.options.transitionSpeed,
slideWidth=this.slideWidth,
isShortDuration=Number(Date.now() - this.touchStart.time) < 250,
isValidSlide=(isShortDuration&&Math.abs(this.touchDelta.x) > 20) ||
Math.abs(this.touchDelta.x) > slideWidth / 2,
isPastBounds=(!index&&this.touchDelta.x > 0) ||
(index===this.num - 1&&this.touchDelta.x < 0),
isValidClose = !isValidSlide&&this.options.closeOnSwipeUpOrDown &&
((isShortDuration&&Math.abs(this.touchDelta.y) > 20) ||
Math.abs(this.touchDelta.y) > this.slideHeight / 2),
direction,
indexForward,
indexBackward,
distanceForward,
distanceBackward;
if(this.options.continuous){
isPastBounds=false;
}
direction=this.touchDelta.x < 0 ? -1:1;
if(!this.isScrolling){
if(isValidSlide&&!isPastBounds){
indexForward=index + direction;
indexBackward=index - direction;
distanceForward=slideWidth * direction;
distanceBackward=-slideWidth * direction;
if(this.options.continuous){
this.move(this.circle(indexForward), distanceForward, 0);
this.move(this.circle(index - 2 * direction), distanceBackward, 0);
}else if(indexForward >=0 &&
indexForward < this.num){
this.move(indexForward, distanceForward, 0);
}
this.move(index, this.positions[index] + distanceForward, speed);
this.move(this.circle(indexBackward),
this.positions[this.circle(indexBackward)] + distanceForward,
speed
);
index=this.circle(indexBackward);
this.onslide(index);
}else{
if(this.options.continuous){
this.move(this.circle(index - 1), -slideWidth, speed);
this.move(index, 0, speed);
this.move(this.circle(index + 1), slideWidth, speed);
}else{
if(index){
this.move(index - 1, -slideWidth, speed);
}
this.move(index, 0, speed);
if(index < this.num - 1){
this.move(index + 1, slideWidth, speed);
}}
}}else{
if(isValidClose){
this.close();
}else{
this.translateY(index, 0, speed);
}}
},
ontouchcancel: function (event){
if(this.touchStart){
this.ontouchend(event);
delete this.touchStart;
}},
ontransitionend: function (event){
var slide=this.slides[this.index];
if(!event||slide===event.target){
if(this.interval){
this.play();
}
this.setTimeout(this.options.onslideend,
[this.index, slide]
);
}},
oncomplete: function (event){
var target=event.target||event.srcElement,
parent=target&&target.parentNode,
index;
if(!target||!parent){
return;
}
index=this.getNodeIndex(parent);
$(parent).removeClass(this.options.slideLoadingClass);
if(event.type==='error'){
$(parent).addClass(this.options.slideErrorClass);
this.elements[index]=3;
}else{
this.elements[index]=2;
}
if(target.clientHeight > this.container[0].clientHeight){
target.style.maxHeight=this.container[0].clientHeight;
}
if(this.interval&&this.slides[this.index]===parent){
this.play();
}
this.setTimeout(this.options.onslidecomplete,
[index, parent]
);
},
onload: function (event){
this.oncomplete(event);
},
onerror: function (event){
this.oncomplete(event);
},
onkeydown: function (event){
switch (event.which||event.keyCode){
case 13:
if(this.options.toggleControlsOnReturn){
this.preventDefault(event);
this.toggleControls();
}
break;
case 27:
if(this.options.closeOnEscape){
this.close();
}
break;
case 32:
if(this.options.toggleSlideshowOnSpace){
this.preventDefault(event);
this.toggleSlideshow();
}
break;
case 37:
if(this.options.enableKeyboardNavigation){
this.preventDefault(event);
this.prev();
}
break;
case 39:
if(this.options.enableKeyboardNavigation){
this.preventDefault(event);
this.next();
}
break;
}},
handleClick: function (event){
var options=this.options,
target=event.target||event.srcElement,
parent=target.parentNode,
isTarget=function (className){
return $(target).hasClass(className) ||
$(parent).hasClass(className);
};
if(isTarget(options.toggleClass)){
this.preventDefault(event);
this.toggleControls();
}else if(isTarget(options.prevClass)){
this.preventDefault(event);
this.prev();
}else if(isTarget(options.nextClass)){
this.preventDefault(event);
this.next();
}else if(isTarget(options.closeClass)){
this.preventDefault(event);
this.close();
}else if(isTarget(options.playPauseClass)){
this.preventDefault(event);
this.toggleSlideshow();
}else if(parent===this.slidesContainer[0]){
this.preventDefault(event);
if(options.closeOnSlideClick){
this.close();
}else{
this.toggleControls();
}}else if(parent.parentNode &&
parent.parentNode===this.slidesContainer[0]){
this.preventDefault(event);
this.toggleControls();
}},
onclick: function (event){
if(this.options.emulateTouchEvents &&
this.touchDelta&&(Math.abs(this.touchDelta.x) > 20 ||
Math.abs(this.touchDelta.y) > 20)){
delete this.touchDelta;
return;
}
return this.handleClick(event);
},
updateEdgeClasses: function (index){
if(!index){
this.container.addClass(this.options.leftEdgeClass);
}else{
this.container.removeClass(this.options.leftEdgeClass);
}
if(index===this.num - 1){
this.container.addClass(this.options.rightEdgeClass);
}else{
this.container.removeClass(this.options.rightEdgeClass);
}},
handleSlide: function (index){
if(!this.options.continuous){
this.updateEdgeClasses(index);
}
this.loadElements(index);
if(this.options.unloadElements){
this.unloadElements(index);
}
this.setTitle(index);
},
onslide: function (index){
this.index=index;
this.handleSlide(index);
this.setTimeout(this.options.onslide, [index, this.slides[index]]);
},
setTitle: function (index){
var text=this.slides[index].firstChild.title,
titleElement=this.titleElement;
if(titleElement.length){
this.titleElement.empty();
if(text){
titleElement[0].appendChild(document.createTextNode(text));
}}
},
setTimeout: function (func, args, wait){
var that=this;
return func&&window.setTimeout(function (){
func.apply(that, args||[]);
}, wait||0);
},
imageFactory: function (obj, callback){
var that=this,
img=this.imagePrototype.cloneNode(false),
url=obj,
backgroundSize=this.options.stretchImages,
called,
element,
callbackWrapper=function (event){
if(!called){
event={
type: event.type,
target: element
};
if(!element.parentNode){
return that.setTimeout(callbackWrapper, [event]);
}
called=true;
$(img).off('load error', callbackWrapper);
if(backgroundSize){
if(event.type==='load'){
element.style.background='url("' + url +
'") center no-repeat';
element.style.backgroundSize=backgroundSize;
}}
callback(event);
}},
title;
if(typeof url!=='string'){
url=this.getItemProperty(obj, this.options.urlProperty);
title=this.getItemProperty(obj, this.options.titleProperty);
}
if(backgroundSize===true){
backgroundSize='contain';
}
backgroundSize=this.support.backgroundSize &&
this.support.backgroundSize[backgroundSize]&&backgroundSize;
if(backgroundSize){
element=this.elementPrototype.cloneNode(false);
}else{
element=img;
img.draggable=false;
}
if(title){
element.title=title;
}
$(img).on('load error', callbackWrapper);
img.src=url;
return element;
},
createElement: function (obj, callback){
var type=obj&&this.getItemProperty(obj, this.options.typeProperty),
factory=(type&&this[type.split('/')[0] + 'Factory']) ||
this.imageFactory,
element=obj&&factory.call(this, obj, callback);
if(!element){
element=this.elementPrototype.cloneNode(false);
this.setTimeout(callback, [{
type: 'error',
target: element
}]);
}
$(element).addClass(this.options.slideContentClass);
return element;
},
loadElement: function (index){
if(!this.elements[index]){
if(this.slides[index].firstChild){
this.elements[index]=$(this.slides[index])
.hasClass(this.options.slideErrorClass) ? 3:2;
}else{
this.elements[index]=1;
$(this.slides[index]).addClass(this.options.slideLoadingClass);
this.slides[index].appendChild(this.createElement(this.list[index],
this.proxyListener
));
}}
},
loadElements: function (index){
var limit=Math.min(this.num, this.options.preloadRange * 2 + 1),
j=index,
i;
for (i=0; i < limit; i +=1){
j +=i * (i % 2===0 ? -1:1);
j=this.circle(j);
this.loadElement(j);
}},
unloadElements: function (index){
var i,
slide,
diff;
for (i in this.elements){
if(this.elements.hasOwnProperty(i)){
diff=Math.abs(index - i);
if(diff > this.options.preloadRange &&
diff + this.options.preloadRange < this.num){
slide=this.slides[i];
slide.removeChild(slide.firstChild);
delete this.elements[i];
}}
}},
addSlide: function (index){
var slide=this.slidePrototype.cloneNode(false);
slide.setAttribute('data-index', index);
this.slidesContainer[0].appendChild(slide);
this.slides.push(slide);
},
positionSlide: function (index){
var slide=this.slides[index];
slide.style.width=this.slideWidth + 'px';
if(this.support.transition){
slide.style.left=(index * -this.slideWidth) + 'px';
this.move(index, this.index > index ? -this.slideWidth :
(this.index < index ? this.slideWidth:0), 0);
}},
initSlides: function (reload){
var clearSlides,
i;
if(!reload){
this.positions=[];
this.positions.length=this.num;
this.elements={};
this.imagePrototype=document.createElement('img');
this.elementPrototype=document.createElement('div');
this.slidePrototype=document.createElement('div');
$(this.slidePrototype).addClass(this.options.slideClass);
this.slides=this.slidesContainer[0].children;
clearSlides=this.options.clearSlides ||
this.slides.length!==this.num;
}
this.slideWidth=this.container[0].offsetWidth;
this.slideHeight=this.container[0].offsetHeight;
this.slidesContainer[0].style.width =
(this.num * this.slideWidth) + 'px';
if(clearSlides){
this.resetSlides();
}
for (i=0; i < this.num; i +=1){
if(clearSlides){
this.addSlide(i);
}
this.positionSlide(i);
}
if(this.options.continuous&&this.support.transition){
this.move(this.circle(this.index - 1), -this.slideWidth, 0);
this.move(this.circle(this.index + 1), this.slideWidth, 0);
}
if(!this.support.transition){
this.slidesContainer[0].style.left =
(this.index * -this.slideWidth) + 'px';
}},
toggleControls: function (){
var controlsClass=this.options.controlsClass;
if(this.container.hasClass(controlsClass)){
this.container.removeClass(controlsClass);
}else{
this.container.addClass(controlsClass);
}},
toggleSlideshow: function (){
if(!this.interval){
this.play();
}else{
this.pause();
}},
getNodeIndex: function (element){
return parseInt(element.getAttribute('data-index'), 10);
},
getNestedProperty: function (obj, property){
property.replace(/\[(?:'([^']+)'|"([^"]+)"|(\d+))\]|(?:(?:^|\.)([^\.\[]+))/g,
function (str, singleQuoteProp, doubleQuoteProp, arrayIndex, dotProp){
var prop=dotProp||singleQuoteProp||doubleQuoteProp ||
(arrayIndex&&parseInt(arrayIndex, 10));
if(str&&obj){
obj=obj[prop];
}}
);
return obj;
},
getDataProperty: function (obj, property){
if(obj.getAttribute){
var prop=obj.getAttribute('data-' +
property.replace(/([A-Z])/g, '-$1').toLowerCase());
if(typeof prop==='string'){
if(/^(true|false|null|-?\d+(\.\d+)?|\{[\s\S]*\}|\[[\s\S]*\])$/
.test(prop)){
try {
return $.parseJSON(prop);
} catch (ignore){}}
return prop;
}}
},
getItemProperty: function (obj, property){
var prop=obj[property];
if(prop===undefined){
prop=this.getDataProperty(obj, property);
if(prop===undefined){
prop=this.getNestedProperty(obj, property);
}}
return prop;
},
initStartIndex: function (){
var index=this.options.index,
urlProperty=this.options.urlProperty,
i;
if(index&&typeof index!=='number'){
for (i=0; i < this.num; i +=1){
if(this.list[i]===index ||
this.getItemProperty(this.list[i], urlProperty)===this.getItemProperty(index, urlProperty)){
index=i;
break;
}}
}
this.index=this.circle(parseInt(index, 10)||0);
},
initEventListeners: function (){
var that=this,
slidesContainer=this.slidesContainer,
proxyListener=function (event){
var type=that.support.transition &&
that.support.transition.end===event.type ?
'transitionend':event.type;
that['on' + type](event);
};
$(window).on('resize', proxyListener);
$(document.body).on('keydown', proxyListener);
this.container.on('click', proxyListener);
if(this.support.touch){
slidesContainer
.on('touchstart touchmove touchend touchcancel', proxyListener);
}else if(this.options.emulateTouchEvents &&
this.support.transition){
slidesContainer
.on('mousedown mousemove mouseup mouseout', proxyListener);
}
if(this.support.transition){
slidesContainer.on(this.support.transition.end,
proxyListener
);
}
this.proxyListener=proxyListener;
},
destroyEventListeners: function (){
var slidesContainer=this.slidesContainer,
proxyListener=this.proxyListener;
$(window).off('resize', proxyListener);
$(document.body).off('keydown', proxyListener);
this.container.off('click', proxyListener);
if(this.support.touch){
slidesContainer
.off('touchstart touchmove touchend touchcancel', proxyListener);
}else if(this.options.emulateTouchEvents &&
this.support.transition){
slidesContainer
.off('mousedown mousemove mouseup mouseout', proxyListener);
}
if(this.support.transition){
slidesContainer.off(this.support.transition.end,
proxyListener
);
}},
handleOpen: function (){
if(this.options.onopened){
this.options.onopened.call(this);
}},
initWidget: function (){
var that=this,
openHandler=function (event){
if(event.target===that.container[0]){
that.container.off(that.support.transition.end,
openHandler
);
that.handleOpen();
}};
this.container=$(this.options.container);
if(!this.container.length){
this.console.log('blueimp Gallery: Widget container not found.',
this.options.container
);
return false;
}
this.slidesContainer=this.container.find(this.options.slidesContainer
).first();
if(!this.slidesContainer.length){
this.console.log('blueimp Gallery: Slides container not found.',
this.options.slidesContainer
);
return false;
}
this.titleElement=this.container.find(this.options.titleElement
).first();
if(this.num===1){
this.container.addClass(this.options.singleClass);
}
if(this.options.onopen){
this.options.onopen.call(this);
}
if(this.support.transition&&this.options.displayTransition){
this.container.on(this.support.transition.end,
openHandler
);
}else{
this.handleOpen();
}
if(this.options.hidePageScrollbars){
this.bodyOverflowStyle=document.body.style.overflow;
document.body.style.overflow='hidden';
}
this.container[0].style.display='block';
this.initSlides();
this.container.addClass(this.options.displayClass);
},
initOptions: function (options){
this.options=$.extend({}, this.options);
if((options&&options.carousel) ||
(this.options.carousel&&(!options||options.carousel!==false))){
$.extend(this.options, this.carouselOptions);
}
$.extend(this.options, options);
if(this.num < 3){
this.options.continuous=this.options.continuous ? null:false;
}
if(!this.support.transition){
this.options.emulateTouchEvents=false;
}
if(this.options.event){
this.preventDefault(this.options.event);
}}
});
return Gallery;
}));
(function (factory){
'use strict';
if(typeof define==='function'&&define.amd){
define([
'./blueimp-helper',
'./blueimp-gallery'
], factory);
}else{
factory(
window.blueimp.helper||window.jQuery,
window.blueimp.Gallery
);
}}(function ($, Gallery){
'use strict';
$.extend(Gallery.prototype.options, {
indicatorContainer: 'ol',
activeIndicatorClass: 'active',
thumbnailProperty: 'thumbnail',
thumbnailIndicators: true
});
var initSlides=Gallery.prototype.initSlides,
addSlide=Gallery.prototype.addSlide,
resetSlides=Gallery.prototype.resetSlides,
handleClick=Gallery.prototype.handleClick,
handleSlide=Gallery.prototype.handleSlide,
handleClose=Gallery.prototype.handleClose;
$.extend(Gallery.prototype, {
createIndicator: function (obj){
var indicator=this.indicatorPrototype.cloneNode(false),
title=this.getItemProperty(obj, this.options.titleProperty),
thumbnailProperty=this.options.thumbnailProperty,
thumbnailUrl,
thumbnail;
if(this.options.thumbnailIndicators){
thumbnail=obj.getElementsByTagName&&$(obj).find('img')[0];
if(thumbnail){
thumbnailUrl=thumbnail.src;
}else if(thumbnailProperty){
thumbnailUrl=this.getItemProperty(obj, thumbnailProperty);
}
if(thumbnailUrl){
indicator.style.backgroundImage='url("' + thumbnailUrl + '")';
}}
if(title){
indicator.title=title;
}
return indicator;
},
addIndicator: function (index){
if(this.indicatorContainer.length){
var indicator=this.createIndicator(this.list[index]);
indicator.setAttribute('data-index', index);
this.indicatorContainer[0].appendChild(indicator);
this.indicators.push(indicator);
}},
setActiveIndicator: function (index){
if(this.indicators){
if(this.activeIndicator){
this.activeIndicator
.removeClass(this.options.activeIndicatorClass);
}
this.activeIndicator=$(this.indicators[index]);
this.activeIndicator
.addClass(this.options.activeIndicatorClass);
}},
initSlides: function (reload){
if(!reload){
this.indicatorContainer=this.container.find(this.options.indicatorContainer
);
if(this.indicatorContainer.length){
this.indicatorPrototype=document.createElement('li');
this.indicators=this.indicatorContainer[0].children;
}}
initSlides.call(this, reload);
},
addSlide: function (index){
addSlide.call(this, index);
this.addIndicator(index);
},
resetSlides: function (){
resetSlides.call(this);
this.indicatorContainer.empty();
this.indicators=[];
},
handleClick: function (event){
var target=event.target||event.srcElement,
parent=target.parentNode;
if(parent===this.indicatorContainer[0]){
this.preventDefault(event);
this.slide(this.getNodeIndex(target));
}else if(parent.parentNode===this.indicatorContainer[0]){
this.preventDefault(event);
this.slide(this.getNodeIndex(parent));
}else{
return handleClick.call(this, event);
}},
handleSlide: function (index){
handleSlide.call(this, index);
this.setActiveIndicator(index);
},
handleClose: function (){
if(this.activeIndicator){
this.activeIndicator
.removeClass(this.options.activeIndicatorClass);
}
handleClose.call(this);
}});
return Gallery;
}));
(function (factory){
'use strict';
if(typeof define==='function'&&define.amd){
define([
'./blueimp-helper',
'./blueimp-gallery'
], factory);
}else{
factory(
window.blueimp.helper||window.jQuery,
window.blueimp.Gallery
);
}}(function ($, Gallery){
'use strict';
$.extend(Gallery.prototype.options, {
fullScreen: false
});
var initialize=Gallery.prototype.initialize,
close=Gallery.prototype.close;
$.extend(Gallery.prototype, {
getFullScreenElement: function (){
return document.fullscreenElement ||
document.webkitFullscreenElement ||
document.mozFullScreenElement ||
document.msFullscreenElement;
},
requestFullScreen: function (element){
if(element.requestFullscreen){
element.requestFullscreen();
}else if(element.webkitRequestFullscreen){
element.webkitRequestFullscreen();
}else if(element.mozRequestFullScreen){
element.mozRequestFullScreen();
}else if(element.msRequestFullscreen){
element.msRequestFullscreen();
}},
exitFullScreen: function (){
if(document.exitFullscreen){
document.exitFullscreen();
}else if(document.webkitCancelFullScreen){
document.webkitCancelFullScreen();
}else if(document.mozCancelFullScreen){
document.mozCancelFullScreen();
}else if(document.msExitFullscreen){
document.msExitFullscreen();
}},
initialize: function (){
initialize.call(this);
if(this.options.fullScreen&&!this.getFullScreenElement()){
this.requestFullScreen(this.container[0]);
}},
close: function (){
if(this.getFullScreenElement()===this.container[0]){
this.exitFullScreen();
}
close.call(this);
}});
return Gallery;
}));
(function (factory){
'use strict';
if(typeof define==='function'&&define.amd){
define([
'./blueimp-helper',
'./blueimp-gallery'
], factory);
}else{
factory(
window.blueimp.helper||window.jQuery,
window.blueimp.Gallery
);
}}(function ($, Gallery){
'use strict';
$.extend(Gallery.prototype.options, {
videoContentClass: 'video-content',
videoLoadingClass: 'video-loading',
videoPlayingClass: 'video-playing',
videoPosterProperty: 'poster',
videoSourcesProperty: 'sources'
});
var handleSlide=Gallery.prototype.handleSlide;
$.extend(Gallery.prototype, {
handleSlide: function (index){
handleSlide.call(this, index);
if(this.playingVideo){
this.playingVideo.pause();
}},
videoFactory: function (obj, callback, videoInterface){
var that=this,
options=this.options,
videoContainerNode=this.elementPrototype.cloneNode(false),
videoContainer=$(videoContainerNode),
errorArgs=[{
type: 'error',
target: videoContainerNode
}],
video=videoInterface||document.createElement('video'),
url=this.getItemProperty(obj, options.urlProperty),
type=this.getItemProperty(obj, options.typeProperty),
title=this.getItemProperty(obj, options.titleProperty),
posterUrl=this.getItemProperty(obj, options.videoPosterProperty),
posterImage,
sources=this.getItemProperty(obj,
options.videoSourcesProperty
),
source,
playMediaControl,
isLoading,
hasControls;
videoContainer.addClass(options.videoContentClass);
if(title){
videoContainerNode.title=title;
}
if(video.canPlayType){
if(url&&type&&video.canPlayType(type)){
video.src=url;
}else{
while (sources&&sources.length){
source=sources.shift();
url=this.getItemProperty(source, options.urlProperty);
type=this.getItemProperty(source, options.typeProperty);
if(url&&type&&video.canPlayType(type)){
video.src=url;
break;
}}
}}
if(posterUrl){
video.poster=posterUrl;
posterImage=this.imagePrototype.cloneNode(false);
$(posterImage).addClass(options.toggleClass);
posterImage.src=posterUrl;
posterImage.draggable=false;
videoContainerNode.appendChild(posterImage);
}
playMediaControl=document.createElement('a');
playMediaControl.setAttribute('target', '_blank');
if(!videoInterface){
playMediaControl.setAttribute('download', title);
}
playMediaControl.href=url;
if(video.src){
video.controls=true;
(videoInterface||$(video))
.on('error', function (){
that.setTimeout(callback, errorArgs);
})
.on('pause', function (){
isLoading=false;
videoContainer
.removeClass(that.options.videoLoadingClass)
.removeClass(that.options.videoPlayingClass);
if(hasControls){
that.container.addClass(that.options.controlsClass);
}
delete that.playingVideo;
if(that.interval){
that.play();
}})
.on('playing', function (){
isLoading=false;
videoContainer
.removeClass(that.options.videoLoadingClass)
.addClass(that.options.videoPlayingClass);
if(that.container.hasClass(that.options.controlsClass)){
hasControls=true;
that.container.removeClass(that.options.controlsClass);
}else{
hasControls=false;
}})
.on('play', function (){
window.clearTimeout(that.timeout);
isLoading=true;
videoContainer.addClass(that.options.videoLoadingClass);
that.playingVideo=video;
});
$(playMediaControl).on('click', function (event){
that.preventDefault(event);
if(isLoading){
video.pause();
}else{
video.play();
}});
videoContainerNode.appendChild((videoInterface&&videoInterface.element)||video
);
}
videoContainerNode.appendChild(playMediaControl);
this.setTimeout(callback, [{
type: 'load',
target: videoContainerNode
}]);
return videoContainerNode;
}});
return Gallery;
}));
(function (factory){
'use strict';
if(typeof define==='function'&&define.amd){
define([
'./blueimp-helper',
'./blueimp-gallery-video'
], factory);
}else{
factory(
window.blueimp.helper||window.jQuery,
window.blueimp.Gallery
);
}}(function ($, Gallery){
'use strict';
if(!window.postMessage){
return Gallery;
}
$.extend(Gallery.prototype.options, {
vimeoVideoIdProperty: 'vimeo',
vimeoPlayerUrl: '//player.vimeo.com/video/VIDEO_ID?api=1&player_id=PLAYER_ID',
vimeoPlayerIdPrefix: 'vimeo-player-',
vimeoClickToPlay: true
});
var textFactory=Gallery.prototype.textFactory||Gallery.prototype.imageFactory,
VimeoPlayer=function (url, videoId, playerId, clickToPlay){
this.url=url;
this.videoId=videoId;
this.playerId=playerId;
this.clickToPlay=clickToPlay;
this.element=document.createElement('div');
this.listeners={};},
counter=0;
$.extend(VimeoPlayer.prototype, {
canPlayType: function (){
return true;
},
on: function (type, func){
this.listeners[type]=func;
return this;
},
loadAPI: function (){
var that=this,
apiUrl='//' + (location.protocol==='https' ? 'secure-':'') +
'a.vimeocdn.com/js/froogaloop2.min.js',
scriptTags=document.getElementsByTagName('script'),
i=scriptTags.length,
scriptTag,
called,
callback=function (){
if(!called&&that.playOnReady){
that.play();
}
called=true;
};
while (i){
i -=1;
if(scriptTags[i].src===apiUrl){
scriptTag=scriptTags[i];
break;
}}
if(!scriptTag){
scriptTag=document.createElement('script');
scriptTag.src=apiUrl;
}
$(scriptTag).on('load', callback);
scriptTags[0].parentNode.insertBefore(scriptTag, scriptTags[0]);
if(/loaded|complete/.test(scriptTag.readyState)){
callback();
}},
onReady: function (){
var that=this;
this.ready=true;
this.player.addEvent('play', function (){
that.hasPlayed=true;
that.onPlaying();
});
this.player.addEvent('pause', function (){
that.onPause();
});
this.player.addEvent('finish', function (){
that.onPause();
});
if(this.playOnReady){
this.play();
}},
onPlaying: function (){
if(this.playStatus < 2){
this.listeners.playing();
this.playStatus=2;
}},
onPause: function (){
this.listeners.pause();
delete this.playStatus;
},
insertIframe: function (){
var iframe=document.createElement('iframe');
iframe.src=this.url
.replace('VIDEO_ID', this.videoId)
.replace('PLAYER_ID', this.playerId);
iframe.id=this.playerId;
this.element.parentNode.replaceChild(iframe, this.element);
this.element=iframe;
},
play: function (){
var that=this;
if(!this.playStatus){
this.listeners.play();
this.playStatus=1;
}
if(this.ready){
if(!this.hasPlayed&&(this.clickToPlay||(window.navigator &&
/iP(hone|od|ad)/.test(window.navigator.platform)))){
this.onPlaying();
}else{
this.player.api('play');
}}else{
this.playOnReady=true;
if(!window.$f){
this.loadAPI();
}else if(!this.player){
this.insertIframe();
this.player=$f(this.element);
this.player.addEvent('ready', function (){
that.onReady();
});
}}
},
pause: function (){
if(this.ready){
this.player.api('pause');
}else if(this.playStatus){
delete this.playOnReady;
this.listeners.pause();
delete this.playStatus;
}}
});
$.extend(Gallery.prototype, {
VimeoPlayer: VimeoPlayer,
textFactory: function (obj, callback){
var options=this.options,
videoId=this.getItemProperty(obj, options.vimeoVideoIdProperty);
if(videoId){
if(this.getItemProperty(obj, options.urlProperty)===undefined){
obj[options.urlProperty]='//vimeo.com/' + videoId;
}
counter +=1;
return this.videoFactory(obj,
callback,
new VimeoPlayer(
options.vimeoPlayerUrl,
videoId,
options.vimeoPlayerIdPrefix + counter,
options.vimeoClickToPlay
)
);
}
return textFactory.call(this, obj, callback);
}});
return Gallery;
}));
(function (factory){
'use strict';
if(typeof define==='function'&&define.amd){
define([
'./blueimp-helper',
'./blueimp-gallery-video'
], factory);
}else{
factory(
window.blueimp.helper||window.jQuery,
window.blueimp.Gallery
);
}}(function ($, Gallery){
'use strict';
if(!window.postMessage){
return Gallery;
}
$.extend(Gallery.prototype.options, {
youTubeVideoIdProperty: 'youtube',
youTubePlayerVars: {
wmode: 'transparent'
},
youTubeClickToPlay: true
});
var textFactory=Gallery.prototype.textFactory||Gallery.prototype.imageFactory,
YouTubePlayer=function (videoId, playerVars, clickToPlay){
this.videoId=videoId;
this.playerVars=playerVars;
this.clickToPlay=clickToPlay;
this.element=document.createElement('div');
this.listeners={};};
$.extend(YouTubePlayer.prototype, {
canPlayType: function (){
return true;
},
on: function (type, func){
this.listeners[type]=func;
return this;
},
loadAPI: function (){
var that=this,
onYouTubeIframeAPIReady=window.onYouTubeIframeAPIReady,
apiUrl='//www.youtube.com/iframe_api',
scriptTags=document.getElementsByTagName('script'),
i=scriptTags.length,
scriptTag;
window.onYouTubeIframeAPIReady=function (){
if(onYouTubeIframeAPIReady){
onYouTubeIframeAPIReady.apply(this);
}
if(that.playOnReady){
that.play();
}};
while (i){
i -=1;
if(scriptTags[i].src===apiUrl){
return;
}}
scriptTag=document.createElement('script');
scriptTag.src=apiUrl;
scriptTags[0].parentNode.insertBefore(scriptTag, scriptTags[0]);
},
onReady: function (){
this.ready=true;
if(this.playOnReady){
this.play();
}},
onPlaying: function (){
if(this.playStatus < 2){
this.listeners.playing();
this.playStatus=2;
}},
onPause: function (){
Gallery.prototype.setTimeout.call(this,
this.checkSeek,
null,
2000
);
},
checkSeek: function (){
if(this.stateChange===YT.PlayerState.PAUSED ||
this.stateChange===YT.PlayerState.ENDED){
this.listeners.pause();
delete this.playStatus;
}},
onStateChange: function (event){
switch (event.data){
case YT.PlayerState.PLAYING:
this.hasPlayed=true;
this.onPlaying();
break;
case YT.PlayerState.PAUSED:
case YT.PlayerState.ENDED:
this.onPause();
break;
}
this.stateChange=event.data;
},
onError: function (event){
this.listeners.error(event);
},
play: function (){
var that=this;
if(!this.playStatus){
this.listeners.play();
this.playStatus=1;
}
if(this.ready){
if(!this.hasPlayed&&(this.clickToPlay||(window.navigator &&
/iP(hone|od|ad)/.test(window.navigator.platform)))){
this.onPlaying();
}else{
this.player.playVideo();
}}else{
this.playOnReady=true;
if(!(window.YT&&YT.Player)){
this.loadAPI();
}else if(!this.player){
this.player=new YT.Player(this.element, {
videoId: this.videoId,
playerVars: this.playerVars,
events: {
onReady: function (){
that.onReady();
},
onStateChange: function (event){
that.onStateChange(event);
},
onError: function (event){
that.onError(event);
}}
});
}}
},
pause: function (){
if(this.ready){
this.player.pauseVideo();
}else if(this.playStatus){
delete this.playOnReady;
this.listeners.pause();
delete this.playStatus;
}}
});
$.extend(Gallery.prototype, {
YouTubePlayer: YouTubePlayer,
textFactory: function (obj, callback){
var options=this.options,
videoId=this.getItemProperty(obj, options.youTubeVideoIdProperty);
if(videoId){
if(this.getItemProperty(obj, options.urlProperty)===undefined){
obj[options.urlProperty]='//www.youtube.com/watch?v=' + videoId;
}
if(this.getItemProperty(obj, options.videoPosterProperty)===undefined){
obj[options.videoPosterProperty]='//img.youtube.com/vi/' + videoId +
'/maxresdefault.jpg';
}
return this.videoFactory(obj,
callback,
new YouTubePlayer(
videoId,
options.youTubePlayerVars,
options.youTubeClickToPlay
)
);
}
return textFactory.call(this, obj, callback);
}});
return Gallery;
}));
(function (factory){
'use strict';
if(typeof define==='function'&&define.amd){
define([
'jquery',
'./blueimp-gallery'
], factory);
}else{
factory(
window.jQuery,
window.blueimp.Gallery
);
}}(function ($, Gallery){
'use strict';
$(document).on('click', '[data-gallery]', function (event){
var id=$(this).data('gallery'),
widget=$(id),
container=(widget.length&&widget) ||
$(Gallery.prototype.options.container),
callbacks={
onopen: function (){
container
.data('gallery', this)
.trigger('open');
},
onopened: function (){
container.trigger('opened');
},
onslide: function (){
container.trigger('slide', arguments);
},
onslideend: function (){
container.trigger('slideend', arguments);
},
onslidecomplete: function (){
container.trigger('slidecomplete', arguments);
},
onclose: function (){
container.trigger('close');
},
onclosed: function (){
container
.trigger('closed')
.removeData('gallery');
}},
options=$.extend(container.data(),
{
container: container[0],
index: this,
event: event
},
callbacks
),
links=$('[data-gallery="' + id + '"]');
if(options.filter){
links=links.filter(options.filter);
}
return new Gallery(links, options);
});
}));
!function(){
(function(){function ba(g){function p(){try{M.doScroll("left")}catch(ca){q.setTimeout(p,50);return}y("poll")}function y(p){if("readystatechange"!=p.type||"complete"==A.readyState)("load"==p.type?q:A)[C](r+p.type,y,!1),!k&&(k=!0)&&g.call(q,p.type||p)}var X=A.addEventListener,k=!1,F=!0,x=X?"addEventListener":"attachEvent",C=X?"removeEventListener":"detachEvent",r=X?"":"on";if("complete"==A.readyState)g.call(q,"lazy");else{if(A.createEventObject&&M.doScroll){try{F=!q.frameElement}catch(ca){}F&&p()}A[x](r+
"DOMContentLoaded",y,!1);A[x](r+"readystatechange",y,!1);q[x](r+"load",y,!1)}}function V(){Y&&ba(function(){var g=N.length;da(g?function(){for(var p=0;p<g;++p)(function(g){q.setTimeout(function(){q.exports[N[g]].apply(q,arguments)},0)})(p)}:void 0)})}for(var q=window,A=document,M=A.documentElement,O=A.head||A.getElementsByTagName("head")[0]||M,C="",G=A.getElementsByTagName("script"),k=G.length;0<=--k;){var P=G[k],Z=P.src.match(/^[^?#]*\/run_prettify\.js(\?[^#]*)?(?:#.*)?$/);if(Z){C=Z[1]||"";P.parentNode.removeChild(P);
break}}var Y=!0,I=[],Q=[],N=[];C.replace(/[?&]([^&=]+)=([^&]+)/g,function(g,p,y){y=decodeURIComponent(y);p=decodeURIComponent(p);"autorun"==p?Y=!/^[0fn]/i.test(y):"lang"==p?I.push(y):"skin"==p?Q.push(y):"callback"==p&&N.push(y)});for(var T=q.codePrettifyLoaderBaseUrl,k=0,C=I.length;k<C;++k)(function(){var g=A.createElement("script");g.onload=g.onerror=g.onreadystatechange=function(){!g||g.readyState&&!/loaded|complete/.test(g.readyState)||(g.onerror=g.onload=g.onreadystatechange=null,--U,U||q.setTimeout(V,
0),g.parentNode&&g.parentNode.removeChild(g),g=null)};g.type="text/javascript";g.src=T+"/lang-"+encodeURIComponent(I[k])+".js";O.insertBefore(g,O.firstChild)})(I[k]);for(var U=I.length,G=[],k=0,C=Q.length;k<C;++k)G.push(T+"/skins/"+encodeURIComponent(Q[k])+".css");G.push(T+"/prettify.css");(function(g){function p(k){if(k!==y){var q=A.createElement("link");q.rel="stylesheet";q.type="text/css";k+1<y&&(q.error=q.onerror=function(){p(k+1)});q.href=g[k];O.appendChild(q)}}var y=g.length;p(0)})(G);var da=
function(){"undefined"!==typeof window&&(window.PR_SHOULD_USE_CONTINUATION=!0);var g;(function(){function p(a){function d(e){var a=e.charCodeAt(0);if(92!==a)return a;var c=e.charAt(1);return(a=k[c])?a:"0"<=c&&"7">=c?parseInt(e.substring(1),8):"u"===c||"x"===c?parseInt(e.substring(2),16):e.charCodeAt(1)}function f(e){if(32>e)return(16>e?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return"\\"===e||"-"===e||"]"===e||"^"===e?"\\"+e:e}function c(e){var c=e.substring(1,e.length-1).match(RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]",
"g"));e=[];var a="^"===c[0],b=["["];a&&b.push("^");for(var a=a?1:0,h=c.length;a<h;++a){var l=c[a];if(/\\[bdsw]/i.test(l))b.push(l);else{var l=d(l),n;a+2<h&&"-"===c[a+1]?(n=d(c[a+2]),a+=2):n=l;e.push([l,n]);65>n||122<l||(65>n||90<l||e.push([Math.max(65,l)|32,Math.min(n,90)|32]),97>n||122<l||e.push([Math.max(97,l)&-33,Math.min(n,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});c=[];h=[];for(a=0;a<e.length;++a)l=e[a],l[0]<=h[1]+1?h[1]=Math.max(h[1],l[1]):c.push(h=l);for(a=0;a<c.length;++a)l=
c[a],b.push(f(l[0])),l[1]>l[0]&&(l[1]+1>l[0]&&b.push("-"),b.push(f(l[1])));b.push("]");return b.join("")}function g(e){for(var a=e.source.match(RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g")),b=a.length,d=[],h=0,l=0;h<b;++h){var n=a[h];"("===n?++l:"\\"===n.charAt(0)&&(n=+n.substring(1))&&(n<=l?d[n]=-1:a[h]=f(n))}for(h=1;h<d.length;++h)-1===d[h]&&(d[h]=++p);for(l=h=0;h<b;++h)n=a[h],
"("===n?(++l,d[l]||(a[h]="(?:")):"\\"===n.charAt(0)&&(n=+n.substring(1))&&n<=l&&(a[h]="\\"+d[n]);for(h=0;h<b;++h)"^"===a[h]&&"^"!==a[h+1]&&(a[h]="");if(e.ignoreCase&&B)for(h=0;h<b;++h)n=a[h],e=n.charAt(0),2<=n.length&&"["===e?a[h]=c(n):"\\"!==e&&(a[h]=n.replace(/[a-zA-Z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var p=0,B=!1,m=!1,J=0,b=a.length;J<b;++J){var t=a[J];if(t.ignoreCase)m=!0;else if(/[a-z]/i.test(t.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,
""))){B=!0;m=!1;break}}for(var k={b:8,t:9,n:10,v:11,f:12,r:13},u=[],J=0,b=a.length;J<b;++J){t=a[J];if(t.global||t.multiline)throw Error(""+t);u.push("(?:"+g(t)+")")}return new RegExp(u.join("|"),m?"gi":"g")}function q(a,d){function f(a){var b=a.nodeType;if(1==b){if(!c.test(a.className)){for(b=a.firstChild;b;b=b.nextSibling)f(b);b=a.nodeName.toLowerCase();if("br"===b||"li"===b)g[m]="\n",B[m<<1]=p++,B[m++<<1|1]=a}}else if(3==b||4==b)b=a.nodeValue,b.length&&(b=d?b.replace(/\r\n?/g,"\n"):b.replace(/[ \t\r\n]+/g,
" "),g[m]=b,B[m<<1]=p,p+=b.length,B[m++<<1|1]=a)}var c=/(?:^|\s)nocode(?:\s|$)/,g=[],p=0,B=[],m=0;f(a);return{a:g.join("").replace(/\n$/,""),c:B}}function k(a,d,f,c,g){f&&(a={h:a,l:1,j:null,m:null,a:f,c:null,i:d,g:null},c(a),g.push.apply(g,a.g))}function A(a){for(var d=void 0,f=a.firstChild;f;f=f.nextSibling)var c=f.nodeType,d=1===c?d?a:f:3===c?T.test(f.nodeValue)?a:d:d;return d===a?void 0:d}function F(a,d){function f(a){for(var m=a.i,p=a.h,b=[m,"pln"],t=0,B=a.a.match(g)||[],u={},e=0,r=B.length;e<
r;++e){var E=B[e],w=u[E],h=void 0,l;if("string"===typeof w)l=!1;else{var n=c[E.charAt(0)];if(n)h=E.match(n[1]),w=n[0];else{for(l=0;l<q;++l)if(n=d[l],h=E.match(n[1])){w=n[0];break}h||(w="pln")}!(l=5<=w.length&&"lang-"===w.substring(0,5))||h&&"string"===typeof h[1]||(l=!1,w="src");l||(u[E]=w)}n=t;t+=E.length;if(l){l=h[1];var D=E.indexOf(l),H=D+l.length;h[2]&&(H=E.length-h[2].length,D=H-l.length);w=w.substring(5);k(p,m+n,E.substring(0,D),f,b);k(p,m+n+D,l,G(w,l),b);k(p,m+n+H,E.substring(H),f,b)}else b.push(m+
n,w)}a.g=b}var c={},g;(function(){for(var f=a.concat(d),m=[],k={},b=0,t=f.length;b<t;++b){var q=f[b],u=q[3];if(u)for(var e=u.length;0<=--e;)c[u.charAt(e)]=q;q=q[1];u=""+q;k.hasOwnProperty(u)||(m.push(q),k[u]=null)}m.push(/[\0-\uffff]/);g=p(m)})();var q=d.length;return f}function x(a){var d=[],f=[];a.tripleQuotedStrings?d.push(["str",/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,
null,"'\""]):a.multiLineStrings?d.push(["str",/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"]):d.push(["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"]);a.verbatimStrings&&f.push(["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null]);var c=a.hashComments;c&&(a.cStyleComments?(1<c?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,
null,"#"]),f.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])):d.push(["com",/^#[^\r\n]*/,null,"#"]));a.cStyleComments&&(f.push(["com",/^\/\/[^\r\n]*/,null]),f.push(["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null]));if(c=a.regexLiterals){var g=(c=1<c?"":"\n\r")?".":"[\\S\\s]";f.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+
("/(?=[^/*"+c+"])(?:[^/\\x5B\\x5C"+c+"]|\\x5C"+g+"|\\x5B(?:[^\\x5C\\x5D"+c+"]|\\x5C"+g+")*(?:\\x5D|$))+/")+")")])}(c=a.types)&&f.push(["typ",c]);c=(""+a.keywords).replace(/^ | $/g,"");c.length&&f.push(["kwd",new RegExp("^(?:"+c.replace(/[\s,]+/g,"|")+")\\b"),null]);d.push(["pln",/^\s+/,null," \r\n\t\u00a0"]);c="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(c+="(?!s*/)");f.push(["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],["pln",/^[a-z_$][a-z_$@0-9]*/i,
null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pln",/^\\[\s\S]?/,null],["pun",new RegExp(c),null]);return F(d,f)}function C(a,d,f){function c(a){var b=a.nodeType;if(1==b&&!p.test(a.className))if("br"===a.nodeName.toLowerCase())g(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)c(a);else if((3==b||4==b)&&f){var e=a.nodeValue,d=e.match(q);d&&(b=e.substring(0,d.index),a.nodeValue=b,(e=e.substring(d.index+
d[0].length))&&a.parentNode.insertBefore(m.createTextNode(e),a.nextSibling),g(a),b||a.parentNode.removeChild(a))}}function g(a){function c(a,b){var e=b?a.cloneNode(!1):a,n=a.parentNode;if(n){var n=c(n,1),d=a.nextSibling;n.appendChild(e);for(var f=d;f;f=d)d=f.nextSibling,n.appendChild(f)}return e}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;a=c(a.nextSibling,0);for(var e;(e=a.parentNode)&&1===e.nodeType;)a=e;b.push(a)}for(var p=/(?:^|\s)nocode(?:\s|$)/,q=/\r\n?|\n/,m=a.ownerDocument,k=m.createElement("li");a.firstChild;)k.appendChild(a.firstChild);
for(var b=[k],t=0;t<b.length;++t)c(b[t]);d===(d|0)&&b[0].setAttribute("value",d);var r=m.createElement("ol");r.className="linenums";d=Math.max(0,d-1|0)||0;for(var t=0,u=b.length;t<u;++t)k=b[t],k.className="L"+(t+d)%10,k.firstChild||k.appendChild(m.createTextNode("\u00a0")),r.appendChild(k);a.appendChild(r)}function r(a,d){for(var f=d.length;0<=--f;){var c=d[f];W.hasOwnProperty(c)?R.console&&console.warn("cannot override language handler %s",c):W[c]=a}}function G(a,d){a&&W.hasOwnProperty(a)||(a=/^\s*</.test(d)?
"default-markup":"default-code");return W[a]}function I(a){var d=a.j;try{var f=q(a.h,a.l),c=f.a;a.a=c;a.c=f.c;a.i=0;G(d,c)(a);var g=/\bMSIE\s(\d+)/.exec(navigator.userAgent),g=g&&8>=+g[1],d=/\n/g,p=a.a,k=p.length,f=0,m=a.c,r=m.length,c=0,b=a.g,t=b.length,x=0;b[t]=k;var u,e;for(e=u=0;e<t;)b[e]!==b[e+2]?(b[u++]=b[e++],b[u++]=b[e++]):e+=2;t=u;for(e=u=0;e<t;){for(var y=b[e],A=b[e+1],w=e+2;w+2<=t&&b[w+1]===A;)w+=2;b[u++]=y;b[u++]=A;e=w}b.length=u;var h=a.h;a="";h&&(a=h.style.display,h.style.display="none");
try{for(;c<r;){var l=m[c+2]||k,n=b[x+2]||k,w=Math.min(l,n),D=m[c+1],H;if(1!==D.nodeType&&(H=p.substring(f,w))){g&&(H=H.replace(d,"\r"));D.nodeValue=H;var aa=D.ownerDocument,v=aa.createElement("span");v.className=b[x+1];var C=D.parentNode;C.replaceChild(v,D);v.appendChild(D);f<l&&(m[c+1]=D=aa.createTextNode(p.substring(w,l)),C.insertBefore(D,v.nextSibling))}f=w;f>=l&&(c+=2);f>=n&&(x+=2)}}finally{h&&(h.style.display=a)}}catch(z){R.console&&console.log(z&&z.stack||z)}}var R="undefined"!==typeof window?
window:{},K=["break,continue,do,else,for,if,return,while"],L=[[K,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],S=[L,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],
M=[L,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],N=[L,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"],
L=[L,"abstract,async,await,constructor,debugger,enum,eval,export,from,function,get,import,implements,instanceof,interface,let,null,of,set,undefined,var,with,yield,Infinity,NaN"],O=[K,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],P=[K,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],
K=[K,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],Q=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,T=/\S/,U=x({keywords:[S,N,M,L,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",O,P,K],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),
W={};r(U,["default-code"]);r(F([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),"default-markup htm html mxml xhtml xml xsl".split(" "));r(F([["pln",/^[\s]+/,
null," \t\r\n"],["atv",/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],["pun",/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);
r(F([],[["atv",/^[\s\S]+/]]),["uq.val"]);r(x({keywords:S,hashComments:!0,cStyleComments:!0,types:Q}),"c cc cpp cxx cyc m".split(" "));r(x({keywords:"null,true,false"}),["json"]);r(x({keywords:N,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:Q}),["cs"]);r(x({keywords:M,cStyleComments:!0}),["java"]);r(x({keywords:K,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);r(x({keywords:O,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);r(x({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",
hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);r(x({keywords:P,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);r(x({keywords:L,cStyleComments:!0,regexLiterals:!0}),["javascript","js","ts","typescript"]);r(x({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,
regexLiterals:!0}),["coffee"]);r(F([],[["str",/^[\s\S]+/]]),["regex"]);var V=R.PR={createSimpleLexer:F,registerLangHandler:r,sourceDecorator:x,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:function(a,d,f){f=f||!1;d=d||null;var c=document.createElement("div");c.innerHTML="<pre>"+a+"</pre>";c=c.firstChild;
f&&C(c,f,!0);I({j:d,m:f,h:c,l:1,a:null,i:null,c:null,g:null});return c.innerHTML},prettyPrint:g=function(a,d){function f(){for(var c=R.PR_SHOULD_USE_CONTINUATION?b.now()+250:Infinity;t<p.length&&b.now()<c;t++){for(var d=p[t],k=h,q=d;q=q.previousSibling;){var m=q.nodeType,v=(7===m||8===m)&&q.nodeValue;if(v?!/^\??prettify\b/.test(v):3!==m||/\S/.test(q.nodeValue))break;if(v){k={};v.replace(/\b(\w+)=([\w:.%+-]+)/g,function(a,b,c){k[b]=c});break}}q=d.className;if(!e.test(q)){m=!1;for(v=d.parentNode;v;v=
v.parentNode)if(w.test(v.tagName)&&v.className&&u.test(v.className)){m=!0;break}if(!m){d.className+=" prettyprinted";m=k.lang;if(!m){var m=q.match(r),B;!m&&(B=A(d))&&y.test(B.tagName)&&(m=B.className.match(r));m&&(m=m[1])}if(x.test(d.tagName))v=1;else var v=d.currentStyle,z=g.defaultView,v=(v=v?v.whiteSpace:z&&z.getComputedStyle?z.getComputedStyle(d,null).getPropertyValue("white-space"):0)&&"pre"===v.substring(0,3);z=k.linenums;(z="true"===z||+z)||(z=(z=q.match(/\blinenums\b(?::(\d+))?/))?z[1]&&z[1].length?
+z[1]:!0:!1);z&&C(d,z,v);I({j:m,h:d,m:z,l:v,a:null,i:null,c:null,g:null})}}}t<p.length?R.setTimeout(f,250):"function"===typeof a&&a()}for(var c=d||document.body,g=c.ownerDocument||document,c=[c.getElementsByTagName("pre"),c.getElementsByTagName("code"),c.getElementsByTagName("xmp")],p=[],k=0;k<c.length;++k)for(var m=0,q=c[k].length;m<q;++m)p.push(c[k][m]);var c=null,b=Date;b.now||(b={now:function(){return+new Date}});var t=0,r=/\blang(?:uage)?-([\w.]+)(?!\S)/,u=/\bprettyprint\b/,e=/\bprettyprinted\b/,
x=/pre|xmp/i,y=/^code$/i,w=/^(?:pre|code|xmp)$/i,h={};f()}},S=R.define;"function"===typeof S&&S.amd&&S("google-code-prettify",[],function(){return V})})();return g}();U||q.setTimeout(V,0)})();}();
function GLTFireEvent(lang_pair, lang_dest){
try {
if(document.createEvent){
var event=document.createEvent("HTMLEvents");
event.initEvent(lang_dest, true, true);
lang_pair.dispatchEvent(event)
}else{
var event=document.createEventObject();
lang_pair.fireEvent('on' + lang_dest, event)
}} catch (e){}}
function GLTGetCurrentLang(){
var keyValue=document.cookie.match('(^|;) ?googtrans=([^;]*)(;|$)');
return keyValue ? keyValue[2].split('/')[2]:null;
}
function doGoogleLanguageTranslator(lang_pair){
if(window.glt_request_uri)
return true;
if(lang_pair.value)
lang_pair=lang_pair.value;
if(lang_pair=='')
return;
var lang=lang_pair.split('|')[1];
if(GLTGetCurrentLang()==null&&lang==lang_pair.split('|')[0])
return;
var teCombo=document.querySelector('select.goog-te-combo');
var teWrapper=document.getElementById('google_language_translator');
if(teWrapper==null||teWrapper.innerHTML.length==0||teCombo==null||teCombo.innerHTML.length==0){
setTimeout(function(){doGoogleLanguageTranslator(lang_pair)}, 500);
}else{
teCombo.value=lang;
GLTFireEvent(teCombo,'change');GLTFireEvent(teCombo,'change');
}}
jQuery(document).ready(function($){
$('#glt-translate-trigger,#glt-translate-trigger font').toolbar({
content: '#flags',
position: 'top',
hideOnClick: true,
event: 'click',
style: 'primary'
});
$('#glt-translate-trigger').on('toolbarItemClick',function(event){
$(this).removeClass('pressed');
});
});
if(typeof Object.create!=='function'){
Object.create=function(obj){
function F(){}
F.prototype=obj;
return new F();
};}
(function($, window, document, undefined){
var ToolBar={
init: function(options, elem){
var self=this;
self.elem=elem;
self.$elem=$(elem);
self.options=$.extend({}, $.fn.toolbar.options, options);
self.metadata=self.$elem.data();
self.overrideOptions();
self.toolbar=$('<div class="tool-container" />')
.addClass('tool-'+self.options.position)
.addClass('toolbar-'+self.options.style)
.append('<div class="tool-items" />')
.append('<div class="arrow" />')
.appendTo('body')
.css('opacity', 0)
.hide();
self.toolbar_arrow=self.toolbar.find('.arrow');
self.initializeToolbar();
},
overrideOptions: function(){
var self=this;
$.each(self.options, function($option){
if(typeof(self.$elem.data('toolbar-'+$option))!="undefined"){
self.options[$option]=self.$elem.data('toolbar-'+$option);
}});
},
initializeToolbar: function(){
var self=this;
self.populateContent();
self.setTrigger();
self.toolbarWidth=self.toolbar.width();
},
setTrigger: function(){
var self=this;
if(self.options.event=='onload'){
$(window).load(function(event){
event.preventDefault();
self.show();
});
}
if(self.options.event=='click'){
self.$elem.on('click', function(event){
event.preventDefault();
if(self.$elem.hasClass('pressed')){
self.hide();
}else{
self.show();
}});
if(self.options.hideOnClick){
$('html').on("click.toolbar", function(event){
if(event.target!=self.elem &&
self.$elem.has(event.target).length===0 &&
self.toolbar.has(event.target).length===0 &&
self.toolbar.is(":visible")){
self.hide();
}});
}}
if(self.options.hover){
var moveTime;
function decideTimeout (){
if(self.$elem.hasClass('pressed')){
moveTime=setTimeout(function(){
self.hide();
}, 150);
}else{
clearTimeout(moveTime);
};};
self.$elem.on({
mouseenter: function(event){
if(self.$elem.hasClass('pressed')){
clearTimeout(moveTime);
}else{
self.show();
}}
});
self.$elem.parent().on({
mouseleave: function(event){ decideTimeout(); }});
$('.tool-container').on({
mouseenter: function(event){ clearTimeout(moveTime); },
mouseleave: function(event){ decideTimeout(); }});
}
$(window).resize(function(event){
event.stopPropagation();
if(self.toolbar.is(":visible")){
self.toolbarCss=self.getCoordinates(self.options.position, 20);
self.collisionDetection();
self.toolbar.css(self.toolbarCss);
self.toolbar_arrow.css(self.arrowCss);
}});
},
populateContent: function(){
var self=this;
var location=self.toolbar.find('.tool-items');
var content=$(self.options.content).clone(true).find('a').addClass('tool-item');
location.html(content);
location.find('.tool-item').on('click', function(event){
if(typeof window.glt_request_uri=='undefined')
event.preventDefault();
self.$elem.trigger('toolbarItemClick', this);
});
},
calculatePosition: function(){
var self=this;
self.arrowCss={};
self.toolbarCss=self.getCoordinates(self.options.position, self.options.adjustment);
self.toolbarCss.position='fixed';
self.toolbarCss.zIndex=self.options.zIndex;
self.collisionDetection();
self.toolbar.css(self.toolbarCss);
self.toolbar_arrow.css(self.arrowCss);
},
getCoordinates: function(position, adjustment){
var self=this;
self.coordinates=self.$elem.offset();
if(self.options.adjustment&&self.options.adjustment[self.options.position]){
adjustment=self.options.adjustment[self.options.position] + adjustment;
}
switch(self.options.position){
case 'top':
return {
left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
top: self.coordinates.top-self.$elem.outerHeight()-adjustment,
right: 'auto'
};
case 'left':
return {
left: self.coordinates.left-(self.toolbar.width()/2)-(self.$elem.outerWidth()/2)-adjustment,
top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
right: 'auto'
};
case 'right':
return {
left: self.coordinates.left+(self.toolbar.width()/2)+(self.$elem.outerWidth()/2)+adjustment,
top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
right: 'auto'
};
case 'bottom':
return {
left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
top: self.coordinates.top+self.$elem.outerHeight()+adjustment,
right: 'auto'
};}},
collisionDetection: function(){
var self=this;
var edgeOffset=20;
if(self.options.position=='top'||self.options.position=='bottom'){
self.arrowCss={left: '50%', right: '50%'};
if(self.toolbarCss.left < edgeOffset){
self.toolbarCss.left=edgeOffset;
self.arrowCss.left=self.$elem.offset().left + self.$elem.width()/2-(edgeOffset);
}
else if(($(window).width() - (self.toolbarCss.left + self.toolbarWidth)) < edgeOffset){
self.toolbarCss.right=edgeOffset;
self.toolbarCss.left='auto';
self.arrowCss.left='auto';
self.arrowCss.right=($(window).width()-self.$elem.offset().left)-(self.$elem.width()/2)-(edgeOffset)-5;
}}
},
show: function(){
var self=this;
self.$elem.addClass('pressed');
self.calculatePosition();
self.toolbar.show().css({'opacity': 1}).addClass('animate-'+self.options.animation);
self.$elem.trigger('toolbarShown');
},
hide: function(){
var self=this;
var animation={'opacity': 0};
self.$elem.removeClass('pressed');
switch(self.options.position){
case 'top':
animation.top='+=20';
break;
case 'left':
animation.left='+=20';
break;
case 'right':
animation.left='-=20';
break;
case 'bottom':
animation.top='-=20';
break;
}
self.toolbar.animate(animation, 200, function(){
self.toolbar.hide();
});
self.$elem.trigger('toolbarHidden');
},
getToolbarElement: function (){
return this.toolbar.find('.tool-items');
}};
$.fn.toolbar=function(options){
if($.isPlainObject(options)){
return this.each(function(){
var toolbarObj=Object.create(ToolBar);
toolbarObj.init(options, this);
$(this).data('toolbarObj', toolbarObj);
});
}else if(typeof options==='string'&&options.indexOf('_')!==0){
var toolbarObj=$(this).data('toolbarObj');
var method=toolbarObj[options];
return method.apply(toolbarObj, $.makeArray(arguments).slice(1));
}};
$.fn.toolbar.options={
content: '#myContent',
position: 'top',
hideOnClick: false,
zIndex: 120,
hover: false,
style: 'default',
animation: 'standard',
adjustment: 10
};})(jQuery, window, document);
jQuery(function($){
$('#flags a, a.single-language, .tool-items a').each(function(){
$(this).attr('data-lang', $(this).attr('title'));
});
$(document.body).on("click", "a.flag", function(){
lang_text=$(this).attr('data-lang');
default_lang=window.glt_default_lang||$('#google_language_translator').attr('class').split("-").pop();
lang_prefix=$(this).attr("class").split(" ")[2];
lang_prefix==default_lang ? l():n();
function l(){
doGoogleLanguageTranslator(default_lang + "|" + default_lang);
}
function n(){
doGoogleLanguageTranslator(default_lang + "|" + lang_prefix);
}
$(".tool-container").hide();
});
if(window.glt_request_uri){
$('#google_language_translator select').on('change', function(){
doGLTTranslate($(this).val());
})
}});