5741 行
350 KiB
JavaScript
可执行文件
5741 行
350 KiB
JavaScript
可执行文件
|
||
/**
|
||
* @preserve
|
||
* Project: Bootstrap Hover Dropdown
|
||
* Author: Cameron Spear
|
||
* Version: v2.2.1
|
||
* Contributors: Mattia Larentis
|
||
* Dependencies: Bootstrap's Dropdown plugin, jQuery
|
||
* Description: A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience.
|
||
* License: MIT
|
||
* Homepage: http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
|
||
*/
|
||
!function(e,n){var o=e();e.fn.dropdownHover=function(t){return"ontouchstart"in document?this:(o=o.add(this.parent()),this.each(function(){function r(){d.parents(".navbar").find(".navbar-toggle").is(":visible")||(n.clearTimeout(a),n.clearTimeout(i),i=n.setTimeout(function(){o.find(":focus").blur(),v.instantlyCloseOthers===!0&&o.removeClass("open"),n.clearTimeout(i),d.attr("aria-expanded","true"),s.addClass("open"),d.trigger(h)},v.hoverDelay))}var a,i,d=e(this),s=d.parent(),u={delay:500,hoverDelay:0,instantlyCloseOthers:!0},l={delay:e(this).data("delay"),hoverDelay:e(this).data("hover-delay"),instantlyCloseOthers:e(this).data("close-others")},h="show.bs.dropdown",c="hide.bs.dropdown",v=e.extend(!0,{},u,t,l);s.hover(function(e){return s.hasClass("open")||d.is(e.target)?void r(e):!0},function(){n.clearTimeout(i),a=n.setTimeout(function(){d.attr("aria-expanded","false"),s.removeClass("open"),d.trigger(c)},v.delay)}),d.hover(function(e){return s.hasClass("open")||s.is(e.target)?void r(e):!0}),s.find(".dropdown-submenu").each(function(){var o,t=e(this);t.hover(function(){n.clearTimeout(o),t.children(".dropdown-menu").show(),t.siblings().children(".dropdown-menu").hide()},function(){var e=t.children(".dropdown-menu");o=n.setTimeout(function(){e.hide()},v.delay)})})}))},e(document).ready(function(){e('[data-hover="dropdown"]').dropdownHover()})}(jQuery,window);
|
||
! function(a) {
|
||
"use strict";
|
||
"function" == typeof define && define.amd ? define(["jquery"], a) : "undefined" != typeof exports ? module.exports = a(require("jquery")) : a(jQuery)
|
||
}(function(a) {
|
||
"use strict";
|
||
var b = window.Slick || {};
|
||
b = function() {
|
||
function c(c, d) {
|
||
var f, e = this;
|
||
e.defaults = {
|
||
accessibility: !0,
|
||
adaptiveHeight: !1,
|
||
appendArrows: a(c),
|
||
appendDots: a(c),
|
||
arrows: !0,
|
||
asNavFor: null,
|
||
prevArrow: '<button type="button" data-role="none" class="slick-prev" aria-label="Previous" tabindex="0" role="button">Previous</button>',
|
||
nextArrow: '<button type="button" data-role="none" class="slick-next" aria-label="Next" tabindex="0" role="button">Next</button>',
|
||
autoplay: !1,
|
||
autoplaySpeed: 3e3,
|
||
centerMode: !1,
|
||
centerPadding: "50px",
|
||
cssEase: "ease",
|
||
customPaging: function(b, c) {
|
||
return a('<button type="button" data-role="none" role="button" tabindex="0" />').text(c + 1)
|
||
},
|
||
dots: !0,
|
||
dotsClass: "slick-dots",
|
||
draggable: !0,
|
||
easing: "linear",
|
||
edgeFriction: .35,
|
||
fade: !1,
|
||
focusOnSelect: !1,
|
||
infinite: !0,
|
||
initialSlide: 0,
|
||
lazyLoad: "ondemand",
|
||
placeHolder: met_lazyloadbg,
|
||
lazyloadPrevNext:!1,
|
||
mobileFirst: !1,
|
||
pauseOnHover: !0,
|
||
pauseOnFocus: !0,
|
||
pauseOnDotsHover: !1,
|
||
respondTo: "window",
|
||
responsive: null,
|
||
rows: 1,
|
||
rtl: !1,
|
||
slide: "",
|
||
slidesPerRow: 1,
|
||
slidesToShow: 1,
|
||
slidesToScroll: 1,
|
||
speed: 500,
|
||
swipe: !0,
|
||
swipeToSlide: !1,
|
||
touchMove: !0,
|
||
touchThreshold: 5,
|
||
useCSS: !0,
|
||
useTransform: !0,
|
||
variableWidth: !1,
|
||
vertical: !1,
|
||
verticalSwiping: !1,
|
||
waitForAnimate: !0,
|
||
zIndex: 1e3
|
||
}, e.initials = {
|
||
animating: !1,
|
||
dragging: !1,
|
||
autoPlayTimer: null,
|
||
currentDirection: 0,
|
||
currentLeft: null,
|
||
currentSlide: 0,
|
||
direction: 1,
|
||
$dots: null,
|
||
listWidth: null,
|
||
listHeight: null,
|
||
loadIndex: 0,
|
||
$nextArrow: null,
|
||
$prevArrow: null,
|
||
slideCount: null,
|
||
slideWidth: null,
|
||
$slideTrack: null,
|
||
$slides: null,
|
||
sliding: !1,
|
||
slideOffset: 0,
|
||
swipeLeft: null,
|
||
$list: null,
|
||
touchObject: {},
|
||
transformsEnabled: !1,
|
||
unslicked: !1
|
||
}, a.extend(e, e.initials), e.activeBreakpoint = null, e.animType = null, e.animProp = null, e.breakpoints = [], e.breakpointSettings = [], e.cssTransitions = !1, e.focussed = !1, e.interrupted = !1, e.hidden = "hidden", e.paused = !0, e.positionProp = null, e.respondTo = null, e.rowCount = 1, e.shouldClick = !0, e.$slider = a(c), e.$slidesCache = null, e.transformType = null, e.transitionType = null, e.visibilityChange = "visibilitychange", e.windowWidth = 0, e.windowTimer = null, f = a(c).data("slick") || {}, e.options = a.extend({}, e.defaults, d, f), e.currentSlide = e.options.initialSlide, e.originalSettings = e.options, "undefined" != typeof document.mozHidden ? (e.hidden = "mozHidden", e.visibilityChange = "mozvisibilitychange") : "undefined" != typeof document.webkitHidden && (e.hidden = "webkitHidden", e.visibilityChange = "webkitvisibilitychange"), e.autoPlay = a.proxy(e.autoPlay, e), e.autoPlayClear = a.proxy(e.autoPlayClear, e), e.autoPlayIterator = a.proxy(e.autoPlayIterator, e), e.changeSlide = a.proxy(e.changeSlide, e), e.clickHandler = a.proxy(e.clickHandler, e), e.selectHandler = a.proxy(e.selectHandler, e), e.setPosition = a.proxy(e.setPosition, e), e.swipeHandler = a.proxy(e.swipeHandler, e), e.dragHandler = a.proxy(e.dragHandler, e), e.keyHandler = a.proxy(e.keyHandler, e), e.instanceUid = b++, e.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/, e.registerBreakpoints(), e.init(!0)
|
||
}
|
||
var b = 0;
|
||
return c
|
||
}(), b.prototype.activateADA = function() {
|
||
var a = this;
|
||
a.$slideTrack.find(".slick-active").attr({
|
||
"aria-hidden": "false"
|
||
}).find("a, input, button, select").attr({
|
||
tabindex: "0"
|
||
})
|
||
}, b.prototype.addSlide = b.prototype.slickAdd = function(b, c, d) {
|
||
var e = this;
|
||
if ("boolean" == typeof c) d = c, c = null;
|
||
else if (0 > c || c >= e.slideCount) return !1;
|
||
e.unload(), "number" == typeof c ? 0 === c && 0 === e.$slides.length ? a(b).appendTo(e.$slideTrack) : d ? a(b).insertBefore(e.$slides.eq(c)) : a(b).insertAfter(e.$slides.eq(c)) : d === !0 ? a(b).prependTo(e.$slideTrack) : a(b).appendTo(e.$slideTrack), e.$slides = e.$slideTrack.children(this.options.slide), e.$slideTrack.children(this.options.slide).detach(), e.$slideTrack.append(e.$slides), e.$slides.each(function(b, c) {
|
||
a(c).attr("data-slick-index", b)
|
||
}), e.$slidesCache = e.$slides, e.reinit()
|
||
}, b.prototype.animateHeight = function() {
|
||
var a = this;
|
||
if (1 === a.options.slidesToShow && a.options.adaptiveHeight === !0 && a.options.vertical === !1) {
|
||
var b = a.$slides.eq(a.currentSlide).outerHeight(!0);
|
||
a.$list.animate({
|
||
height: b
|
||
}, a.options.speed)
|
||
}
|
||
}, b.prototype.animateSlide = function(b, c) {
|
||
var d = {},
|
||
e = this;
|
||
e.animateHeight(), e.options.rtl === !0 && e.options.vertical === !1 && (b = -b), e.transformsEnabled === !1 ? e.options.vertical === !1 ? e.$slideTrack.animate({
|
||
left: b
|
||
}, e.options.speed, e.options.easing, c) : e.$slideTrack.animate({
|
||
top: b
|
||
}, e.options.speed, e.options.easing, c) : e.cssTransitions === !1 ? (e.options.rtl === !0 && (e.currentLeft = -e.currentLeft), a({
|
||
animStart: e.currentLeft
|
||
}).animate({
|
||
animStart: b
|
||
}, {
|
||
duration: e.options.speed,
|
||
easing: e.options.easing,
|
||
step: function(a) {
|
||
a = Math.ceil(a), e.options.vertical === !1 ? (d[e.animType] = "translate(" + a + "px, 0px)", e.$slideTrack.css(d)) : (d[e.animType] = "translate(0px," + a + "px)", e.$slideTrack.css(d))
|
||
},
|
||
complete: function() {
|
||
c && c.call()
|
||
}
|
||
})) : (e.applyTransition(), b = Math.ceil(b), e.options.vertical === !1 ? d[e.animType] = "translate3d(" + b + "px, 0px, 0px)" : d[e.animType] = "translate3d(0px," + b + "px, 0px)", e.$slideTrack.css(d), c && setTimeout(function() {
|
||
e.disableTransition(), c.call()
|
||
}, e.options.speed))
|
||
}, b.prototype.getNavTarget = function() {
|
||
var b = this,
|
||
c = b.options.asNavFor;
|
||
return c && null !== c && (c = a(c).not(b.$slider)), c
|
||
}, b.prototype.asNavFor = function(b) {
|
||
var c = this,
|
||
d = c.getNavTarget();
|
||
null !== d && "object" == typeof d && d.each(function() {
|
||
var c = a(this).slick("getSlick");
|
||
c.unslicked || c.slideHandler(b, !0)
|
||
})
|
||
}, b.prototype.applyTransition = function(a) {
|
||
var b = this,
|
||
c = {};
|
||
b.options.fade === !1 ? c[b.transitionType] = b.transformType + " " + b.options.speed + "ms " + b.options.cssEase : c[b.transitionType] = "opacity " + b.options.speed + "ms " + b.options.cssEase, b.options.fade === !1 ? b.$slideTrack.css(c) : b.$slides.eq(a).css(c)
|
||
}, b.prototype.autoPlay = function() {
|
||
var a = this;
|
||
a.autoPlayClear(), a.slideCount > a.options.slidesToShow && (a.autoPlayTimer = setInterval(a.autoPlayIterator, a.options.autoplaySpeed))
|
||
}, b.prototype.autoPlayClear = function() {
|
||
var a = this;
|
||
a.autoPlayTimer && clearInterval(a.autoPlayTimer)
|
||
}, b.prototype.autoPlayIterator = function() {
|
||
var a = this,
|
||
b = a.currentSlide + a.options.slidesToScroll;
|
||
a.paused || a.interrupted || a.focussed || (a.options.infinite === !1 && (1 === a.direction && a.currentSlide + 1 === a.slideCount - 1 ? a.direction = 0 : 0 === a.direction && (b = a.currentSlide - a.options.slidesToScroll, a.currentSlide - 1 === 0 && (a.direction = 1))), a.slideHandler(b))
|
||
}, b.prototype.buildArrows = function() {
|
||
var b = this;
|
||
b.options.arrows === !0 && (b.$prevArrow = a(b.options.prevArrow).addClass("slick-arrow"), b.$nextArrow = a(b.options.nextArrow).addClass("slick-arrow"), b.slideCount > b.options.slidesToShow ? (b.$prevArrow.removeClass("slick-hidden").removeAttr("aria-hidden tabindex"), b.$nextArrow.removeClass("slick-hidden").removeAttr("aria-hidden tabindex"), b.htmlExpr.test(b.options.prevArrow) && b.$prevArrow.prependTo(b.options.appendArrows), b.htmlExpr.test(b.options.nextArrow) && b.$nextArrow.appendTo(b.options.appendArrows), b.options.infinite !== !0 && b.$prevArrow.addClass("slick-disabled").attr("aria-disabled", "true")) : b.$prevArrow.add(b.$nextArrow).addClass("slick-hidden").attr({
|
||
"aria-disabled": "true",
|
||
tabindex: "-1"
|
||
}))
|
||
}, b.prototype.buildDots = function() {
|
||
var c, d, b = this;
|
||
if (b.options.dots === !0 && b.slideCount > b.options.slidesToShow) {
|
||
for (b.$slider.addClass("slick-dotted"), d = a("<ul />").addClass(b.options.dotsClass), c = 0; c <= b.getDotCount(); c += 1) d.append(a("<li />").append(b.options.customPaging.call(this, b, c)));
|
||
b.$dots = d.appendTo(b.options.appendDots), b.$dots.find("li").first().addClass("slick-active").attr("aria-hidden", "false")
|
||
}
|
||
}, b.prototype.buildOut = function() {
|
||
var b = this;
|
||
b.$slides = b.$slider.children(b.options.slide + ":not(.slick-cloned)").addClass("slick-slide"), b.slideCount = b.$slides.length, b.$slides.each(function(b, c) {
|
||
a(c).attr("data-slick-index", b).data("originalStyling", a(c).attr("style") || "")
|
||
}), b.$slider.addClass("slick-slider"), b.$slideTrack = 0 === b.slideCount ? a('<div class="slick-track"/>').appendTo(b.$slider) : b.$slides.wrapAll('<div class="slick-track"/>').parent(), b.$list = b.$slideTrack.wrap('<div aria-live="polite" class="slick-list"/>').parent(), b.$slideTrack.css("opacity", 0), (b.options.centerMode === !0 || b.options.swipeToSlide === !0) && (b.options.slidesToScroll = 1), a("img[data-lazy]", b.$slider).not("[src]").addClass("slick-loading"), b.setupInfinite(), b.buildArrows(), b.buildDots(), b.updateDots(), b.setSlideClasses("number" == typeof b.currentSlide ? b.currentSlide : 0), b.options.draggable === !0 && b.$list.addClass("draggable")
|
||
}, b.prototype.buildRows = function() {
|
||
var b, c, d, e, f, g, h, a = this;
|
||
if (e = document.createDocumentFragment(), g = a.$slider.children(), a.options.rows > 1) {
|
||
for (h = a.options.slidesPerRow * a.options.rows, f = Math.ceil(g.length / h), b = 0; f > b; b++) {
|
||
var i = document.createElement("div");
|
||
for (c = 0; c < a.options.rows; c++) {
|
||
var j = document.createElement("div");
|
||
for (d = 0; d < a.options.slidesPerRow; d++) {
|
||
var k = b * h + (c * a.options.slidesPerRow + d);
|
||
g.get(k) && j.appendChild(g.get(k))
|
||
}
|
||
i.appendChild(j)
|
||
}
|
||
e.appendChild(i)
|
||
}
|
||
a.$slider.empty().append(e), a.$slider.children().children().children().css({
|
||
width: 100 / a.options.slidesPerRow + "%",
|
||
display: "inline-block"
|
||
})
|
||
}
|
||
}, b.prototype.checkResponsive = function(b, c) {
|
||
var e, f, g, d = this,
|
||
h = !1,
|
||
i = d.$slider.width(),
|
||
j = window.innerWidth || a(window).width();
|
||
if ("window" === d.respondTo ? g = j : "slider" === d.respondTo ? g = i : "min" === d.respondTo && (g = Math.min(j, i)), d.options.responsive && d.options.responsive.length && null !== d.options.responsive) {
|
||
f = null;
|
||
for (e in d.breakpoints) d.breakpoints.hasOwnProperty(e) && (d.originalSettings.mobileFirst === !1 ? g < d.breakpoints[e] && (f = d.breakpoints[e]) : g > d.breakpoints[e] && (f = d.breakpoints[e]));
|
||
null !== f ? null !== d.activeBreakpoint ? (f !== d.activeBreakpoint || c) && (d.activeBreakpoint = f, "unslick" === d.breakpointSettings[f] ? d.unslick(f) : (d.options = a.extend({}, d.originalSettings, d.breakpointSettings[f]), b === !0 && (d.currentSlide = d.options.initialSlide), d.refresh(b)), h = f) : (d.activeBreakpoint = f, "unslick" === d.breakpointSettings[f] ? d.unslick(f) : (d.options = a.extend({}, d.originalSettings, d.breakpointSettings[f]), b === !0 && (d.currentSlide = d.options.initialSlide), d.refresh(b)), h = f) : null !== d.activeBreakpoint && (d.activeBreakpoint = null, d.options = d.originalSettings, b === !0 && (d.currentSlide = d.options.initialSlide), d.refresh(b), h = f), b || h === !1 || d.$slider.trigger("breakpoint", [d, h])
|
||
}
|
||
}, b.prototype.changeSlide = function(b, c) {
|
||
var f, g, h, d = this,
|
||
e = a(b.currentTarget);
|
||
switch (e.is("a") && b.preventDefault(), e.is("li") || (e = e.closest("li")), h = d.slideCount % d.options.slidesToScroll !== 0, f = h ? 0 : (d.slideCount - d.currentSlide) % d.options.slidesToScroll, b.data.message) {
|
||
case "previous":
|
||
g = 0 === f ? d.options.slidesToScroll : d.options.slidesToShow - f, d.slideCount > d.options.slidesToShow && d.slideHandler(d.currentSlide - g, !1, c);
|
||
break;
|
||
case "next":
|
||
g = 0 === f ? d.options.slidesToScroll : f, d.slideCount > d.options.slidesToShow && d.slideHandler(d.currentSlide + g, !1, c);
|
||
break;
|
||
case "index":
|
||
var i = 0 === b.data.index ? 0 : b.data.index || e.index() * d.options.slidesToScroll;
|
||
d.slideHandler(d.checkNavigable(i), !1, c), e.children().trigger("focus");
|
||
break;
|
||
default:
|
||
return
|
||
}
|
||
}, b.prototype.checkNavigable = function(a) {
|
||
var c, d, b = this;
|
||
if (c = b.getNavigableIndexes(), d = 0, a > c[c.length - 1]) a = c[c.length - 1];
|
||
else
|
||
for (var e in c) {
|
||
if (a < c[e]) {
|
||
a = d;
|
||
break
|
||
}
|
||
d = c[e]
|
||
}
|
||
return a
|
||
}, b.prototype.cleanUpEvents = function() {
|
||
var b = this;
|
||
b.options.dots && null !== b.$dots && a("li", b.$dots).off("click.slick", b.changeSlide).off("mouseenter.slick", a.proxy(b.interrupt, b, !0)).off("mouseleave.slick", a.proxy(b.interrupt, b, !1)), b.$slider.off("focus.slick blur.slick"), b.options.arrows === !0 && b.slideCount > b.options.slidesToShow && (b.$prevArrow && b.$prevArrow.off("click.slick", b.changeSlide), b.$nextArrow && b.$nextArrow.off("click.slick", b.changeSlide)), b.$list.off("touchstart.slick mousedown.slick", b.swipeHandler), b.$list.off("touchmove.slick mousemove.slick", b.swipeHandler), b.$list.off("touchend.slick mouseup.slick", b.swipeHandler), b.$list.off("touchcancel.slick mouseleave.slick", b.swipeHandler), b.$list.off("click.slick", b.clickHandler), a(document).off(b.visibilityChange, b.visibility), b.cleanUpSlideEvents(), b.options.accessibility === !0 && b.$list.off("keydown.slick", b.keyHandler), b.options.focusOnSelect === !0 && a(b.$slideTrack).children().off("click.slick", b.selectHandler), a(window).off("orientationchange.slick.slick-" + b.instanceUid, b.orientationChange), a(window).off("resize.slick.slick-" + b.instanceUid, b.resize), a("[draggable!=true]", b.$slideTrack).off("dragstart", b.preventDefault), a(window).off("load.slick.slick-" + b.instanceUid, b.setPosition), a(document).off("ready.slick.slick-" + b.instanceUid, b.setPosition)
|
||
}, b.prototype.cleanUpSlideEvents = function() {
|
||
var b = this;
|
||
b.$list.off("mouseenter.slick", a.proxy(b.interrupt, b, !0)), b.$list.off("mouseleave.slick", a.proxy(b.interrupt, b, !1))
|
||
}, b.prototype.cleanUpRows = function() {
|
||
var b, a = this;
|
||
a.options.rows > 1 && (b = a.$slides.children().children(), b.removeAttr("style"), a.$slider.empty().append(b))
|
||
}, b.prototype.clickHandler = function(a) {
|
||
var b = this;
|
||
b.shouldClick === !1 && (a.stopImmediatePropagation(), a.stopPropagation(), a.preventDefault())
|
||
}, b.prototype.destroy = function(b) {
|
||
var c = this;
|
||
c.autoPlayClear(), c.touchObject = {}, c.cleanUpEvents(), a(".slick-cloned", c.$slider).detach(), c.$dots && c.$dots.remove(), c.$prevArrow && c.$prevArrow.length && (c.$prevArrow.removeClass("slick-disabled slick-arrow slick-hidden").removeAttr("aria-hidden aria-disabled tabindex").css("display", ""), c.htmlExpr.test(c.options.prevArrow) && c.$prevArrow.remove()), c.$nextArrow && c.$nextArrow.length && (c.$nextArrow.removeClass("slick-disabled slick-arrow slick-hidden").removeAttr("aria-hidden aria-disabled tabindex").css("display", ""), c.htmlExpr.test(c.options.nextArrow) && c.$nextArrow.remove()), c.$slides && (c.$slides.removeClass("slick-slide slick-active slick-center slick-visible slick-current").removeAttr("aria-hidden").removeAttr("data-slick-index").each(function() {
|
||
a(this).attr("style", a(this).data("originalStyling"))
|
||
}), c.$slideTrack.children(this.options.slide).detach(), c.$slideTrack.detach(), c.$list.detach(), c.$slider.append(c.$slides)), c.cleanUpRows(), c.$slider.removeClass("slick-slider"), c.$slider.removeClass("slick-initialized"), c.$slider.removeClass("slick-dotted"), c.unslicked = !0, b || c.$slider.trigger("destroy", [c])
|
||
}, b.prototype.disableTransition = function(a) {
|
||
var b = this,
|
||
c = {};
|
||
c[b.transitionType] = "", b.options.fade === !1 ? b.$slideTrack.css(c) : b.$slides.eq(a).css(c)
|
||
}, b.prototype.fadeSlide = function(a, b) {
|
||
var c = this;
|
||
c.cssTransitions === !1 ? (c.$slides.eq(a).css({
|
||
zIndex: c.options.zIndex
|
||
}), c.$slides.eq(a).animate({
|
||
opacity: 1
|
||
}, c.options.speed, c.options.easing, b)) : (c.applyTransition(a), c.$slides.eq(a).css({
|
||
opacity: 1,
|
||
zIndex: c.options.zIndex
|
||
}), b && setTimeout(function() {
|
||
c.disableTransition(a), b.call()
|
||
}, c.options.speed))
|
||
}, b.prototype.fadeSlideOut = function(a) {
|
||
var b = this;
|
||
b.cssTransitions === !1 ? b.$slides.eq(a).animate({
|
||
opacity: 0,
|
||
zIndex: b.options.zIndex - 2
|
||
}, b.options.speed, b.options.easing) : (b.applyTransition(a), b.$slides.eq(a).css({
|
||
opacity: 0,
|
||
zIndex: b.options.zIndex - 2
|
||
}))
|
||
}, b.prototype.filterSlides = b.prototype.slickFilter = function(a) {
|
||
var b = this;
|
||
null !== a && (b.$slidesCache = b.$slides, b.unload(), b.$slideTrack.children(this.options.slide).detach(), b.$slidesCache.filter(a).appendTo(b.$slideTrack), b.reinit())
|
||
}, b.prototype.focusHandler = function() {
|
||
var b = this;
|
||
b.$slider.off("focus.slick blur.slick").on("focus.slick blur.slick", "*:not(.slick-arrow)", function(c) {
|
||
c.stopImmediatePropagation();
|
||
var d = a(this);
|
||
setTimeout(function() {
|
||
b.options.pauseOnFocus && (b.focussed = d.is(":focus"), b.autoPlay())
|
||
}, 0)
|
||
})
|
||
}, b.prototype.getCurrent = b.prototype.slickCurrentSlide = function() {
|
||
var a = this;
|
||
return a.currentSlide
|
||
}, b.prototype.getDotCount = function() {
|
||
var a = this,
|
||
b = 0,
|
||
c = 0,
|
||
d = 0;
|
||
if (a.options.infinite === !0)
|
||
for (; b < a.slideCount;) ++d, b = c + a.options.slidesToScroll, c += a.options.slidesToScroll <= a.options.slidesToShow ? a.options.slidesToScroll : a.options.slidesToShow;
|
||
else if (a.options.centerMode === !0) d = a.slideCount;
|
||
else if (a.options.asNavFor)
|
||
for (; b < a.slideCount;) ++d, b = c + a.options.slidesToScroll, c += a.options.slidesToScroll <= a.options.slidesToShow ? a.options.slidesToScroll : a.options.slidesToShow;
|
||
else d = 1 + Math.ceil((a.slideCount - a.options.slidesToShow) / a.options.slidesToScroll);
|
||
return d - 1
|
||
}, b.prototype.getLeft = function(a) {
|
||
var c, d, f, b = this,
|
||
e = 0;
|
||
return b.slideOffset = 0, d = b.$slides.first().outerHeight(!0), b.options.infinite === !0 ? (b.slideCount > b.options.slidesToShow && (b.slideOffset = b.slideWidth * b.options.slidesToShow * -1, e = d * b.options.slidesToShow * -1), b.slideCount % b.options.slidesToScroll !== 0 && a + b.options.slidesToScroll > b.slideCount && b.slideCount > b.options.slidesToShow && (a > b.slideCount ? (b.slideOffset = (b.options.slidesToShow - (a - b.slideCount)) * b.slideWidth * -1, e = (b.options.slidesToShow - (a - b.slideCount)) * d * -1) : (b.slideOffset = b.slideCount % b.options.slidesToScroll * b.slideWidth * -1, e = b.slideCount % b.options.slidesToScroll * d * -1))) : a + b.options.slidesToShow > b.slideCount && (b.slideOffset = (a + b.options.slidesToShow - b.slideCount) * b.slideWidth, e = (a + b.options.slidesToShow - b.slideCount) * d), b.slideCount <= b.options.slidesToShow && (b.slideOffset = 0, e = 0), b.options.centerMode === !0 && b.options.infinite === !0 ? b.slideOffset += b.slideWidth * Math.floor(b.options.slidesToShow / 2) - b.slideWidth : b.options.centerMode === !0 && (b.slideOffset = 0, b.slideOffset += b.slideWidth * Math.floor(b.options.slidesToShow / 2)), c = b.options.vertical === !1 ? a * b.slideWidth * -1 + b.slideOffset : a * d * -1 + e, b.options.variableWidth === !0 && (f = b.slideCount <= b.options.slidesToShow || b.options.infinite === !1 ? b.$slideTrack.children(".slick-slide").eq(a) : b.$slideTrack.children(".slick-slide").eq(a + b.options.slidesToShow), c = b.options.rtl === !0 ? f[0] ? -1 * (b.$slideTrack.width() - f[0].offsetLeft - f.width()) : 0 : f[0] ? -1 * f[0].offsetLeft : 0, b.options.centerMode === !0 && (f = b.slideCount <= b.options.slidesToShow || b.options.infinite === !1 ? b.$slideTrack.children(".slick-slide").eq(a) : b.$slideTrack.children(".slick-slide").eq(a + b.options.slidesToShow + 1), c = b.options.rtl === !0 ? f[0] ? -1 * (b.$slideTrack.width() - f[0].offsetLeft - f.width()) : 0 : f[0] ? -1 * f[0].offsetLeft : 0, c += (b.$list.width() - f.outerWidth()) / 2)), c
|
||
}, b.prototype.getOption = b.prototype.slickGetOption = function(a) {
|
||
var b = this;
|
||
return b.options[a]
|
||
}, b.prototype.getNavigableIndexes = function() {
|
||
var e, a = this,
|
||
b = 0,
|
||
c = 0,
|
||
d = [];
|
||
for (a.options.infinite === !1 ? e = a.slideCount : (b = -1 * a.options.slidesToScroll, c = -1 * a.options.slidesToScroll, e = 2 * a.slideCount); e > b;) d.push(b), b = c + a.options.slidesToScroll, c += a.options.slidesToScroll <= a.options.slidesToShow ? a.options.slidesToScroll : a.options.slidesToShow;
|
||
return d
|
||
}, b.prototype.getSlick = function() {
|
||
return this
|
||
}, b.prototype.getSlideCount = function() {
|
||
var c, d, e, b = this;
|
||
return e = b.options.centerMode === !0 ? b.slideWidth * Math.floor(b.options.slidesToShow / 2) : 0, b.options.swipeToSlide === !0 ? (b.$slideTrack.find(".slick-slide").each(function(c, f) {
|
||
return f.offsetLeft - e + a(f).outerWidth() / 2 > -1 * b.swipeLeft ? (d = f, !1) : void 0
|
||
}), c = Math.abs(a(d).attr("data-slick-index") - b.currentSlide) || 1) : b.options.slidesToScroll
|
||
}, b.prototype.goTo = b.prototype.slickGoTo = function(a, b) {
|
||
var c = this;
|
||
c.changeSlide({
|
||
data: {
|
||
message: "index",
|
||
index: parseInt(a)
|
||
}
|
||
}, b)
|
||
}, b.prototype.init = function(b) {
|
||
var c = this;
|
||
a(c.$slider).hasClass("slick-initialized") || (a(c.$slider).addClass("slick-initialized"), c.buildRows(), c.buildOut(), c.setProps(), c.startLoad(), c.loadSlider(), c.initializeEvents(), c.updateArrows(), c.updateDots(), c.checkResponsive(!0), c.focusHandler()), b && c.$slider.trigger("init", [c]), c.options.accessibility === !0 && c.initADA(), c.options.autoplay && (c.paused = !1, c.autoPlay())
|
||
}, b.prototype.initADA = function() {
|
||
var b = this;
|
||
b.$slides.add(b.$slideTrack.find(".slick-cloned")).attr({
|
||
"aria-hidden": "true",
|
||
tabindex: "-1"
|
||
}).find("a, input, button, select").attr({
|
||
tabindex: "-1"
|
||
}), b.$slideTrack.attr("role", "listbox"), b.$slides.not(b.$slideTrack.find(".slick-cloned")).each(function(c) {
|
||
a(this).attr({
|
||
role: "option",
|
||
"aria-describedby": "slick-slide" + b.instanceUid + c
|
||
})
|
||
}), null !== b.$dots && b.$dots.attr("role", "tablist").find("li").each(function(c) {
|
||
a(this).attr({
|
||
role: "presentation",
|
||
"aria-selected": "false",
|
||
"aria-controls": "navigation" + b.instanceUid + c,
|
||
id: "slick-slide" + b.instanceUid + c
|
||
})
|
||
}).first().attr("aria-selected", "true").end().find("button").attr("role", "button").end().closest("div").attr("role", "toolbar"), b.activateADA()
|
||
}, b.prototype.initArrowEvents = function() {
|
||
var a = this;
|
||
a.options.arrows === !0 && a.slideCount > a.options.slidesToShow && (a.$prevArrow.off("click.slick").on("click.slick", {
|
||
message: "previous"
|
||
}, a.changeSlide), a.$nextArrow.off("click.slick").on("click.slick", {
|
||
message: "next"
|
||
}, a.changeSlide))
|
||
}, b.prototype.initDotEvents = function() {
|
||
var b = this;
|
||
b.options.dots === !0 && b.slideCount > b.options.slidesToShow && a("li", b.$dots).on("click.slick", {
|
||
message: "index"
|
||
}, b.changeSlide), b.options.dots === !0 && b.options.pauseOnDotsHover === !0 && a("li", b.$dots).on("mouseenter.slick", a.proxy(b.interrupt, b, !0)).on("mouseleave.slick", a.proxy(b.interrupt, b, !1))
|
||
}, b.prototype.initSlideEvents = function() {
|
||
var b = this;
|
||
b.options.pauseOnHover && (b.$list.on("mouseenter.slick", a.proxy(b.interrupt, b, !0)), b.$list.on("mouseleave.slick", a.proxy(b.interrupt, b, !1)))
|
||
}, b.prototype.initializeEvents = function() {
|
||
var b = this;
|
||
b.initArrowEvents(), b.initDotEvents(), b.initSlideEvents(), b.$list.on("touchstart.slick mousedown.slick", {
|
||
action: "start"
|
||
}, b.swipeHandler), b.$list.on("touchmove.slick mousemove.slick", {
|
||
action: "move"
|
||
}, b.swipeHandler), b.$list.on("touchend.slick mouseup.slick", {
|
||
action: "end"
|
||
}, b.swipeHandler), b.$list.on("touchcancel.slick mouseleave.slick", {
|
||
action: "end"
|
||
}, b.swipeHandler), b.$list.on("click.slick", b.clickHandler), a(document).on(b.visibilityChange, a.proxy(b.visibility, b)), b.options.accessibility === !0 && b.$list.on("keydown.slick", b.keyHandler), b.options.focusOnSelect === !0 && a(b.$slideTrack).children().on("click.slick", b.selectHandler), a(window).on("orientationchange.slick.slick-" + b.instanceUid, a.proxy(b.orientationChange, b)), a(window).on("resize.slick.slick-" + b.instanceUid, a.proxy(b.resize, b)), a("[draggable!=true]", b.$slideTrack).on("dragstart", b.preventDefault), a(window).on("load.slick.slick-" + b.instanceUid, b.setPosition), a(document).on("ready.slick.slick-" + b.instanceUid, b.setPosition)
|
||
}, b.prototype.initUI = function() {
|
||
var a = this;
|
||
a.options.arrows === !0 && a.slideCount > a.options.slidesToShow && (a.$prevArrow.show(), a.$nextArrow.show()), a.options.dots === !0 && a.slideCount > a.options.slidesToShow && a.$dots.show()
|
||
}, b.prototype.keyHandler = function(a) {
|
||
var b = this;
|
||
a.target.tagName.match("TEXTAREA|INPUT|SELECT") || (37 === a.keyCode && b.options.accessibility === !0 ? b.changeSlide({
|
||
data: {
|
||
message: b.options.rtl === !0 ? "next" : "previous"
|
||
}
|
||
}) : 39 === a.keyCode && b.options.accessibility === !0 && b.changeSlide({
|
||
data: {
|
||
message: b.options.rtl === !0 ? "previous" : "next"
|
||
}
|
||
}))
|
||
}, b.prototype.lazyLoad = function() {
|
||
function g(c) {
|
||
a("img[data-lazy]", c).each(function() {
|
||
var c = a(this),
|
||
d = a(this).attr("data-lazy"),
|
||
ds = a(this).attr("data-srcset"),
|
||
e = document.createElement("img");
|
||
c.animate({
|
||
opacity: 0
|
||
}, 100, function() {
|
||
c.attr({
|
||
src: d,
|
||
srcset: ds
|
||
}).removeAttr("data-lazy").removeAttr("data-srcset").removeClass("slick-loading").animate({
|
||
opacity: 1
|
||
}, 200), b.$slider.trigger("lazyLoaded", [b, c, d])
|
||
});
|
||
e.onerror = function() {
|
||
c.removeAttr("data-lazy").removeAttr("data-srcset").removeClass("slick-loading").addClass("slick-lazyload-error"), b.$slider.trigger("lazyLoadError", [b, c, d])
|
||
}
|
||
})
|
||
}
|
||
var c, d, e, f, b = this;
|
||
b.options.centerMode === !0 ? b.options.infinite === !0 ? (e = b.currentSlide + (b.options.slidesToShow / 2 + 1), f = e + b.options.slidesToShow + 2) : (e = Math.max(0, b.currentSlide - (b.options.slidesToShow / 2 + 1)), f = 2 + (b.options.slidesToShow / 2 + 1) + b.currentSlide) : (e = b.options.infinite ? b.options.slidesToShow + b.currentSlide : b.currentSlide, f = Math.ceil(e + b.options.slidesToShow), b.options.fade === !0 && (e > 0 && e--, f <= b.slideCount && f++)), c = b.$slider.find(".slick-slide").slice(e, f), g(c), b.slideCount <= b.options.slidesToShow ? (d = b.$slider.find(".slick-slide"), g(d)) : b.currentSlide >= b.slideCount - b.options.slidesToShow ? (d = b.$slider.find(".slick-cloned").slice(0, b.options.slidesToShow), g(d)) : 0 === b.currentSlide && (d = b.$slider.find(".slick-cloned").slice(-1 * b.options.slidesToShow), g(d))
|
||
if(b.options.lazyloadPrevNext && b.$slideTrack.find('.slick-slide').length>2){
|
||
var slide_index=b.$slideTrack.find('.slick-active').index(),
|
||
slide_prevnext_order=[slide_index-1,slide_index+1];
|
||
for (var i = 0; i < 2; i++) {
|
||
b.$slideTrack.find('.slick-slide:eq('+slide_prevnext_order[i]+') img').each(function(){
|
||
if($(this).attr('data-lazy')) $(this).attr({src:$(this).data('lazy')}).removeAttr('data-lazy').removeClass('slick-loading');
|
||
if($(this).attr('data-srcset')) $(this).attr({srcset:$(this).data('srcset')}).removeAttr('data-srcset');
|
||
})
|
||
}
|
||
}
|
||
}, b.prototype.loadSlider = function() {
|
||
var a = this;
|
||
if (a.options.placeHolder){
|
||
a.$slideTrack.find('img[data-lazy]').each(function(index, el) {
|
||
$(this).attr({src:a.options.placeHolder});
|
||
});
|
||
};
|
||
a.setPosition(), a.$slideTrack.css({
|
||
opacity: 1
|
||
}), a.$slider.removeClass("slick-loading"), a.initUI(), "progressive" === a.options.lazyLoad && a.progressiveLazyLoad()
|
||
}, b.prototype.next = b.prototype.slickNext = function() {
|
||
var a = this;
|
||
a.changeSlide({
|
||
data: {
|
||
message: "next"
|
||
}
|
||
})
|
||
}, b.prototype.orientationChange = function() {
|
||
var a = this;
|
||
a.checkResponsive(), a.setPosition()
|
||
}, b.prototype.pause = b.prototype.slickPause = function() {
|
||
var a = this;
|
||
a.autoPlayClear(), a.paused = !0
|
||
}, b.prototype.play = b.prototype.slickPlay = function() {
|
||
var a = this;
|
||
a.autoPlay(), a.options.autoplay = !0, a.paused = !1, a.focussed = !1, a.interrupted = !1
|
||
}, b.prototype.postSlide = function(a) {
|
||
var b = this;
|
||
b.unslicked || (b.$slider.trigger("afterChange", [b, a]), b.animating = !1, b.setPosition(), b.swipeLeft = null, b.options.autoplay && b.autoPlay(), b.options.accessibility === !0 && b.initADA())
|
||
}, b.prototype.prev = b.prototype.slickPrev = function() {
|
||
var a = this;
|
||
a.changeSlide({
|
||
data: {
|
||
message: "previous"
|
||
}
|
||
})
|
||
}, b.prototype.preventDefault = function(a) {
|
||
a.preventDefault()
|
||
}, b.prototype.progressiveLazyLoad = function(b) {
|
||
b = b || 1;
|
||
var e, f, fs, g, c = this,
|
||
d = a("img[data-lazy]", c.$slider);
|
||
d.length ? (e = d.first(), f = e.attr("data-lazy"), fs = e.attr("data-srcset"), g = document.createElement("img"), g.onload = function() {
|
||
e.attr({
|
||
src: f,
|
||
srcset: fs
|
||
}).removeAttr("data-lazy").removeAttr("data-srcset").removeClass("slick-loading"), c.options.adaptiveHeight === !0 && c.setPosition(), c.$slider.trigger("lazyLoaded", [c, e, f]), c.progressiveLazyLoad()
|
||
}, g.onerror = function() {
|
||
3 > b ? setTimeout(function() {
|
||
c.progressiveLazyLoad(b + 1)
|
||
}, 500) : (e.removeAttr("data-lazy").removeAttr("data-srcset").removeClass("slick-loading").addClass("slick-lazyload-error"), c.$slider.trigger("lazyLoadError", [c, e, f]), c.progressiveLazyLoad())
|
||
}, g.src = f) : c.$slider.trigger("allImagesLoaded", [c])
|
||
}, b.prototype.refresh = function(b) {
|
||
var d, e, c = this;
|
||
e = c.slideCount - c.options.slidesToShow, !c.options.infinite && c.currentSlide > e && (c.currentSlide = e), c.slideCount <= c.options.slidesToShow && (c.currentSlide = 0), d = c.currentSlide, c.destroy(!0), a.extend(c, c.initials, {
|
||
currentSlide: d
|
||
}), c.init(), b || c.changeSlide({
|
||
data: {
|
||
message: "index",
|
||
index: d
|
||
}
|
||
}, !1)
|
||
}, b.prototype.registerBreakpoints = function() {
|
||
var c, d, e, b = this,
|
||
f = b.options.responsive || null;
|
||
if ("array" === a.type(f) && f.length) {
|
||
b.respondTo = b.options.respondTo || "window";
|
||
for (c in f)
|
||
if (e = b.breakpoints.length - 1, d = f[c].breakpoint, f.hasOwnProperty(c)) {
|
||
for (; e >= 0;) b.breakpoints[e] && b.breakpoints[e] === d && b.breakpoints.splice(e, 1), e--;
|
||
b.breakpoints.push(d), b.breakpointSettings[d] = f[c].settings
|
||
}
|
||
b.breakpoints.sort(function(a, c) {
|
||
return b.options.mobileFirst ? a - c : c - a
|
||
})
|
||
}
|
||
}, b.prototype.reinit = function() {
|
||
var b = this;
|
||
b.$slides = b.$slideTrack.children(b.options.slide).addClass("slick-slide"), b.slideCount = b.$slides.length, b.currentSlide >= b.slideCount && 0 !== b.currentSlide && (b.currentSlide = b.currentSlide - b.options.slidesToScroll), b.slideCount <= b.options.slidesToShow && (b.currentSlide = 0), b.registerBreakpoints(), b.setProps(), b.setupInfinite(), b.buildArrows(), b.updateArrows(), b.initArrowEvents(), b.buildDots(), b.updateDots(), b.initDotEvents(), b.cleanUpSlideEvents(), b.initSlideEvents(), b.checkResponsive(!1, !0), b.options.focusOnSelect === !0 && a(b.$slideTrack).children().on("click.slick", b.selectHandler), b.setSlideClasses("number" == typeof b.currentSlide ? b.currentSlide : 0), b.setPosition(), b.focusHandler(), b.paused = !b.options.autoplay, b.autoPlay(), b.$slider.trigger("reInit", [b])
|
||
}, b.prototype.resize = function() {
|
||
var b = this;
|
||
a(window).width() !== b.windowWidth && (clearTimeout(b.windowDelay), b.windowDelay = window.setTimeout(function() {
|
||
b.windowWidth = a(window).width(), b.checkResponsive(), b.unslicked || b.setPosition()
|
||
}, 50))
|
||
}, b.prototype.removeSlide = b.prototype.slickRemove = function(a, b, c) {
|
||
var d = this;
|
||
return "boolean" == typeof a ? (b = a, a = b === !0 ? 0 : d.slideCount - 1) : a = b === !0 ? --a : a, d.slideCount < 1 || 0 > a || a > d.slideCount - 1 ? !1 : (d.unload(), c === !0 ? d.$slideTrack.children().remove() : d.$slideTrack.children(this.options.slide).eq(a).remove(), d.$slides = d.$slideTrack.children(this.options.slide), d.$slideTrack.children(this.options.slide).detach(), d.$slideTrack.append(d.$slides), d.$slidesCache = d.$slides, void d.reinit())
|
||
}, b.prototype.setCSS = function(a) {
|
||
var d, e, b = this,
|
||
c = {};
|
||
b.options.rtl === !0 && (a = -a), d = "left" == b.positionProp ? Math.ceil(a) + "px" : "0px", e = "top" == b.positionProp ? Math.ceil(a) + "px" : "0px", c[b.positionProp] = a, b.transformsEnabled === !1 ? b.$slideTrack.css(c) : (c = {}, b.cssTransitions === !1 ? (c[b.animType] = "translate(" + d + ", " + e + ")", b.$slideTrack.css(c)) : (c[b.animType] = "translate3d(" + d + ", " + e + ", 0px)", b.$slideTrack.css(c)))
|
||
}, b.prototype.setDimensions = function() {
|
||
var a = this;
|
||
a.options.vertical === !1 ? a.options.centerMode === !0 && a.$list.css({
|
||
padding: "0px " + a.options.centerPadding
|
||
}) : (a.$list.height(a.$slides.first().outerHeight(!0) * a.options.slidesToShow), a.options.centerMode === !0 && a.$list.css({
|
||
padding: a.options.centerPadding + " 0px"
|
||
})), a.listWidth = a.$list.width(), a.listHeight = a.$list.height(), a.options.vertical === !1 && a.options.variableWidth === !1 ? (a.slideWidth = Math.ceil(a.listWidth / a.options.slidesToShow), a.$slideTrack.width(Math.ceil(a.slideWidth * a.$slideTrack.children(".slick-slide").length))) : a.options.variableWidth === !0 ? a.$slideTrack.width(5e3 * a.slideCount) : (a.slideWidth = Math.ceil(a.listWidth), a.$slideTrack.height(Math.ceil(a.$slides.first().outerHeight(!0) * a.$slideTrack.children(".slick-slide").length)));
|
||
var b = a.$slides.first().outerWidth(!0) - a.$slides.first().width();
|
||
a.options.variableWidth === !1 && a.$slideTrack.children(".slick-slide").width(a.slideWidth - b)
|
||
}, b.prototype.setFade = function() {
|
||
var c, b = this;
|
||
b.$slides.each(function(d, e) {
|
||
c = b.slideWidth * d * -1, b.options.rtl === !0 ? a(e).css({
|
||
position: "relative",
|
||
right: c,
|
||
top: 0,
|
||
zIndex: b.options.zIndex - 2,
|
||
opacity: 0
|
||
}) : a(e).css({
|
||
position: "relative",
|
||
left: c,
|
||
top: 0,
|
||
zIndex: b.options.zIndex - 2,
|
||
opacity: 0
|
||
})
|
||
}), b.$slides.eq(b.currentSlide).css({
|
||
zIndex: b.options.zIndex - 1,
|
||
opacity: 1
|
||
})
|
||
}, b.prototype.setHeight = function() {
|
||
var a = this;
|
||
if (1 === a.options.slidesToShow && a.options.adaptiveHeight === !0 && a.options.vertical === !1) {
|
||
var b = a.$slides.eq(a.currentSlide).outerHeight(!0);
|
||
a.$list.css("height", b)
|
||
}
|
||
}, b.prototype.setOption = b.prototype.slickSetOption = function() {
|
||
var c, d, e, f, h, b = this,
|
||
g = !1;
|
||
if ("object" === a.type(arguments[0]) ? (e = arguments[0], g = arguments[1], h = "multiple") : "string" === a.type(arguments[0]) && (e = arguments[0], f = arguments[1], g = arguments[2], "responsive" === arguments[0] && "array" === a.type(arguments[1]) ? h = "responsive" : "undefined" != typeof arguments[1] && (h = "single")), "single" === h) b.options[e] = f;
|
||
else if ("multiple" === h) a.each(e, function(a, c) {
|
||
b.options[a] = c
|
||
});
|
||
else if ("responsive" === h)
|
||
for (d in f)
|
||
if ("array" !== a.type(b.options.responsive)) b.options.responsive = [f[d]];
|
||
else {
|
||
for (c = b.options.responsive.length - 1; c >= 0;) b.options.responsive[c].breakpoint === f[d].breakpoint && b.options.responsive.splice(c, 1), c--;
|
||
b.options.responsive.push(f[d])
|
||
}
|
||
g && (b.unload(), b.reinit())
|
||
}, b.prototype.setPosition = function() {
|
||
var a = this;
|
||
a.setDimensions(), a.setHeight(), a.options.fade === !1 ? a.setCSS(a.getLeft(a.currentSlide)) : a.setFade(), a.$slider.trigger("setPosition", [a])
|
||
}, b.prototype.setProps = function() {
|
||
var a = this,
|
||
b = document.body.style;
|
||
a.positionProp = a.options.vertical === !0 ? "top" : "left", "top" === a.positionProp ? a.$slider.addClass("slick-vertical") : a.$slider.removeClass("slick-vertical"), (void 0 !== b.WebkitTransition || void 0 !== b.MozTransition || void 0 !== b.msTransition) && a.options.useCSS === !0 && (a.cssTransitions = !0), a.options.fade && ("number" == typeof a.options.zIndex ? a.options.zIndex < 3 && (a.options.zIndex = 3) : a.options.zIndex = a.defaults.zIndex), void 0 !== b.OTransform && (a.animType = "OTransform", a.transformType = "-o-transform", a.transitionType = "OTransition", void 0 === b.perspectiveProperty && void 0 === b.webkitPerspective && (a.animType = !1)), void 0 !== b.MozTransform && (a.animType = "MozTransform", a.transformType = "-moz-transform", a.transitionType = "MozTransition", void 0 === b.perspectiveProperty && void 0 === b.MozPerspective && (a.animType = !1)), void 0 !== b.webkitTransform && (a.animType = "webkitTransform", a.transformType = "-webkit-transform", a.transitionType = "webkitTransition", void 0 === b.perspectiveProperty && void 0 === b.webkitPerspective && (a.animType = !1)), void 0 !== b.msTransform && (a.animType = "msTransform", a.transformType = "-ms-transform", a.transitionType = "msTransition", void 0 === b.msTransform && (a.animType = !1)), void 0 !== b.transform && a.animType !== !1 && (a.animType = "transform", a.transformType = "transform", a.transitionType = "transition"), a.transformsEnabled = a.options.useTransform && null !== a.animType && a.animType !== !1
|
||
}, b.prototype.setSlideClasses = function(a) {
|
||
var c, d, e, f, b = this;
|
||
d = b.$slider.find(".slick-slide").removeClass("slick-active slick-center slick-current").attr("aria-hidden", "true"), b.$slides.eq(a).addClass("slick-current"), b.options.centerMode === !0 ? (c = Math.floor(b.options.slidesToShow / 2), b.options.infinite === !0 && (a >= c && a <= b.slideCount - 1 - c ? b.$slides.slice(a - c, a + c + 1).addClass("slick-active").attr("aria-hidden", "false") : (e = b.options.slidesToShow + a, d.slice(e - c + 1, e + c + 2).addClass("slick-active").attr("aria-hidden", "false")), 0 === a ? d.eq(d.length - 1 - b.options.slidesToShow).addClass("slick-center") : a === b.slideCount - 1 && d.eq(b.options.slidesToShow).addClass("slick-center")), b.$slides.eq(a).addClass("slick-center")) : a >= 0 && a <= b.slideCount - b.options.slidesToShow ? b.$slides.slice(a, a + b.options.slidesToShow).addClass("slick-active").attr("aria-hidden", "false") : d.length <= b.options.slidesToShow ? d.addClass("slick-active").attr("aria-hidden", "false") : (f = b.slideCount % b.options.slidesToShow, e = b.options.infinite === !0 ? b.options.slidesToShow + a : a, b.options.slidesToShow == b.options.slidesToScroll && b.slideCount - a < b.options.slidesToShow ? d.slice(e - (b.options.slidesToShow - f), e + f).addClass("slick-active").attr("aria-hidden", "false") : d.slice(e, e + b.options.slidesToShow).addClass("slick-active").attr("aria-hidden", "false")), "ondemand" === b.options.lazyLoad && b.lazyLoad()
|
||
}, b.prototype.setupInfinite = function() {
|
||
var c, d, e, b = this;
|
||
if (b.options.fade === !0 && (b.options.centerMode = !1), b.options.infinite === !0 && b.options.fade === !1 && (d = null, b.slideCount > b.options.slidesToShow)) {
|
||
for (e = b.options.centerMode === !0 ? b.options.slidesToShow + 1 : b.options.slidesToShow, c = b.slideCount; c > b.slideCount - e; c -= 1) d = c - 1, a(b.$slides[d]).clone(!0).attr("id", "").attr("data-slick-index", d - b.slideCount).prependTo(b.$slideTrack).addClass("slick-cloned").find('img').height('').removeAttr('height');
|
||
for (c = 0; e > c; c += 1) d = c, a(b.$slides[d]).clone(!0).attr("id", "").attr("data-slick-index", d + b.slideCount).appendTo(b.$slideTrack).addClass("slick-cloned").find('img').height('').removeAttr('height');
|
||
b.$slideTrack.find(".slick-cloned").find("[id]").each(function() {
|
||
a(this).attr("id", "")
|
||
})
|
||
}
|
||
}, b.prototype.interrupt = function(a) {
|
||
var b = this;
|
||
a || b.autoPlay(), b.interrupted = a
|
||
}, b.prototype.selectHandler = function(b) {
|
||
var c = this,
|
||
d = a(b.target).is(".slick-slide") ? a(b.target) : a(b.target).parents(".slick-slide"),
|
||
e = parseInt(d.attr("data-slick-index"));
|
||
return e || (e = 0), c.slideCount <= c.options.slidesToShow ? (c.setSlideClasses(e), void c.asNavFor(e)) : void c.slideHandler(e)
|
||
}, b.prototype.slideHandler = function(a, b, c) {
|
||
var d, e, f, g, j, h = null,
|
||
i = this;
|
||
return b = b || !1, i.animating === !0 && i.options.waitForAnimate === !0 || i.options.fade === !0 && i.currentSlide === a || i.slideCount <= i.options.slidesToShow ? void 0 : (b === !1 && i.asNavFor(a), d = a, h = i.getLeft(d), g = i.getLeft(i.currentSlide), i.currentLeft = null === i.swipeLeft ? g : i.swipeLeft, i.options.infinite === !1 && i.options.centerMode === !1 && (0 > a || a > i.getDotCount() * i.options.slidesToScroll) ? void(i.options.fade === !1 && (d = i.currentSlide, c !== !0 ? i.animateSlide(g, function() {
|
||
i.postSlide(d)
|
||
}) : i.postSlide(d))) : i.options.infinite === !1 && i.options.centerMode === !0 && (0 > a || a > i.slideCount - i.options.slidesToScroll) ? void(i.options.fade === !1 && (d = i.currentSlide, c !== !0 ? i.animateSlide(g, function() {
|
||
i.postSlide(d)
|
||
}) : i.postSlide(d))) : (i.options.autoplay && clearInterval(i.autoPlayTimer), e = 0 > d ? i.slideCount % i.options.slidesToScroll !== 0 ? i.slideCount - i.slideCount % i.options.slidesToScroll : i.slideCount + d : d >= i.slideCount ? i.slideCount % i.options.slidesToScroll !== 0 ? 0 : d - i.slideCount : d, i.animating = !0, i.$slider.trigger("beforeChange", [i, i.currentSlide, e]), f = i.currentSlide, i.currentSlide = e, i.setSlideClasses(i.currentSlide), i.options.asNavFor && (j = i.getNavTarget(), j = j.slick("getSlick"), j.slideCount <= j.options.slidesToShow && j.setSlideClasses(i.currentSlide)), i.updateDots(), i.updateArrows(), i.options.fade === !0 ? (c !== !0 ? (i.fadeSlideOut(f), i.fadeSlide(e, function() {
|
||
i.postSlide(e)
|
||
})) : i.postSlide(e), void i.animateHeight()) : void(c !== !0 ? i.animateSlide(h, function() {
|
||
i.postSlide(e)
|
||
}) : i.postSlide(e))))
|
||
}, b.prototype.startLoad = function() {
|
||
var a = this;
|
||
a.options.arrows === !0 && a.slideCount > a.options.slidesToShow && (a.$prevArrow.hide(), a.$nextArrow.hide()), a.options.dots === !0 && a.slideCount > a.options.slidesToShow && a.$dots.hide(), a.$slider.addClass("slick-loading")
|
||
}, b.prototype.swipeDirection = function() {
|
||
var a, b, c, d, e = this;
|
||
return a = e.touchObject.startX - e.touchObject.curX, b = e.touchObject.startY - e.touchObject.curY, c = Math.atan2(b, a), d = Math.round(180 * c / Math.PI), 0 > d && (d = 360 - Math.abs(d)), 45 >= d && d >= 0 ? e.options.rtl === !1 ? "left" : "right" : 360 >= d && d >= 315 ? e.options.rtl === !1 ? "left" : "right" : d >= 135 && 225 >= d ? e.options.rtl === !1 ? "right" : "left" : e.options.verticalSwiping === !0 ? d >= 35 && 135 >= d ? "down" : "up" : "vertical"
|
||
}, b.prototype.swipeEnd = function(a) {
|
||
var c, d, b = this;
|
||
if (b.dragging = !1, b.interrupted = !1, b.shouldClick = b.touchObject.swipeLength > 10 ? !1 : !0, void 0 === b.touchObject.curX) return !1;
|
||
if (b.touchObject.edgeHit === !0 && b.$slider.trigger("edge", [b, b.swipeDirection()]), b.touchObject.swipeLength >= b.touchObject.minSwipe) {
|
||
switch (d = b.swipeDirection()) {
|
||
case "left":
|
||
case "down":
|
||
c = b.options.swipeToSlide ? b.checkNavigable(b.currentSlide + b.getSlideCount()) : b.currentSlide + b.getSlideCount(), b.currentDirection = 0;
|
||
break;
|
||
case "right":
|
||
case "up":
|
||
c = b.options.swipeToSlide ? b.checkNavigable(b.currentSlide - b.getSlideCount()) : b.currentSlide - b.getSlideCount(), b.currentDirection = 1
|
||
}
|
||
"vertical" != d && (b.slideHandler(c), b.touchObject = {}, b.$slider.trigger("swipe", [b, d]))
|
||
} else b.touchObject.startX !== b.touchObject.curX && (b.slideHandler(b.currentSlide), b.touchObject = {})
|
||
}, b.prototype.swipeHandler = function(a) {
|
||
var b = this;
|
||
if (!(b.options.swipe === !1 || "ontouchend" in document && b.options.swipe === !1 || b.options.draggable === !1 && -1 !== a.type.indexOf("mouse"))) switch (b.touchObject.fingerCount = a.originalEvent && void 0 !== a.originalEvent.touches ? a.originalEvent.touches.length : 1, b.touchObject.minSwipe = b.listWidth / b.options.touchThreshold, b.options.verticalSwiping === !0 && (b.touchObject.minSwipe = b.listHeight / b.options.touchThreshold), a.data.action) {
|
||
case "start":
|
||
b.swipeStart(a);
|
||
break;
|
||
case "move":
|
||
b.swipeMove(a);
|
||
break;
|
||
case "end":
|
||
b.swipeEnd(a)
|
||
}
|
||
}, b.prototype.swipeMove = function(a) {
|
||
var d, e, f, g, h, b = this;
|
||
return h = void 0 !== a.originalEvent ? a.originalEvent.touches : null, !b.dragging || h && 1 !== h.length ? !1 : (d = b.getLeft(b.currentSlide), b.touchObject.curX = void 0 !== h ? h[0].pageX : a.clientX, b.touchObject.curY = void 0 !== h ? h[0].pageY : a.clientY, b.touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(b.touchObject.curX - b.touchObject.startX, 2))), b.options.verticalSwiping === !0 && (b.touchObject.swipeLength = Math.round(Math.sqrt(Math.pow(b.touchObject.curY - b.touchObject.startY, 2)))), e = b.swipeDirection(), "vertical" !== e ? (void 0 !== a.originalEvent && b.touchObject.swipeLength > 4 && a.preventDefault(), g = (b.options.rtl === !1 ? 1 : -1) * (b.touchObject.curX > b.touchObject.startX ? 1 : -1), b.options.verticalSwiping === !0 && (g = b.touchObject.curY > b.touchObject.startY ? 1 : -1), f = b.touchObject.swipeLength, b.touchObject.edgeHit = !1, b.options.infinite === !1 && (0 === b.currentSlide && "right" === e || b.currentSlide >= b.getDotCount() && "left" === e) && (f = b.touchObject.swipeLength * b.options.edgeFriction, b.touchObject.edgeHit = !0), b.options.vertical === !1 ? b.swipeLeft = d + f * g : b.swipeLeft = d + f * (b.$list.height() / b.listWidth) * g, b.options.verticalSwiping === !0 && (b.swipeLeft = d + f * g), b.options.fade === !0 || b.options.touchMove === !1 ? !1 : b.animating === !0 ? (b.swipeLeft = null, !1) : void b.setCSS(b.swipeLeft)) : void 0)
|
||
}, b.prototype.swipeStart = function(a) {
|
||
var c, b = this;
|
||
return b.interrupted = !0, 1 !== b.touchObject.fingerCount || b.slideCount <= b.options.slidesToShow ? (b.touchObject = {}, !1) : (void 0 !== a.originalEvent && void 0 !== a.originalEvent.touches && (c = a.originalEvent.touches[0]), b.touchObject.startX = b.touchObject.curX = void 0 !== c ? c.pageX : a.clientX, b.touchObject.startY = b.touchObject.curY = void 0 !== c ? c.pageY : a.clientY, void(b.dragging = !0))
|
||
}, b.prototype.unfilterSlides = b.prototype.slickUnfilter = function() {
|
||
var a = this;
|
||
null !== a.$slidesCache && (a.unload(), a.$slideTrack.children(this.options.slide).detach(), a.$slidesCache.appendTo(a.$slideTrack), a.reinit())
|
||
}, b.prototype.unload = function() {
|
||
var b = this;
|
||
a(".slick-cloned", b.$slider).remove(), b.$dots && b.$dots.remove(), b.$prevArrow && b.htmlExpr.test(b.options.prevArrow) && b.$prevArrow.remove(), b.$nextArrow && b.htmlExpr.test(b.options.nextArrow) && b.$nextArrow.remove(), b.$slides.removeClass("slick-slide slick-active slick-visible slick-current").attr("aria-hidden", "true").css("width", "")
|
||
}, b.prototype.unslick = function(a) {
|
||
var b = this;
|
||
b.$slider.trigger("unslick", [b, a]), b.destroy()
|
||
}, b.prototype.updateArrows = function() {
|
||
var b, a = this;
|
||
b = Math.floor(a.options.slidesToShow / 2), a.options.arrows === !0 && a.slideCount > a.options.slidesToShow && !a.options.infinite && (a.$prevArrow.removeClass("slick-disabled").attr("aria-disabled", "false"), a.$nextArrow.removeClass("slick-disabled").attr("aria-disabled", "false"), 0 === a.currentSlide ? (a.$prevArrow.addClass("slick-disabled").attr("aria-disabled", "true"), a.$nextArrow.removeClass("slick-disabled").attr("aria-disabled", "false")) : a.currentSlide >= a.slideCount - a.options.slidesToShow && a.options.centerMode === !1 ? (a.$nextArrow.addClass("slick-disabled").attr("aria-disabled", "true"), a.$prevArrow.removeClass("slick-disabled").attr("aria-disabled", "false")) : a.currentSlide >= a.slideCount - 1 && a.options.centerMode === !0 && (a.$nextArrow.addClass("slick-disabled").attr("aria-disabled", "true"), a.$prevArrow.removeClass("slick-disabled").attr("aria-disabled", "false")))
|
||
}, b.prototype.updateDots = function() {
|
||
var a = this;
|
||
null !== a.$dots && (a.$dots.find("li").removeClass("slick-active").attr("aria-hidden", "true"), a.$dots.find("li").eq(Math.floor(a.currentSlide / a.options.slidesToScroll)).addClass("slick-active").attr("aria-hidden", "false"))
|
||
}, b.prototype.visibility = function() {
|
||
var a = this;
|
||
a.options.autoplay && (document[a.hidden] ? a.interrupted = !0 : a.interrupted = !1)
|
||
}, a.fn.slick = function() {
|
||
var f, g, a = this,
|
||
c = arguments[0],
|
||
d = Array.prototype.slice.call(arguments, 1),
|
||
e = a.length;
|
||
for (f = 0; e > f; f++)
|
||
if ("object" == typeof c || "undefined" == typeof c ? a[f].slick = new b(a[f], c) : g = a[f].slick[c].apply(a[f].slick, d), "undefined" != typeof g) return g;
|
||
return a
|
||
}
|
||
});
|
||
window.met_prevarrow='<button type="button" class="slick-prev"><i class="iconfont icon-prev"></i></button>',
|
||
met_nextarrow='<button type="button" class="slick-next"><i class="iconfont icon-next"></i></button>';
|
||
/*! Tablesaw - v2.0.2 - 2015-10-28
|
||
* https://github.com/filamentgroup/tablesaw
|
||
* Copyright (c) 2015 Filament Group; Licensed */
|
||
/*
|
||
* tablesaw: A set of plugins for responsive tables
|
||
* Stack and Column Toggle tables
|
||
* Copyright (c) 2013 Filament Group, Inc.
|
||
* MIT License
|
||
*/
|
||
if(typeof Tablesaw==="undefined"){Tablesaw={i18n:{modes:['Stack','Swipe','Toggle'],columns:'Col<span class=\"a11y-sm\">umn</span>s',columnBtnText:'Columns',columnsDialogError:'No eligible columns.',sort:'Sort'}, mustard:'querySelector'in document&&(!window.blackberry||window.WebKitPoint)&&!window.operamini};}if(!Tablesaw.config){Tablesaw.config={};}if(Tablesaw.mustard){jQuery(document.documentElement).addClass('tablesaw-enhanced');};(function($){var pluginName="table",classes={toolbar:"tablesaw-bar"},events={create:"tablesawcreate",destroy:"tablesawdestroy",refresh:"tablesawrefresh"},defaultMode="stack",initSelector="table[data-tablesaw-mode],table[data-tablesaw-sortable]";var Table=function(element){if(!element){throw new Error("Tablesaw requires an element.");}this.table=element;this.$table=$(element);this.mode=this.$table.attr("data-tablesaw-mode")||defaultMode;this.init();};Table.prototype.init=function(){ if(!this.$table.attr("id")){this.$table.attr("id",pluginName+"-"+Math.round(Math.random()*10000));}this.createToolbar();var colstart=this._initCells();this.$table.trigger(events.create,[this,colstart]);};Table.prototype._initCells=function(){var colstart,thrs=this.table.querySelectorAll("thead tr"),self=this;$(thrs).each(function(){var coltally=0;$(this).children().each(function(){var span=parseInt(this.getAttribute("colspan"),10),sel=":nth-child("+(coltally+1)+")";colstart=coltally+1;if(span){for(var k=0;k<span-1;k++){coltally++;sel+=", :nth-child("+(coltally+1)+")";}} this.cells=self.$table.find("tr").not(thrs[0]).not(this).children().filter(sel);coltally++;});});return colstart;};Table.prototype.refresh=function(){this._initCells();this.$table.trigger(events.refresh);};Table.prototype.createToolbar=function(){var $toolbar=this.$table.prev().filter('.'+classes.toolbar);if(!$toolbar.length){$toolbar=$('<div>').addClass(classes.toolbar).insertBefore(this.$table);}this.$toolbar=$toolbar;if(this.mode){this.$toolbar.addClass('mode-'+this.mode);}};Table.prototype.destroy=function(){this.$table.prev().filter('.'+classes.toolbar).each(function(){this.className=this.className.replace(/\bmode\-\w*\b/gi,'');});var tableId=this.$table.attr('id');$(document).unbind("."+tableId);$(window).unbind("."+tableId); this.$table.trigger(events.destroy,[this]);this.$table.removeAttr('data-tablesaw-mode');this.$table.removeData(pluginName);};$.fn[pluginName]=function(){return this.each(function(){var $t=$(this);if($t.data(pluginName)){return;}var table=new Table(this);$t.data(pluginName,table);});};$(document).on("enhance.tablesaw",function(e){ if(Tablesaw.mustard){$(e.target).find(initSelector)[pluginName]();}});}(jQuery));;(function(win,$,undefined){var classes={stackTable:'tablesaw-stack',cellLabels:'tablesaw-cell-label',cellContentLabels:'tablesaw-cell-content'};var data={obj:'tablesaw-stack'};var attrs={labelless:'data-tablesaw-no-labels',hideempty:'data-tablesaw-hide-empty'};var Stack=function(element){this.$table=$(element);this.labelless=this.$table.is('['+attrs.labelless+']');this.hideempty=this.$table.is('['+attrs.hideempty+']');if(!this.labelless){ this.allHeaders=this.$table.find("th");}this.$table.data(data.obj,this);};Stack.prototype.init=function(colstart){this.$table.addClass(classes.stackTable);if(this.labelless){return;} var reverseHeaders=$(this.allHeaders);var hideempty=this.hideempty; reverseHeaders.each(function(){var $t=$(this),$cells=$(this.cells).filter(function(){return!$(this).parent().is("["+attrs.labelless+"]")&&(!hideempty||!$(this).is(":empty"));}),hierarchyClass=$cells.not(this).filter("thead th").length&&" tablesaw-cell-label-top", $sortableButton=$t.find(".tablesaw-sortable-btn"),html=$sortableButton.length?$sortableButton.html():$t.html();if(html!==""){if(hierarchyClass){var iteration=parseInt($(this).attr("colspan"),10),filter="";if(iteration){filter="td:nth-child("+iteration+"n + "+(colstart)+")";}$cells.filter(filter).prepend("<b class='"+classes.cellLabels+hierarchyClass+"'>"+html+"</b>");}else{$cells.wrapInner("<span class='"+classes.cellContentLabels+"'></span>");$cells.prepend("<b class='"+classes.cellLabels+"'>"+html+"</b>");}}});};Stack.prototype.destroy=function(){this.$table.removeClass(classes.stackTable);this.$table.find('.'+classes.cellLabels).remove();this.$table.find('.'+classes.cellContentLabels).each(function(){$(this).replaceWith(this.childNodes);});}; $(document).on("tablesawcreate",function(e,Tablesaw,colstart){if(Tablesaw.mode==='stack'){var table=new Stack(Tablesaw.table);table.init(colstart);}});$(document).on("tablesawdestroy",function(e,Tablesaw){if(Tablesaw.mode==='stack'){$(Tablesaw.table).data(data.obj).destroy();}});}(this,jQuery));;(function($){var pluginName="tablesawbtn",methods={_create:function(){return $(this).each(function(){$(this).trigger("beforecreate."+pluginName)[pluginName]("_init").trigger("create."+pluginName);});},_init:function(){var oEl=$(this),sel=this.getElementsByTagName("select")[0];if(sel){$(this).addClass("btn-select")[pluginName]("_select",sel);}return oEl;},_select:function(sel){var update=function(oEl,sel){var opts=$(sel).find("option"),label,el,children;opts.each(function(){var opt=this;if(opt.selected){label=document.createTextNode(opt.text);}});children=oEl.childNodes;if(opts.length>0){for(var i=0,l=children.length;i<l;i++){el=children[i];if(el&&el.nodeType===3){oEl.replaceChild(label,el);}}}};update(this,sel);$(this).bind("change refresh",function(){update(this,sel);});}};$.fn[pluginName]=function(arrg,a,b,c){return this.each(function(){ if(arrg&&typeof(arrg)==="string"){return $.fn[pluginName].prototype[arrg].call(this,a,b,c);} if($(this).data(pluginName+"active")){return $(this);} $(this).data(pluginName+"active",true);$.fn[pluginName].prototype._create.call(this);});}; $.extend($.fn[pluginName].prototype,methods);}(jQuery));;(function(win,$,undefined){var ColumnToggle=function(element){this.$table=$(element);this.classes={columnToggleTable:'tablesaw-columntoggle',columnBtnContain:'tablesaw-columntoggle-btnwrap tablesaw-advance',columnBtn:'tablesaw-columntoggle-btn tablesaw-nav-btn down',popup:'tablesaw-columntoggle-popup',priorityPrefix:'tablesaw-priority-', toolbar:'tablesaw-bar'};this.headers=this.$table.find('tr:first > th');this.$table.data('tablesaw-coltoggle',this);};ColumnToggle.prototype.init=function(){var tableId,id,$menuButton,$popup,$menu,$btnContain,self=this;this.$table.addClass(this.classes.columnToggleTable);tableId=this.$table.attr("id");id=tableId+"-popup";$btnContain=$("<div class='"+this.classes.columnBtnContain+"'></div>");$menuButton=$("<a href='#"+id+"' class='btn btn-micro "+this.classes.columnBtn+"' data-popup-link>"+"<span>"+Tablesaw.i18n.columnBtnText+"</span></a>");$popup=$("<div class='dialog-table-coltoggle "+this.classes.popup+"' id='"+id+"'></div>");$menu=$("<div class='btn-group'></div>");var hasNonPersistentHeaders=false;$(this.headers).not("td").each(function(){var $this=$(this),priority=$this.attr("data-tablesaw-priority"),$cells=self.$getCells(this);if(priority&&priority!=="persist"){$cells.addClass(self.classes.priorityPrefix+priority);$("<label><input type='checkbox' checked>"+$this.text()+"</label>").appendTo($menu).children(0).data("tablesaw-header",this);hasNonPersistentHeaders=true;}});if(!hasNonPersistentHeaders){$menu.append('<label>'+Tablesaw.i18n.columnsDialogError+'</label>');}$menu.appendTo($popup);$menu.find('input[type="checkbox"]').on("change",function(e){var checked=e.target.checked;self.$getCellsFromCheckbox(e.target).toggleClass("tablesaw-cell-hidden",!checked).toggleClass("tablesaw-cell-visible",checked);self.$table.trigger('tablesawcolumns');});$menuButton.appendTo($btnContain);$btnContain.appendTo(this.$table.prev().filter('.'+this.classes.toolbar));var closeTimeout;function openPopup(){$btnContain.addClass('visible');$menuButton.removeClass('down').addClass('up');$(document).unbind('click.'+tableId,closePopup);window.clearTimeout(closeTimeout);closeTimeout=window.setTimeout(function(){$(document).one('click.'+tableId,closePopup);},15);}function closePopup(event){if(event&&$(event.target).closest("."+self.classes.popup).length){return;}$(document).unbind('click.'+tableId);$menuButton.removeClass('up').addClass('down');$btnContain.removeClass('visible');}$menuButton.on("click.tablesaw",function(event){event.preventDefault();if(!$btnContain.is(".visible")){openPopup();}else{closePopup();}});$popup.appendTo($btnContain);this.$menu=$menu;$(window).on("resize."+tableId,function(){self.refreshToggle();});this.refreshToggle();};ColumnToggle.prototype.$getCells=function(th){return $(th).add(th.cells);};ColumnToggle.prototype.$getCellsFromCheckbox=function(checkbox){var th=$(checkbox).data("tablesaw-header");return this.$getCells(th);};ColumnToggle.prototype.refreshToggle=function(){var self=this;this.$menu.find("input").each(function(){this.checked=self.$getCellsFromCheckbox(this).eq(0).css("display")==="table-cell";});};ColumnToggle.prototype.refreshPriority=function(){var self=this;$(this.headers).not("td").each(function(){var $this=$(this),priority=$this.attr("data-tablesaw-priority"),$cells=$this.add(this.cells);if(priority&&priority!=="persist"){$cells.addClass(self.classes.priorityPrefix+priority);}});};ColumnToggle.prototype.destroy=function(){this.$table.removeClass(this.classes.columnToggleTable);this.$table.find('th, td').each(function(){var $cell=$(this);$cell.removeClass('tablesaw-cell-hidden').removeClass('tablesaw-cell-visible');this.className=this.className.replace(/\bui\-table\-priority\-\d\b/g,'');});}; $(document).on("tablesawcreate",function(e,Tablesaw){if(Tablesaw.mode==='columntoggle'){var table=new ColumnToggle(Tablesaw.table);table.init();}});$(document).on("tablesawdestroy",function(e,Tablesaw){if(Tablesaw.mode==='columntoggle'){$(Tablesaw.table).data('tablesaw-coltoggle').destroy();}});}(this,jQuery));;(function(win,$,undefined){$.extend(Tablesaw.config,{swipe:{horizontalThreshold:15,verticalThreshold:30}});function isIE8(){var div=document.createElement('div'),all=div.getElementsByTagName('i');div.innerHTML='<!--[if lte IE 8]><i></i><![endif]-->';return!!all.length;}function createSwipeTable($table){var $btns=$("<div class='tablesaw-advance'></div>"),$prevBtn=$("<a href='#' class='tablesaw-nav-btn btn btn-micro left' title='Previous Column'></a>").appendTo($btns),$nextBtn=$("<a href='#' class='tablesaw-nav-btn btn btn-micro right' title='Next Column'></a>").appendTo($btns),hideBtn='disabled',persistWidths='tablesaw-fix-persist',$headerCells=$table.find("thead th"),$headerCellsNoPersist=$headerCells.not('[data-tablesaw-priority="persist"]'),headerWidths=[],$head=$(document.head||'head'),tableId=$table.attr('id'), supportsNthChild=!isIE8();if(!$headerCells.length){throw new Error("tablesaw swipe: no header cells found. Are you using <th> inside of <thead>?");} $table.css('width','auto');$headerCells.each(function(){headerWidths.push($(this).outerWidth());});$table.css('width','');$btns.appendTo($table.prev().filter('.tablesaw-bar'));$table.addClass("tablesaw-swipe");if(!tableId){tableId='tableswipe-'+Math.round(Math.random()*10000);$table.attr('id',tableId);}function $getCells(headerCell){return $(headerCell.cells).add(headerCell);}function showColumn(headerCell){$getCells(headerCell).removeClass('tablesaw-cell-hidden');}function hideColumn(headerCell){$getCells(headerCell).addClass('tablesaw-cell-hidden');}function persistColumn(headerCell){$getCells(headerCell).addClass('tablesaw-cell-persist');}function isPersistent(headerCell){return $(headerCell).is('[data-tablesaw-priority="persist"]');}function unmaintainWidths(){$table.removeClass(persistWidths);$('#'+tableId+'-persist').remove();}function maintainWidths(){var prefix='#'+tableId+'.tablesaw-swipe ',styles=[],tableWidth=$table.width(),hash=[],newHash;$headerCells.each(function(index){var width;if(isPersistent(this)){width=$(this).outerWidth();if(width<tableWidth*0.75){hash.push(index+'-'+width);styles.push(prefix+' .tablesaw-cell-persist:nth-child('+(index+1)+') { width: '+width+'px; }');}}});newHash=hash.join('_');$table.addClass(persistWidths);var $style=$('#'+tableId+'-persist'); if(!$style.length||$style.data('hash')!==newHash){ $style.remove();if(styles.length){$('<style>'+styles.join("\n")+'</style>').attr('id',tableId+'-persist').data('hash',newHash).appendTo($head);}}}function getNext(){var next=[],checkFound;$headerCellsNoPersist.each(function(i){var $t=$(this),isHidden=$t.css("display")==="none"||$t.is(".tablesaw-cell-hidden");if(!isHidden&&!checkFound){checkFound=true;next[0]=i;}else if(isHidden&&checkFound){next[1]=i;return false;}});return next;}function getPrev(){var next=getNext();return[next[1]-1,next[0]-1];}function nextpair(fwd){return fwd?getNext():getPrev();}function canAdvance(pair){return pair[1]>-1&&pair[1]<$headerCellsNoPersist.length;}function matchesMedia(){var matchMedia=$table.attr("data-tablesaw-swipe-media");return!matchMedia||("matchMedia"in win)&&win.matchMedia(matchMedia).matches;}function fakeBreakpoints(){if(!matchesMedia()){return;}var extraPaddingPixels=20,containerWidth=$table.parent().width(),persist=[],sum=0,sums=[],visibleNonPersistantCount=$headerCells.length;$headerCells.each(function(index){var $t=$(this),isPersist=$t.is('[data-tablesaw-priority="persist"]');persist.push(isPersist);sum+=headerWidths[index]+(isPersist?0:extraPaddingPixels);sums.push(sum); if(isPersist||sum>containerWidth){visibleNonPersistantCount--;}});var needsNonPersistentColumn=visibleNonPersistantCount===0;$headerCells.each(function(index){if(persist[index]){ persistColumn(this);return;}if(sums[index]<=containerWidth||needsNonPersistentColumn){needsNonPersistentColumn=false;showColumn(this);}else{hideColumn(this);}});if(supportsNthChild){unmaintainWidths();}$table.trigger('tablesawcolumns');}function advance(fwd){var pair=nextpair(fwd);if(canAdvance(pair)){if(isNaN(pair[0])){if(fwd){pair[0]=0;}else{pair[0]=$headerCellsNoPersist.length-1;}}if(supportsNthChild){maintainWidths();}hideColumn($headerCellsNoPersist.get(pair[0]));showColumn($headerCellsNoPersist.get(pair[1]));$table.trigger('tablesawcolumns');}}$prevBtn.add($nextBtn).click(function(e){advance(!!$(e.target).closest($nextBtn).length);e.preventDefault();});function getCoord(event,key){return(event.touches||event.originalEvent.touches)[0][key];}$table.bind("touchstart.swipetoggle",function(e){var originX=getCoord(e,'pageX'),originY=getCoord(e,'pageY'),x,y;$(win).off("resize",fakeBreakpoints);$(this).bind("touchmove",function(e){x=getCoord(e,'pageX');y=getCoord(e,'pageY');var cfg=Tablesaw.config.swipe;if(Math.abs(x-originX)>cfg.horizontalThreshold&&Math.abs(y-originY)<cfg.verticalThreshold){e.preventDefault();}}).bind("touchend.swipetoggle",function(){var cfg=Tablesaw.config.swipe;if(Math.abs(y-originY)<cfg.verticalThreshold){if(x-originX<-1*cfg.horizontalThreshold){advance(true);}if(x-originX>cfg.horizontalThreshold){advance(false);}}window.setTimeout(function(){$(win).on("resize",fakeBreakpoints);},300);$(this).unbind("touchmove touchend");});}).bind("tablesawcolumns.swipetoggle",function(){$prevBtn[canAdvance(getPrev())?"removeClass":"addClass"](hideBtn);$nextBtn[canAdvance(getNext())?"removeClass":"addClass"](hideBtn);}).bind("tablesawnext.swipetoggle",function(){advance(true);}).bind("tablesawprev.swipetoggle",function(){advance(false);}).bind("tablesawdestroy.swipetoggle",function(){var $t=$(this);$t.removeClass('tablesaw-swipe');$t.prev().filter('.tablesaw-bar').find('.tablesaw-advance').remove();$(win).off("resize",fakeBreakpoints);$t.unbind(".swipetoggle");});fakeBreakpoints();$(win).on("resize",fakeBreakpoints);} $(document).on("tablesawcreate",function(e,Tablesaw){if(Tablesaw.mode==='swipe'){createSwipeTable(Tablesaw.$table);}});}(this,jQuery));;(function($){function getSortValue(cell){return $.map(cell.childNodes,function(el){var $el=$(el);if($el.is('input, select')){return $el.val();}else if($el.hasClass('tablesaw-cell-label')){return;}return $.trim($el.text());}).join('');}var pluginName="tablesaw-sortable",initSelector="table[data-"+pluginName+"]",sortableSwitchSelector="[data-"+pluginName+"-switch]",attrs={defaultCol:"data-tablesaw-sortable-default-col",numericCol:"data-tablesaw-sortable-numeric"},classes={head:pluginName+"-head",ascend:pluginName+"-ascending",descend:pluginName+"-descending",switcher:pluginName+"-switch",tableToolbar:'tablesaw-toolbar',sortButton:pluginName+"-btn"},methods={_create:function(o){return $(this).each(function(){var init=$(this).data("init"+pluginName);if(init){return false;}$(this).data("init"+pluginName,true).trigger("beforecreate."+pluginName)[pluginName]("_init",o).trigger("create."+pluginName);});},_init:function(){var el=$(this),heads,$switcher;var addClassToTable=function(){el.addClass(pluginName);},addClassToHeads=function(h){$.each(h,function(i,v){$(v).addClass(classes.head);});},makeHeadsActionable=function(h,fn){$.each(h,function(i,v){var b=$("<button class='"+classes.sortButton+"'/>");b.bind("click",{col:v},fn);$(v).wrapInner(b);});},clearOthers=function(sibs){$.each(sibs,function(i,v){var col=$(v);col.removeAttr(attrs.defaultCol);col.removeClass(classes.ascend);col.removeClass(classes.descend);});},headsOnAction=function(e){if($(e.target).is('a[href]')){return;}e.stopPropagation();var head=$(this).parent(),v=e.data.col,newSortValue=heads.index(head);clearOthers(head.siblings());if(head.hasClass(classes.descend)){el[pluginName]("sortBy",v,true);newSortValue+='_asc';}else{el[pluginName]("sortBy",v);newSortValue+='_desc';}if($switcher){$switcher.find('select').val(newSortValue).trigger('refresh');}e.preventDefault();},handleDefault=function(heads){$.each(heads,function(idx,el){var $el=$(el);if($el.is("["+attrs.defaultCol+"]")){if(!$el.hasClass(classes.descend)){$el.addClass(classes.ascend);}}});},addSwitcher=function(heads){$switcher=$('<div>').addClass(classes.switcher).addClass(classes.tableToolbar).html(function(){var html=['<label>'+Tablesaw.i18n.sort+':'];html.push('<span class="btn btn-small"> <select>');heads.each(function(j){var $t=$(this);var isDefaultCol=$t.is("["+attrs.defaultCol+"]");var isDescending=$t.hasClass(classes.descend);var hasNumericAttribute=$t.is('[data-sortable-numeric]');var numericCount=0;var numericCountMax=5;$(this.cells).slice(0,numericCountMax).each(function(){if(!isNaN(parseInt(getSortValue(this),10))){numericCount++;}});var isNumeric=numericCount===numericCountMax;if(!hasNumericAttribute){$t.attr("data-sortable-numeric",isNumeric?"":"false");}html.push('<option'+(isDefaultCol&&!isDescending?' selected':'')+' value="'+j+'_asc">'+$t.text()+' '+(isNumeric?'↑':'(A-Z)')+'</option>');html.push('<option'+(isDefaultCol&&isDescending?' selected':'')+' value="'+j+'_desc">'+$t.text()+' '+(isNumeric?'↓':'(Z-A)')+'</option>');});html.push('</select></span></label>');return html.join('');});var $toolbar=el.prev().filter('.tablesaw-bar'),$firstChild=$toolbar.children().eq(0);if($firstChild.length){$switcher.insertBefore($firstChild);}else{$switcher.appendTo($toolbar);}$switcher.find('.btn').tablesawbtn();$switcher.find('select').on('change',function(){var val=$(this).val().split('_'),head=heads.eq(val[0]);clearOthers(head.siblings());el[pluginName]('sortBy',head.get(0),val[1]==='asc');});};addClassToTable();heads=el.find("thead th[data-"+pluginName+"-col]");addClassToHeads(heads);makeHeadsActionable(heads,headsOnAction);handleDefault(heads);if(el.is(sortableSwitchSelector)){addSwitcher(heads,el.find('tbody tr:nth-child(-n+3)'));}},getColumnNumber:function(col){return $(col).prevAll().length;},getTableRows:function(){return $(this).find("tbody tr");},sortRows:function(rows,colNum,ascending,col){var cells,fn,sorted;var getCells=function(rows){var cells=[];$.each(rows,function(i,r){var element=$(r).children().get(colNum);cells.push({element:element,cell:getSortValue(element),rowNum:i});});return cells;},getSortFxn=function(ascending,forceNumeric){var fn,regex=/[^\-\+\d\.]/g;if(ascending){fn=function(a,b){if(forceNumeric){return parseFloat(a.cell.replace(regex,''))-parseFloat(b.cell.replace(regex,''));}else{return a.cell.toLowerCase()>b.cell.toLowerCase()?1:-1;}};}else{fn=function(a,b){if(forceNumeric){return parseFloat(b.cell.replace(regex,''))-parseFloat(a.cell.replace(regex,''));}else{return a.cell.toLowerCase()<b.cell.toLowerCase()?1:-1;}};}return fn;},applyToRows=function(sorted,rows){var newRows=[],i,l,cur;for(i=0,l=sorted.length;i<l;i++){cur=sorted[i].rowNum;newRows.push(rows[cur]);}return newRows;};cells=getCells(rows);var customFn=$(col).data('tablesaw-sort');fn=(customFn&&typeof customFn==="function"?customFn(ascending):false)||getSortFxn(ascending,$(col).is('[data-sortable-numeric]')&&!$(col).is('[data-sortable-numeric="false"]'));sorted=cells.sort(fn);rows=applyToRows(sorted,rows);return rows;},replaceTableRows:function(rows){var el=$(this),body=el.find("tbody");body.html(rows);},makeColDefault:function(col,a){var c=$(col);c.attr(attrs.defaultCol,"true");if(a){c.removeClass(classes.descend);c.addClass(classes.ascend);}else{c.removeClass(classes.ascend);c.addClass(classes.descend);}},sortBy:function(col,ascending){var el=$(this),colNum,rows;colNum=el[pluginName]("getColumnNumber",col);rows=el[pluginName]("getTableRows");rows=el[pluginName]("sortRows",rows,colNum,ascending,col);el[pluginName]("replaceTableRows",rows);el[pluginName]("makeColDefault",col,ascending);}};$.fn[pluginName]=function(arrg){var args=Array.prototype.slice.call(arguments,1),returnVal; if(arrg&&typeof(arrg)==="string"){returnVal=$.fn[pluginName].prototype[arrg].apply(this[0],args);return(typeof returnVal!=="undefined")?returnVal:$(this);} if(!$(this).data(pluginName+"data")){$(this).data(pluginName+"active",true);$.fn[pluginName].prototype._create.call(this,arrg);}return $(this);}; $.extend($.fn[pluginName].prototype,methods);$(document).on("tablesawcreate",function(e,Tablesaw){if(Tablesaw.$table.is(initSelector)){Tablesaw.$table[pluginName]();}});}(jQuery));;(function(win,$,undefined){var MM={attr:{init:'data-tablesaw-minimap'}};function createMiniMap($table){var $btns=$('<div class="tablesaw-advance minimap">'),$dotNav=$('<ul class="tablesaw-advance-dots">').appendTo($btns),hideDot='tablesaw-advance-dots-hide',$headerCells=$table.find('thead th'); $headerCells.each(function(){$dotNav.append('<li><i></i></li>');});$btns.appendTo($table.prev().filter('.tablesaw-bar'));function showMinimap($table){var mq=$table.attr(MM.attr.init);return!mq||win.matchMedia&&win.matchMedia(mq).matches;}function showHideNav(){if(!showMinimap($table)){$btns.hide();return;}$btns.show(); var dots=$dotNav.find("li").removeClass(hideDot);$table.find("thead th").each(function(i){if($(this).css("display")==="none"){dots.eq(i).addClass(hideDot);}});}showHideNav();$(win).on("resize",showHideNav);$table.bind("tablesawcolumns.minimap",function(){showHideNav();}).bind("tablesawdestroy.minimap",function(){var $t=$(this);$t.prev().filter('.tablesaw-bar').find('.tablesaw-advance').remove();$(win).off("resize",showHideNav);$t.unbind(".minimap");});} $(document).on("tablesawcreate",function(e,Tablesaw){if((Tablesaw.mode==='swipe'||Tablesaw.mode==='columntoggle')&&Tablesaw.$table.is('[ '+MM.attr.init+']')){createMiniMap(Tablesaw.$table);}});}(this,jQuery));;(function(win,$){var S={selectors:{init:'table[data-tablesaw-mode-switch]'},attributes:{excludeMode:'data-tablesaw-mode-exclude'},classes:{main:'tablesaw-modeswitch',toolbar:'tablesaw-toolbar'},modes:['stack','swipe','columntoggle'],init:function(table){var $table=$(table),ignoreMode=$table.attr(S.attributes.excludeMode),$toolbar=$table.prev().filter('.tablesaw-bar'),modeVal='',$switcher=$('<div>').addClass(S.classes.main+' '+S.classes.toolbar).html(function(){var html=['<label>'+Tablesaw.i18n.columns+':'],dataMode=$table.attr('data-tablesaw-mode'),isSelected;html.push('<span class="btn btn-small"> <select>');for(var j=0,k=S.modes.length;j<k;j++){if(ignoreMode&&ignoreMode.toLowerCase()===S.modes[j]){continue;}isSelected=dataMode===S.modes[j];if(isSelected){modeVal=S.modes[j];}html.push('<option'+(isSelected?' selected':'')+' value="'+S.modes[j]+'">'+Tablesaw.i18n.modes[j]+'</option>');}html.push('</select></span></label>');return html.join('');});var $otherToolbarItems=$toolbar.find('.tablesaw-advance').eq(0);if($otherToolbarItems.length){$switcher.insertBefore($otherToolbarItems);}else{$switcher.appendTo($toolbar);}$switcher.find('.btn').tablesawbtn();$switcher.find('select').bind('change',S.onModeChange);},onModeChange:function(){var $t=$(this),$switcher=$t.closest('.'+S.classes.main),$table=$t.closest('.tablesaw-bar').nextUntil($table).eq(0),val=$t.val();$switcher.remove();$table.data('table').destroy();$table.attr('data-tablesaw-mode',val);$table.table();}};$(win.document).on("tablesawcreate",function(e,Tablesaw){if(Tablesaw.$table.is(S.selectors.init)){S.init(Tablesaw.table);}});})(this,jQuery);
|
||
/*! Tablesaw - v2.0.2 - 2015-10-28
|
||
* https://github.com/filamentgroup/tablesaw
|
||
* Copyright (c) 2015 Filament Group; Licensed */
|
||
;(function($){ $(function(){$(document).trigger("enhance.tablesaw");});})(jQuery);
|
||
/*! PhotoSwipe - v4.1.2 - 2017-04-05
|
||
* http://photoswipe.com
|
||
* Copyright (c) 2017 Dmitry Semenov; */
|
||
(function (root, factory) {
|
||
if (typeof define === 'function' && define.amd) {
|
||
define(factory);
|
||
} else if (typeof exports === 'object') {
|
||
module.exports = factory();
|
||
} else {
|
||
root.PhotoSwipe = factory();
|
||
}
|
||
})(this, function () {
|
||
|
||
'use strict';
|
||
var PhotoSwipe = function(template, UiClass, items, options){
|
||
|
||
/*>>framework-bridge*/
|
||
/**
|
||
*
|
||
* Set of generic functions used by gallery.
|
||
*
|
||
* You're free to modify anything here as long as functionality is kept.
|
||
*
|
||
*/
|
||
var framework = {
|
||
features: null,
|
||
bind: function(target, type, listener, unbind) {
|
||
var methodName = (unbind ? 'remove' : 'add') + 'EventListener';
|
||
type = type.split(' ');
|
||
for(var i = 0; i < type.length; i++) {
|
||
if(type[i]) {
|
||
target[methodName]( type[i], listener, false);
|
||
}
|
||
}
|
||
},
|
||
isArray: function(obj) {
|
||
return (obj instanceof Array);
|
||
},
|
||
createEl: function(classes, tag) {
|
||
var el = document.createElement(tag || 'div');
|
||
if(classes) {
|
||
el.className = classes;
|
||
}
|
||
return el;
|
||
},
|
||
getScrollY: function() {
|
||
var yOffset = window.pageYOffset;
|
||
return yOffset !== undefined ? yOffset : document.documentElement.scrollTop;
|
||
},
|
||
unbind: function(target, type, listener) {
|
||
framework.bind(target,type,listener,true);
|
||
},
|
||
removeClass: function(el, className) {
|
||
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
|
||
el.className = el.className.replace(reg, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||
},
|
||
addClass: function(el, className) {
|
||
if( !framework.hasClass(el,className) ) {
|
||
el.className += (el.className ? ' ' : '') + className;
|
||
}
|
||
},
|
||
hasClass: function(el, className) {
|
||
return el.className && new RegExp('(^|\\s)' + className + '(\\s|$)').test(el.className);
|
||
},
|
||
getChildByClass: function(parentEl, childClassName) {
|
||
var node = parentEl.firstChild;
|
||
while(node) {
|
||
if( framework.hasClass(node, childClassName) ) {
|
||
return node;
|
||
}
|
||
node = node.nextSibling;
|
||
}
|
||
},
|
||
arraySearch: function(array, value, key) {
|
||
var i = array.length;
|
||
while(i--) {
|
||
if(array[i][key] === value) {
|
||
return i;
|
||
}
|
||
}
|
||
return -1;
|
||
},
|
||
extend: function(o1, o2, preventOverwrite) {
|
||
for (var prop in o2) {
|
||
if (o2.hasOwnProperty(prop)) {
|
||
if(preventOverwrite && o1.hasOwnProperty(prop)) {
|
||
continue;
|
||
}
|
||
o1[prop] = o2[prop];
|
||
}
|
||
}
|
||
},
|
||
easing: {
|
||
sine: {
|
||
out: function(k) {
|
||
return Math.sin(k * (Math.PI / 2));
|
||
},
|
||
inOut: function(k) {
|
||
return - (Math.cos(Math.PI * k) - 1) / 2;
|
||
}
|
||
},
|
||
cubic: {
|
||
out: function(k) {
|
||
return --k * k * k + 1;
|
||
}
|
||
}
|
||
/*
|
||
elastic: {
|
||
out: function ( k ) {
|
||
|
||
var s, a = 0.1, p = 0.4;
|
||
if ( k === 0 ) return 0;
|
||
if ( k === 1 ) return 1;
|
||
if ( !a || a < 1 ) { a = 1; s = p / 4; }
|
||
else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
|
||
return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 );
|
||
|
||
},
|
||
},
|
||
back: {
|
||
out: function ( k ) {
|
||
var s = 1.70158;
|
||
return --k * k * ( ( s + 1 ) * k + s ) + 1;
|
||
}
|
||
}
|
||
*/
|
||
},
|
||
|
||
/**
|
||
*
|
||
* @return {object}
|
||
*
|
||
* {
|
||
* raf : request animation frame function
|
||
* caf : cancel animation frame function
|
||
* transfrom : transform property key (with vendor), or null if not supported
|
||
* oldIE : IE8 or below
|
||
* }
|
||
*
|
||
*/
|
||
detectFeatures: function() {
|
||
if(framework.features) {
|
||
return framework.features;
|
||
}
|
||
var helperEl = framework.createEl(),
|
||
helperStyle = helperEl.style,
|
||
vendor = '',
|
||
features = {};
|
||
|
||
// IE8 and below
|
||
features.oldIE = document.all && !document.addEventListener;
|
||
|
||
features.touch = 'ontouchstart' in window;
|
||
|
||
if(window.requestAnimationFrame) {
|
||
features.raf = window.requestAnimationFrame;
|
||
features.caf = window.cancelAnimationFrame;
|
||
}
|
||
|
||
features.pointerEvent = navigator.pointerEnabled || navigator.msPointerEnabled;
|
||
|
||
// fix false-positive detection of old Android in new IE
|
||
// (IE11 ua string contains "Android 4.0")
|
||
|
||
if(!features.pointerEvent) {
|
||
|
||
var ua = navigator.userAgent;
|
||
|
||
// Detect if device is iPhone or iPod and if it's older than iOS 8
|
||
// http://stackoverflow.com/a/14223920
|
||
//
|
||
// This detection is made because of buggy top/bottom toolbars
|
||
// that don't trigger window.resize event.
|
||
// For more info refer to _isFixedPosition variable in core.js
|
||
|
||
if (/iP(hone|od)/.test(navigator.platform)) {
|
||
var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
|
||
if(v && v.length > 0) {
|
||
v = parseInt(v[1], 10);
|
||
if(v >= 1 && v < 8 ) {
|
||
features.isOldIOSPhone = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
// Detect old Android (before KitKat)
|
||
// due to bugs related to position:fixed
|
||
// http://stackoverflow.com/questions/7184573/pick-up-the-android-version-in-the-browser-by-javascript
|
||
|
||
var match = ua.match(/Android\s([0-9\.]*)/);
|
||
var androidversion = match ? match[1] : 0;
|
||
androidversion = parseFloat(androidversion);
|
||
if(androidversion >= 1 ) {
|
||
if(androidversion < 4.4) {
|
||
features.isOldAndroid = true; // for fixed position bug & performance
|
||
}
|
||
features.androidVersion = androidversion; // for touchend bug
|
||
}
|
||
features.isMobileOpera = /opera mini|opera mobi/i.test(ua);
|
||
|
||
// p.s. yes, yes, UA sniffing is bad, propose your solution for above bugs.
|
||
}
|
||
|
||
var styleChecks = ['transform', 'perspective', 'animationName'],
|
||
vendors = ['', 'webkit','Moz','ms','O'],
|
||
styleCheckItem,
|
||
styleName;
|
||
|
||
for(var i = 0; i < 4; i++) {
|
||
vendor = vendors[i];
|
||
|
||
for(var a = 0; a < 3; a++) {
|
||
styleCheckItem = styleChecks[a];
|
||
|
||
// uppercase first letter of property name, if vendor is present
|
||
styleName = vendor + (vendor ?
|
||
styleCheckItem.charAt(0).toUpperCase() + styleCheckItem.slice(1) :
|
||
styleCheckItem);
|
||
|
||
if(!features[styleCheckItem] && styleName in helperStyle ) {
|
||
features[styleCheckItem] = styleName;
|
||
}
|
||
}
|
||
|
||
if(vendor && !features.raf) {
|
||
vendor = vendor.toLowerCase();
|
||
features.raf = window[vendor+'RequestAnimationFrame'];
|
||
if(features.raf) {
|
||
features.caf = window[vendor+'CancelAnimationFrame'] ||
|
||
window[vendor+'CancelRequestAnimationFrame'];
|
||
}
|
||
}
|
||
}
|
||
|
||
if(!features.raf) {
|
||
var lastTime = 0;
|
||
features.raf = function(fn) {
|
||
var currTime = new Date().getTime();
|
||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||
var id = window.setTimeout(function() { fn(currTime + timeToCall); }, timeToCall);
|
||
lastTime = currTime + timeToCall;
|
||
return id;
|
||
};
|
||
features.caf = function(id) { clearTimeout(id); };
|
||
}
|
||
|
||
// Detect SVG support
|
||
features.svg = !!document.createElementNS &&
|
||
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
|
||
|
||
framework.features = features;
|
||
|
||
return features;
|
||
}
|
||
};
|
||
|
||
framework.detectFeatures();
|
||
|
||
// Override addEventListener for old versions of IE
|
||
if(framework.features.oldIE) {
|
||
|
||
framework.bind = function(target, type, listener, unbind) {
|
||
|
||
type = type.split(' ');
|
||
|
||
var methodName = (unbind ? 'detach' : 'attach') + 'Event',
|
||
evName,
|
||
_handleEv = function() {
|
||
listener.handleEvent.call(listener);
|
||
};
|
||
|
||
for(var i = 0; i < type.length; i++) {
|
||
evName = type[i];
|
||
if(evName) {
|
||
|
||
if(typeof listener === 'object' && listener.handleEvent) {
|
||
if(!unbind) {
|
||
listener['oldIE' + evName] = _handleEv;
|
||
} else {
|
||
if(!listener['oldIE' + evName]) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
target[methodName]( 'on' + evName, listener['oldIE' + evName]);
|
||
} else {
|
||
target[methodName]( 'on' + evName, listener);
|
||
}
|
||
|
||
}
|
||
}
|
||
};
|
||
|
||
}
|
||
|
||
/*>>framework-bridge*/
|
||
|
||
/*>>core*/
|
||
//function(template, UiClass, items, options)
|
||
|
||
var self = this;
|
||
|
||
/**
|
||
* Static vars, don't change unless you know what you're doing.
|
||
*/
|
||
var DOUBLE_TAP_RADIUS = 25,
|
||
NUM_HOLDERS = 3;
|
||
|
||
/**
|
||
* Options
|
||
*/
|
||
var _options = {
|
||
allowPanToNext:true,
|
||
spacing: 0.05,
|
||
bgOpacity: 1,
|
||
mouseUsed: false,
|
||
loop: false,
|
||
pinchToClose: true,
|
||
closeOnScroll: true,
|
||
closeOnVerticalDrag: true,
|
||
verticalDragRange: 0.75,
|
||
hideAnimationDuration: 333,
|
||
showAnimationDuration: 333,
|
||
showHideOpacity: false,
|
||
focus: true,
|
||
escKey: true,
|
||
arrowKeys: true,
|
||
mainScrollEndFriction: 0.35,
|
||
panEndFriction: 0.35,
|
||
isClickableElement: function(el) {
|
||
return el.tagName === 'A';
|
||
},
|
||
getDoubleTapZoom: function(isMouseClick, item) {
|
||
if(isMouseClick) {
|
||
return 1;
|
||
} else {
|
||
return item.initialZoomLevel < 0.7 ? 1 : 1.33;
|
||
}
|
||
},
|
||
maxSpreadZoom: 1.33,
|
||
modal: true,
|
||
|
||
// not fully implemented yet
|
||
scaleMode: 'fit' // TODO
|
||
};
|
||
framework.extend(_options, options);
|
||
|
||
|
||
/**
|
||
* Private helper variables & functions
|
||
*/
|
||
|
||
var _getEmptyPoint = function() {
|
||
return {x:0,y:0};
|
||
};
|
||
|
||
var _isOpen,
|
||
_isDestroying,
|
||
_closedByScroll,
|
||
_currentItemIndex,
|
||
_containerStyle,
|
||
_containerShiftIndex,
|
||
_currPanDist = _getEmptyPoint(),
|
||
_startPanOffset = _getEmptyPoint(),
|
||
_panOffset = _getEmptyPoint(),
|
||
_upMoveEvents, // drag move, drag end & drag cancel events array
|
||
_downEvents, // drag start events array
|
||
_globalEventHandlers,
|
||
_viewportSize = {},
|
||
_currZoomLevel,
|
||
_startZoomLevel,
|
||
_translatePrefix,
|
||
_translateSufix,
|
||
_updateSizeInterval,
|
||
_itemsNeedUpdate,
|
||
_currPositionIndex = 0,
|
||
_offset = {},
|
||
_slideSize = _getEmptyPoint(), // size of slide area, including spacing
|
||
_itemHolders,
|
||
_prevItemIndex,
|
||
_indexDiff = 0, // difference of indexes since last content update
|
||
_dragStartEvent,
|
||
_dragMoveEvent,
|
||
_dragEndEvent,
|
||
_dragCancelEvent,
|
||
_transformKey,
|
||
_pointerEventEnabled,
|
||
_isFixedPosition = true,
|
||
_likelyTouchDevice,
|
||
_modules = [],
|
||
_requestAF,
|
||
_cancelAF,
|
||
_initalClassName,
|
||
_initalWindowScrollY,
|
||
_oldIE,
|
||
_currentWindowScrollY,
|
||
_features,
|
||
_windowVisibleSize = {},
|
||
_renderMaxResolution = false,
|
||
_orientationChangeTimeout,
|
||
|
||
|
||
// Registers PhotoSWipe module (History, Controller ...)
|
||
_registerModule = function(name, module) {
|
||
framework.extend(self, module.publicMethods);
|
||
_modules.push(name);
|
||
},
|
||
|
||
_getLoopedId = function(index) {
|
||
var numSlides = _getNumItems();
|
||
if(index > numSlides - 1) {
|
||
return index - numSlides;
|
||
} else if(index < 0) {
|
||
return numSlides + index;
|
||
}
|
||
return index;
|
||
},
|
||
|
||
// Micro bind/trigger
|
||
_listeners = {},
|
||
_listen = function(name, fn) {
|
||
if(!_listeners[name]) {
|
||
_listeners[name] = [];
|
||
}
|
||
return _listeners[name].push(fn);
|
||
},
|
||
_shout = function(name) {
|
||
var listeners = _listeners[name];
|
||
|
||
if(listeners) {
|
||
var args = Array.prototype.slice.call(arguments);
|
||
args.shift();
|
||
|
||
for(var i = 0; i < listeners.length; i++) {
|
||
listeners[i].apply(self, args);
|
||
}
|
||
}
|
||
},
|
||
|
||
_getCurrentTime = function() {
|
||
return new Date().getTime();
|
||
},
|
||
_applyBgOpacity = function(opacity) {
|
||
_bgOpacity = opacity;
|
||
// opacity=opacity * _options.bgOpacity;
|
||
if(opacity){
|
||
$(self.bg).stop().animate({opacity:opacity}, 0);
|
||
}else{
|
||
setTimeout(function() {
|
||
$(self.bg).stop().animate({opacity:opacity}, 100);
|
||
},300)
|
||
}
|
||
// self.bg.style.opacity = opacity;
|
||
},
|
||
|
||
_applyZoomTransform = function(styleObj,x,y,zoom,item) {
|
||
if(!_renderMaxResolution || (item && item !== self.currItem) ) {
|
||
zoom = zoom / (item ? item.fitRatio : self.currItem.fitRatio);
|
||
}
|
||
|
||
styleObj[_transformKey] = _translatePrefix + x + 'px, ' + y + 'px' + _translateSufix + ' scale(' + zoom + ')';
|
||
},
|
||
_applyCurrentZoomPan = function( allowRenderResolution ) {
|
||
if(_currZoomElementStyle) {
|
||
|
||
if(allowRenderResolution) {
|
||
if(_currZoomLevel > self.currItem.fitRatio) {
|
||
if(!_renderMaxResolution) {
|
||
_setImageSize(self.currItem, false, true);
|
||
_renderMaxResolution = true;
|
||
}
|
||
} else {
|
||
if(_renderMaxResolution) {
|
||
_setImageSize(self.currItem);
|
||
_renderMaxResolution = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
_applyZoomTransform(_currZoomElementStyle, _panOffset.x, _panOffset.y, _currZoomLevel);
|
||
}
|
||
},
|
||
_applyZoomPanToItem = function(item) {
|
||
if(item.container) {
|
||
|
||
_applyZoomTransform(item.container.style,
|
||
item.initialPosition.x,
|
||
item.initialPosition.y,
|
||
item.initialZoomLevel,
|
||
item);
|
||
}
|
||
},
|
||
_setTranslateX = function(x, elStyle) {
|
||
elStyle[_transformKey] = _translatePrefix + x + 'px, 0px' + _translateSufix;
|
||
},
|
||
_moveMainScroll = function(x, dragging) {
|
||
|
||
if(!_options.loop && dragging) {
|
||
var newSlideIndexOffset = _currentItemIndex + (_slideSize.x * _currPositionIndex - x) / _slideSize.x,
|
||
delta = Math.round(x - _mainScrollPos.x);
|
||
|
||
if( (newSlideIndexOffset < 0 && delta > 0) ||
|
||
(newSlideIndexOffset >= _getNumItems() - 1 && delta < 0) ) {
|
||
x = _mainScrollPos.x + delta * _options.mainScrollEndFriction;
|
||
}
|
||
}
|
||
|
||
_mainScrollPos.x = x;
|
||
_setTranslateX(x, _containerStyle);
|
||
},
|
||
_calculatePanOffset = function(axis, zoomLevel) {
|
||
var m = _midZoomPoint[axis] - _offset[axis];
|
||
return _startPanOffset[axis] + _currPanDist[axis] + m - m * ( zoomLevel / _startZoomLevel );
|
||
},
|
||
|
||
_equalizePoints = function(p1, p2) {
|
||
p1.x = p2.x;
|
||
p1.y = p2.y;
|
||
if(p2.id) {
|
||
p1.id = p2.id;
|
||
}
|
||
},
|
||
_roundPoint = function(p) {
|
||
p.x = Math.round(p.x);
|
||
p.y = Math.round(p.y);
|
||
},
|
||
|
||
_mouseMoveTimeout = null,
|
||
_onFirstMouseMove = function() {
|
||
// Wait until mouse move event is fired at least twice during 100ms
|
||
// We do this, because some mobile browsers trigger it on touchstart
|
||
if(_mouseMoveTimeout ) {
|
||
framework.unbind(document, 'mousemove', _onFirstMouseMove);
|
||
framework.addClass(template, 'pswp--has_mouse');
|
||
_options.mouseUsed = true;
|
||
_shout('mouseUsed');
|
||
}
|
||
_mouseMoveTimeout = setTimeout(function() {
|
||
_mouseMoveTimeout = null;
|
||
}, 100);
|
||
},
|
||
|
||
_bindEvents = function() {
|
||
framework.bind(document, 'keydown', self);
|
||
|
||
if(_features.transform) {
|
||
// don't bind click event in browsers that don't support transform (mostly IE8)
|
||
framework.bind(self.scrollWrap, 'click', self);
|
||
}
|
||
|
||
|
||
if(!_options.mouseUsed) {
|
||
framework.bind(document, 'mousemove', _onFirstMouseMove);
|
||
}
|
||
|
||
framework.bind(window, 'resize scroll orientationchange', self);
|
||
|
||
_shout('bindEvents');
|
||
},
|
||
|
||
_unbindEvents = function() {
|
||
framework.unbind(window, 'resize scroll orientationchange', self);
|
||
framework.unbind(window, 'scroll', _globalEventHandlers.scroll);
|
||
framework.unbind(document, 'keydown', self);
|
||
framework.unbind(document, 'mousemove', _onFirstMouseMove);
|
||
|
||
if(_features.transform) {
|
||
framework.unbind(self.scrollWrap, 'click', self);
|
||
}
|
||
|
||
if(_isDragging) {
|
||
framework.unbind(window, _upMoveEvents, self);
|
||
}
|
||
|
||
clearTimeout(_orientationChangeTimeout);
|
||
|
||
_shout('unbindEvents');
|
||
},
|
||
|
||
_calculatePanBounds = function(zoomLevel, update) {
|
||
var bounds = _calculateItemSize( self.currItem, _viewportSize, zoomLevel );
|
||
if(update) {
|
||
_currPanBounds = bounds;
|
||
}
|
||
return bounds;
|
||
},
|
||
|
||
_getMinZoomLevel = function(item) {
|
||
if(!item) {
|
||
item = self.currItem;
|
||
}
|
||
return item.initialZoomLevel;
|
||
},
|
||
_getMaxZoomLevel = function(item) {
|
||
if(!item) {
|
||
item = self.currItem;
|
||
}
|
||
return item.w > 0 ? _options.maxSpreadZoom : 1;
|
||
},
|
||
|
||
// Return true if offset is out of the bounds
|
||
_modifyDestPanOffset = function(axis, destPanBounds, destPanOffset, destZoomLevel) {
|
||
if(destZoomLevel === self.currItem.initialZoomLevel) {
|
||
destPanOffset[axis] = self.currItem.initialPosition[axis];
|
||
return true;
|
||
} else {
|
||
destPanOffset[axis] = _calculatePanOffset(axis, destZoomLevel);
|
||
|
||
if(destPanOffset[axis] > destPanBounds.min[axis]) {
|
||
destPanOffset[axis] = destPanBounds.min[axis];
|
||
return true;
|
||
} else if(destPanOffset[axis] < destPanBounds.max[axis] ) {
|
||
destPanOffset[axis] = destPanBounds.max[axis];
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
},
|
||
|
||
_setupTransforms = function() {
|
||
|
||
if(_transformKey) {
|
||
// setup 3d transforms
|
||
var allow3dTransform = _features.perspective && !_likelyTouchDevice;
|
||
_translatePrefix = 'translate' + (allow3dTransform ? '3d(' : '(');
|
||
_translateSufix = _features.perspective ? ', 0px)' : ')';
|
||
return;
|
||
}
|
||
|
||
// Override zoom/pan/move functions in case old browser is used (most likely IE)
|
||
// (so they use left/top/width/height, instead of CSS transform)
|
||
|
||
_transformKey = 'left';
|
||
framework.addClass(template, 'pswp--ie');
|
||
|
||
_setTranslateX = function(x, elStyle) {
|
||
elStyle.left = x + 'px';
|
||
};
|
||
_applyZoomPanToItem = function(item) {
|
||
|
||
var zoomRatio = item.fitRatio > 1 ? 1 : item.fitRatio,
|
||
s = item.container.style,
|
||
w = zoomRatio * item.w,
|
||
h = zoomRatio * item.h;
|
||
|
||
s.width = w + 'px';
|
||
s.height = h + 'px';
|
||
s.left = item.initialPosition.x + 'px';
|
||
s.top = item.initialPosition.y + 'px';
|
||
|
||
};
|
||
_applyCurrentZoomPan = function() {
|
||
if(_currZoomElementStyle) {
|
||
|
||
var s = _currZoomElementStyle,
|
||
item = self.currItem,
|
||
zoomRatio = item.fitRatio > 1 ? 1 : item.fitRatio,
|
||
w = zoomRatio * item.w,
|
||
h = zoomRatio * item.h;
|
||
|
||
s.width = w + 'px';
|
||
s.height = h + 'px';
|
||
|
||
|
||
s.left = _panOffset.x + 'px';
|
||
s.top = _panOffset.y + 'px';
|
||
}
|
||
|
||
};
|
||
},
|
||
|
||
_onKeyDown = function(e) {
|
||
var keydownAction = '';
|
||
if(_options.escKey && e.keyCode === 27) {
|
||
keydownAction = 'close';
|
||
} else if(_options.arrowKeys) {
|
||
if(e.keyCode === 37) {
|
||
keydownAction = 'prev';
|
||
} else if(e.keyCode === 39) {
|
||
keydownAction = 'next';
|
||
}
|
||
}
|
||
|
||
if(keydownAction) {
|
||
// don't do anything if special key pressed to prevent from overriding default browser actions
|
||
// e.g. in Chrome on Mac cmd+arrow-left returns to previous page
|
||
if( !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey ) {
|
||
if(e.preventDefault) {
|
||
e.preventDefault();
|
||
} else {
|
||
e.returnValue = false;
|
||
}
|
||
self[keydownAction]();
|
||
}
|
||
}
|
||
},
|
||
|
||
_onGlobalClick = function(e) {
|
||
if(!e) {
|
||
return;
|
||
}
|
||
|
||
// don't allow click event to pass through when triggering after drag or some other gesture
|
||
if(_moved || _zoomStarted || _mainScrollAnimating || _verticalDragInitiated) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
}
|
||
},
|
||
|
||
_updatePageScrollOffset = function() {
|
||
self.setScrollOffset(0, framework.getScrollY());
|
||
}
|
||
// Micro animation engine
|
||
var _animations = {},
|
||
_numAnimations = 0,
|
||
_stopAnimation = function(name) {
|
||
if(_animations[name]) {
|
||
if(_animations[name].raf) {
|
||
_cancelAF( _animations[name].raf );
|
||
}
|
||
_numAnimations--;
|
||
delete _animations[name];
|
||
}
|
||
},
|
||
_registerStartAnimation = function(name) {
|
||
if(_animations[name]) {
|
||
_stopAnimation(name);
|
||
}
|
||
if(!_animations[name]) {
|
||
_numAnimations++;
|
||
_animations[name] = {};
|
||
}
|
||
},
|
||
_stopAllAnimations = function() {
|
||
for (var prop in _animations) {
|
||
|
||
if( _animations.hasOwnProperty( prop ) ) {
|
||
_stopAnimation(prop);
|
||
}
|
||
|
||
}
|
||
},
|
||
_animateProp = function(name, b, endProp, d, easingFn, onUpdate, onComplete) {
|
||
var startAnimTime = _getCurrentTime(), t;
|
||
_registerStartAnimation(name);
|
||
|
||
var animloop = function(){
|
||
if ( _animations[name] ) {
|
||
|
||
t = _getCurrentTime() - startAnimTime; // time diff
|
||
//b - beginning (start prop)
|
||
//d - anim duration
|
||
|
||
if ( t >= d ) {
|
||
_stopAnimation(name);
|
||
onUpdate(endProp);
|
||
if(onComplete) {
|
||
onComplete();
|
||
}
|
||
return;
|
||
}
|
||
onUpdate( (endProp - b) * easingFn(t/d) + b );
|
||
|
||
_animations[name].raf = _requestAF(animloop);
|
||
}
|
||
};
|
||
animloop();
|
||
};
|
||
|
||
|
||
|
||
var publicMethods = {
|
||
|
||
// make a few local variables and functions public
|
||
shout: _shout,
|
||
listen: _listen,
|
||
viewportSize: _viewportSize,
|
||
options: _options,
|
||
|
||
isMainScrollAnimating: function() {
|
||
return _mainScrollAnimating;
|
||
},
|
||
getZoomLevel: function() {
|
||
return _currZoomLevel;
|
||
},
|
||
getCurrentIndex: function() {
|
||
return _currentItemIndex;
|
||
},
|
||
isDragging: function() {
|
||
return _isDragging;
|
||
},
|
||
isZooming: function() {
|
||
return _isZooming;
|
||
},
|
||
setScrollOffset: function(x,y) {
|
||
_offset.x = x;
|
||
_currentWindowScrollY = _offset.y = y;
|
||
_shout('updateScrollOffset', _offset);
|
||
},
|
||
applyZoomPan: function(zoomLevel,panX,panY,allowRenderResolution) {
|
||
_panOffset.x = panX;
|
||
_panOffset.y = panY;
|
||
_currZoomLevel = zoomLevel;
|
||
_applyCurrentZoomPan( allowRenderResolution );
|
||
},
|
||
|
||
init: function() {
|
||
|
||
if(_isOpen || _isDestroying) {
|
||
return;
|
||
}
|
||
|
||
var i;
|
||
|
||
self.framework = framework; // basic functionality
|
||
self.template = template; // root DOM element of PhotoSwipe
|
||
self.bg = framework.getChildByClass(template, 'pswp__bg');
|
||
|
||
_initalClassName = template.className;
|
||
_isOpen = true;
|
||
|
||
_features = framework.detectFeatures();
|
||
_requestAF = _features.raf;
|
||
_cancelAF = _features.caf;
|
||
_transformKey = _features.transform;
|
||
_oldIE = _features.oldIE;
|
||
|
||
self.scrollWrap = framework.getChildByClass(template, 'pswp__scroll-wrap');
|
||
self.container = framework.getChildByClass(self.scrollWrap, 'pswp__container');
|
||
|
||
_containerStyle = self.container.style; // for fast access
|
||
|
||
// Objects that hold slides (there are only 3 in DOM)
|
||
self.itemHolders = _itemHolders = [
|
||
{el:self.container.children[0] , wrap:0, index: -1},
|
||
{el:self.container.children[1] , wrap:0, index: -1},
|
||
{el:self.container.children[2] , wrap:0, index: -1}
|
||
];
|
||
|
||
// hide nearby item holders until initial zoom animation finishes (to avoid extra Paints)
|
||
_itemHolders[0].el.style.display = _itemHolders[2].el.style.display = 'none';
|
||
|
||
_setupTransforms();
|
||
|
||
// Setup global events
|
||
_globalEventHandlers = {
|
||
resize: self.updateSize,
|
||
|
||
// Fixes: iOS 10.3 resize event
|
||
// does not update scrollWrap.clientWidth instantly after resize
|
||
// https://github.com/dimsemenov/PhotoSwipe/issues/1315
|
||
orientationchange: function() {
|
||
clearTimeout(_orientationChangeTimeout);
|
||
_orientationChangeTimeout = setTimeout(function() {
|
||
if(_viewportSize.x !== self.scrollWrap.clientWidth) {
|
||
self.updateSize();
|
||
}
|
||
}, 500);
|
||
},
|
||
scroll: _updatePageScrollOffset,
|
||
keydown: _onKeyDown,
|
||
click: _onGlobalClick
|
||
};
|
||
|
||
// disable show/hide effects on old browsers that don't support CSS animations or transforms,
|
||
// old IOS, Android and Opera mobile. Blackberry seems to work fine, even older models.
|
||
var oldPhone = _features.isOldIOSPhone || _features.isOldAndroid || _features.isMobileOpera;
|
||
if(!_features.animationName || !_features.transform || oldPhone) {
|
||
_options.showAnimationDuration = _options.hideAnimationDuration = 0;
|
||
}
|
||
|
||
// init modules
|
||
for(i = 0; i < _modules.length; i++) {
|
||
self['init' + _modules[i]]();
|
||
}
|
||
|
||
// init
|
||
if(UiClass) {
|
||
var ui = self.ui = new UiClass(self, framework);
|
||
ui.init();
|
||
}
|
||
|
||
_shout('firstUpdate');
|
||
_currentItemIndex = _currentItemIndex || _options.index || 0;
|
||
// validate index
|
||
if( isNaN(_currentItemIndex) || _currentItemIndex < 0 || _currentItemIndex >= _getNumItems() ) {
|
||
_currentItemIndex = 0;
|
||
}
|
||
self.currItem = _getItemAt( _currentItemIndex );
|
||
|
||
|
||
if(_features.isOldIOSPhone || _features.isOldAndroid) {
|
||
_isFixedPosition = false;
|
||
}
|
||
|
||
template.setAttribute('aria-hidden', 'false');
|
||
if(_options.modal) {
|
||
if(!_isFixedPosition) {
|
||
template.style.position = 'absolute';
|
||
template.style.top = framework.getScrollY() + 'px';
|
||
} else {
|
||
template.style.position = 'fixed';
|
||
}
|
||
}
|
||
|
||
if(_currentWindowScrollY === undefined) {
|
||
_shout('initialLayout');
|
||
_currentWindowScrollY = _initalWindowScrollY = framework.getScrollY();
|
||
}
|
||
|
||
// add classes to root element of PhotoSwipe
|
||
var rootClasses = 'pswp--open ';
|
||
if(_options.mainClass) {
|
||
rootClasses += _options.mainClass + ' ';
|
||
}
|
||
if(_options.showHideOpacity) {
|
||
rootClasses += 'pswp--animate_opacity ';
|
||
}
|
||
rootClasses += _likelyTouchDevice ? 'pswp--touch' : 'pswp--notouch';
|
||
rootClasses += _features.animationName ? ' pswp--css_animation' : '';
|
||
rootClasses += _features.svg ? ' pswp--svg' : '';
|
||
framework.addClass(template, rootClasses);
|
||
|
||
self.updateSize();
|
||
|
||
// initial update
|
||
_containerShiftIndex = -1;
|
||
_indexDiff = null;
|
||
for(i = 0; i < NUM_HOLDERS; i++) {
|
||
_setTranslateX( (i+_containerShiftIndex) * _slideSize.x, _itemHolders[i].el.style);
|
||
}
|
||
|
||
if(!_oldIE) {
|
||
framework.bind(self.scrollWrap, _downEvents, self); // no dragging for old IE
|
||
}
|
||
|
||
_listen('initialZoomInEnd', function() {
|
||
self.setContent(_itemHolders[0], _currentItemIndex-1);
|
||
self.setContent(_itemHolders[2], _currentItemIndex+1);
|
||
|
||
_itemHolders[0].el.style.display = _itemHolders[2].el.style.display = 'block';
|
||
|
||
if(_options.focus) {
|
||
// focus causes layout,
|
||
// which causes lag during the animation,
|
||
// that's why we delay it untill the initial zoom transition ends
|
||
template.focus();
|
||
}
|
||
|
||
|
||
_bindEvents();
|
||
});
|
||
|
||
// set content for center slide (first time)
|
||
self.setContent(_itemHolders[1], _currentItemIndex);
|
||
|
||
self.updateCurrItem();
|
||
|
||
_shout('afterInit');
|
||
|
||
if(!_isFixedPosition) {
|
||
|
||
// On all versions of iOS lower than 8.0, we check size of viewport every second.
|
||
//
|
||
// This is done to detect when Safari top & bottom bars appear,
|
||
// as this action doesn't trigger any events (like resize).
|
||
//
|
||
// On iOS8 they fixed this.
|
||
//
|
||
// 10 Nov 2014: iOS 7 usage ~40%. iOS 8 usage 56%.
|
||
|
||
_updateSizeInterval = setInterval(function() {
|
||
if(!_numAnimations && !_isDragging && !_isZooming && (_currZoomLevel === self.currItem.initialZoomLevel) ) {
|
||
self.updateSize();
|
||
}
|
||
}, 1000);
|
||
}
|
||
|
||
framework.addClass(template, 'pswp--visible');
|
||
|
||
// 屏蔽滚动条滚动
|
||
setTimeout(function(){
|
||
$('html').css({overflow:'hidden',height:'100%'});
|
||
},300);
|
||
},
|
||
|
||
// Close the gallery, then destroy it
|
||
close: function() {
|
||
if(!_isOpen) {
|
||
return;
|
||
}
|
||
// 撤销滚动条屏蔽
|
||
$('html').css({overflow:'',height:''});
|
||
_isOpen = false;
|
||
_isDestroying = true;
|
||
_shout('close');
|
||
_unbindEvents();
|
||
|
||
_showOrHide(self.currItem, null, true, self.destroy);
|
||
},
|
||
|
||
// destroys the gallery (unbinds events, cleans up intervals and timeouts to avoid memory leaks)
|
||
destroy: function() {
|
||
_shout('destroy');
|
||
|
||
if(_showOrHideTimeout) {
|
||
clearTimeout(_showOrHideTimeout);
|
||
}
|
||
|
||
template.setAttribute('aria-hidden', 'true');
|
||
template.className = _initalClassName;
|
||
|
||
if(_updateSizeInterval) {
|
||
clearInterval(_updateSizeInterval);
|
||
}
|
||
|
||
framework.unbind(self.scrollWrap, _downEvents, self);
|
||
|
||
// we unbind scroll event at the end, as closing animation may depend on it
|
||
framework.unbind(window, 'scroll', self);
|
||
|
||
_stopDragUpdateLoop();
|
||
|
||
_stopAllAnimations();
|
||
|
||
_listeners = null;
|
||
},
|
||
|
||
/**
|
||
* Pan image to position
|
||
* @param {Number} x
|
||
* @param {Number} y
|
||
* @param {Boolean} force Will ignore bounds if set to true.
|
||
*/
|
||
panTo: function(x,y,force) {
|
||
if(!force) {
|
||
if(x > _currPanBounds.min.x) {
|
||
x = _currPanBounds.min.x;
|
||
} else if(x < _currPanBounds.max.x) {
|
||
x = _currPanBounds.max.x;
|
||
}
|
||
|
||
if(y > _currPanBounds.min.y) {
|
||
y = _currPanBounds.min.y;
|
||
} else if(y < _currPanBounds.max.y) {
|
||
y = _currPanBounds.max.y;
|
||
}
|
||
}
|
||
|
||
_panOffset.x = x;
|
||
_panOffset.y = y;
|
||
_applyCurrentZoomPan();
|
||
},
|
||
|
||
handleEvent: function (e) {
|
||
e = e || window.event;
|
||
if(_globalEventHandlers[e.type]) {
|
||
_globalEventHandlers[e.type](e);
|
||
}
|
||
},
|
||
|
||
|
||
goTo: function(index) {
|
||
var $container=$(self.container);
|
||
$container.addClass('transition500');
|
||
setTimeout(function(){
|
||
$container.removeClass('transition500');
|
||
},500)
|
||
index = _getLoopedId(index);
|
||
|
||
var diff = index - _currentItemIndex;
|
||
_indexDiff = diff;
|
||
|
||
_currentItemIndex = index;
|
||
self.currItem = _getItemAt( _currentItemIndex );
|
||
_currPositionIndex -= diff;
|
||
|
||
_moveMainScroll(_slideSize.x * _currPositionIndex);
|
||
|
||
|
||
_stopAllAnimations();
|
||
_mainScrollAnimating = false;
|
||
|
||
self.updateCurrItem();
|
||
},
|
||
next: function() {
|
||
self.goTo( _currentItemIndex + 1);
|
||
},
|
||
prev: function() {
|
||
self.goTo( _currentItemIndex - 1);
|
||
},
|
||
|
||
// update current zoom/pan objects
|
||
updateCurrZoomItem: function(emulateSetContent) {
|
||
if(emulateSetContent) {
|
||
_shout('beforeChange', 0);
|
||
}
|
||
|
||
// itemHolder[1] is middle (current) item
|
||
if(_itemHolders[1].el.children.length) {
|
||
var zoomElement = _itemHolders[1].el.children[0];
|
||
if( framework.hasClass(zoomElement, 'pswp__zoom-wrap') ) {
|
||
_currZoomElementStyle = zoomElement.style;
|
||
} else {
|
||
_currZoomElementStyle = null;
|
||
}
|
||
} else {
|
||
_currZoomElementStyle = null;
|
||
}
|
||
|
||
_currPanBounds = self.currItem.bounds;
|
||
_startZoomLevel = _currZoomLevel = self.currItem.initialZoomLevel;
|
||
|
||
_panOffset.x = _currPanBounds.center.x;
|
||
_panOffset.y = _currPanBounds.center.y;
|
||
|
||
if(emulateSetContent) {
|
||
_shout('afterChange');
|
||
}
|
||
},
|
||
|
||
|
||
invalidateCurrItems: function() {
|
||
_itemsNeedUpdate = true;
|
||
for(var i = 0; i < NUM_HOLDERS; i++) {
|
||
if( _itemHolders[i].item ) {
|
||
_itemHolders[i].item.needsUpdate = true;
|
||
}
|
||
}
|
||
},
|
||
|
||
updateCurrItem: function(beforeAnimation) {
|
||
|
||
if(_indexDiff === 0) {
|
||
return;
|
||
}
|
||
|
||
var diffAbs = Math.abs(_indexDiff),
|
||
tempHolder;
|
||
|
||
if(beforeAnimation && diffAbs < 2) {
|
||
return;
|
||
}
|
||
|
||
|
||
self.currItem = _getItemAt( _currentItemIndex );
|
||
_renderMaxResolution = false;
|
||
|
||
_shout('beforeChange', _indexDiff);
|
||
|
||
if(diffAbs >= NUM_HOLDERS) {
|
||
_containerShiftIndex += _indexDiff + (_indexDiff > 0 ? -NUM_HOLDERS : NUM_HOLDERS);
|
||
diffAbs = NUM_HOLDERS;
|
||
}
|
||
for(var i = 0; i < diffAbs; i++) {
|
||
if(_indexDiff > 0) {
|
||
tempHolder = _itemHolders.shift();
|
||
_itemHolders[NUM_HOLDERS-1] = tempHolder; // move first to last
|
||
|
||
_containerShiftIndex++;
|
||
_setTranslateX( (_containerShiftIndex+2) * _slideSize.x, tempHolder.el.style);
|
||
self.setContent(tempHolder, _currentItemIndex - diffAbs + i + 1 + 1);
|
||
} else {
|
||
tempHolder = _itemHolders.pop();
|
||
_itemHolders.unshift( tempHolder ); // move last to first
|
||
|
||
_containerShiftIndex--;
|
||
_setTranslateX( _containerShiftIndex * _slideSize.x, tempHolder.el.style);
|
||
self.setContent(tempHolder, _currentItemIndex + diffAbs - i - 1 - 1);
|
||
}
|
||
|
||
}
|
||
|
||
// reset zoom/pan on previous item
|
||
if(_currZoomElementStyle && Math.abs(_indexDiff) === 1) {
|
||
|
||
var prevItem = _getItemAt(_prevItemIndex);
|
||
if(prevItem.initialZoomLevel !== _currZoomLevel) {
|
||
_calculateItemSize(prevItem , _viewportSize );
|
||
_setImageSize(prevItem);
|
||
_applyZoomPanToItem( prevItem );
|
||
}
|
||
|
||
}
|
||
|
||
// reset diff after update
|
||
_indexDiff = 0;
|
||
|
||
self.updateCurrZoomItem();
|
||
|
||
_prevItemIndex = _currentItemIndex;
|
||
|
||
_shout('afterChange');
|
||
|
||
},
|
||
|
||
|
||
|
||
updateSize: function(force) {
|
||
|
||
if(!_isFixedPosition && _options.modal) {
|
||
var windowScrollY = framework.getScrollY();
|
||
if(_currentWindowScrollY !== windowScrollY) {
|
||
template.style.top = windowScrollY + 'px';
|
||
_currentWindowScrollY = windowScrollY;
|
||
}
|
||
if(!force && _windowVisibleSize.x === window.innerWidth && _windowVisibleSize.y === window.innerHeight) {
|
||
return;
|
||
}
|
||
_windowVisibleSize.x = window.innerWidth;
|
||
_windowVisibleSize.y = window.innerHeight;
|
||
|
||
//template.style.width = _windowVisibleSize.x + 'px';
|
||
template.style.height = _windowVisibleSize.y + 'px';
|
||
}
|
||
|
||
|
||
|
||
_viewportSize.x = self.scrollWrap.clientWidth;
|
||
_viewportSize.y = self.scrollWrap.clientHeight;
|
||
|
||
_updatePageScrollOffset();
|
||
|
||
_slideSize.x = _viewportSize.x + Math.round(_viewportSize.x * _options.spacing);
|
||
_slideSize.y = _viewportSize.y;
|
||
|
||
_moveMainScroll(_slideSize.x * _currPositionIndex);
|
||
|
||
_shout('beforeResize'); // even may be used for example to switch image sources
|
||
|
||
|
||
// don't re-calculate size on inital size update
|
||
if(_containerShiftIndex !== undefined) {
|
||
|
||
var holder,
|
||
item,
|
||
hIndex;
|
||
|
||
for(var i = 0; i < NUM_HOLDERS; i++) {
|
||
holder = _itemHolders[i];
|
||
_setTranslateX( (i+_containerShiftIndex) * _slideSize.x, holder.el.style);
|
||
|
||
hIndex = _currentItemIndex+i-1;
|
||
|
||
if(_options.loop && _getNumItems() > 2) {
|
||
hIndex = _getLoopedId(hIndex);
|
||
}
|
||
|
||
// update zoom level on items and refresh source (if needsUpdate)
|
||
item = _getItemAt( hIndex );
|
||
|
||
// re-render gallery item if `needsUpdate`,
|
||
// or doesn't have `bounds` (entirely new slide object)
|
||
if( item && (_itemsNeedUpdate || item.needsUpdate || !item.bounds) ) {
|
||
|
||
self.cleanSlide( item );
|
||
|
||
self.setContent( holder, hIndex );
|
||
|
||
// if "center" slide
|
||
if(i === 1) {
|
||
self.currItem = item;
|
||
self.updateCurrZoomItem(true);
|
||
}
|
||
|
||
item.needsUpdate = false;
|
||
|
||
} else if(holder.index === -1 && hIndex >= 0) {
|
||
// add content first time
|
||
self.setContent( holder, hIndex );
|
||
}
|
||
if(item && item.container) {
|
||
_calculateItemSize(item, _viewportSize);
|
||
_setImageSize(item);
|
||
_applyZoomPanToItem( item );
|
||
}
|
||
|
||
}
|
||
_itemsNeedUpdate = false;
|
||
}
|
||
|
||
_startZoomLevel = _currZoomLevel = self.currItem.initialZoomLevel;
|
||
_currPanBounds = self.currItem.bounds;
|
||
|
||
if(_currPanBounds) {
|
||
_panOffset.x = _currPanBounds.center.x;
|
||
_panOffset.y = _currPanBounds.center.y;
|
||
_applyCurrentZoomPan( true );
|
||
}
|
||
|
||
_shout('resize');
|
||
},
|
||
|
||
// Zoom current item to
|
||
zoomTo: function(destZoomLevel, centerPoint, speed, easingFn, updateFn) {
|
||
/*
|
||
if(destZoomLevel === 'fit') {
|
||
destZoomLevel = self.currItem.fitRatio;
|
||
} else if(destZoomLevel === 'fill') {
|
||
destZoomLevel = self.currItem.fillRatio;
|
||
}
|
||
*/
|
||
|
||
if(centerPoint) {
|
||
_startZoomLevel = _currZoomLevel;
|
||
_midZoomPoint.x = Math.abs(centerPoint.x) - _panOffset.x ;
|
||
_midZoomPoint.y = Math.abs(centerPoint.y) - _panOffset.y ;
|
||
_equalizePoints(_startPanOffset, _panOffset);
|
||
}
|
||
|
||
var destPanBounds = _calculatePanBounds(destZoomLevel, false),
|
||
destPanOffset = {};
|
||
|
||
_modifyDestPanOffset('x', destPanBounds, destPanOffset, destZoomLevel);
|
||
_modifyDestPanOffset('y', destPanBounds, destPanOffset, destZoomLevel);
|
||
|
||
var initialZoomLevel = _currZoomLevel;
|
||
var initialPanOffset = {
|
||
x: _panOffset.x,
|
||
y: _panOffset.y
|
||
};
|
||
|
||
_roundPoint(destPanOffset);
|
||
|
||
var onUpdate = function(now) {
|
||
if(now === 1) {
|
||
_currZoomLevel = destZoomLevel;
|
||
_panOffset.x = destPanOffset.x;
|
||
_panOffset.y = destPanOffset.y;
|
||
} else {
|
||
_currZoomLevel = (destZoomLevel - initialZoomLevel) * now + initialZoomLevel;
|
||
_panOffset.x = (destPanOffset.x - initialPanOffset.x) * now + initialPanOffset.x;
|
||
_panOffset.y = (destPanOffset.y - initialPanOffset.y) * now + initialPanOffset.y;
|
||
}
|
||
|
||
if(updateFn) {
|
||
updateFn(now);
|
||
}
|
||
|
||
_applyCurrentZoomPan( now === 1 );
|
||
};
|
||
|
||
if(speed) {
|
||
_animateProp('customZoomTo', 0, 1, speed, easingFn || framework.easing.sine.inOut, onUpdate);
|
||
} else {
|
||
onUpdate(1);
|
||
}
|
||
},
|
||
};
|
||
|
||
|
||
/*>>core*/
|
||
|
||
/*>>gestures*/
|
||
/**
|
||
* Mouse/touch/pointer event handlers.
|
||
*
|
||
* separated from @core.js for readability
|
||
*/
|
||
|
||
var MIN_SWIPE_DISTANCE = 30,
|
||
DIRECTION_CHECK_OFFSET = 10; // amount of pixels to drag to determine direction of swipe
|
||
|
||
var _gestureStartTime,
|
||
_gestureCheckSpeedTime,
|
||
|
||
// pool of objects that are used during dragging of zooming
|
||
p = {}, // first point
|
||
p2 = {}, // second point (for zoom gesture)
|
||
delta = {},
|
||
_currPoint = {},
|
||
_startPoint = {},
|
||
_currPointers = [],
|
||
_startMainScrollPos = {},
|
||
_releaseAnimData,
|
||
_posPoints = [], // array of points during dragging, used to determine type of gesture
|
||
_tempPoint = {},
|
||
|
||
_isZoomingIn,
|
||
_verticalDragInitiated,
|
||
_oldAndroidTouchEndTimeout,
|
||
_currZoomedItemIndex = 0,
|
||
_centerPoint = _getEmptyPoint(),
|
||
_lastReleaseTime = 0,
|
||
_isDragging, // at least one pointer is down
|
||
_isMultitouch, // at least two _pointers are down
|
||
_zoomStarted, // zoom level changed during zoom gesture
|
||
_moved,
|
||
_dragAnimFrame,
|
||
_mainScrollShifted,
|
||
_currentPoints, // array of current touch points
|
||
_isZooming,
|
||
_currPointsDistance,
|
||
_startPointsDistance,
|
||
_currPanBounds,
|
||
_mainScrollPos = _getEmptyPoint(),
|
||
_currZoomElementStyle,
|
||
_mainScrollAnimating, // true, if animation after swipe gesture is running
|
||
_midZoomPoint = _getEmptyPoint(),
|
||
_currCenterPoint = _getEmptyPoint(),
|
||
_direction,
|
||
_isFirstMove,
|
||
_opacityChanged,
|
||
_bgOpacity,
|
||
_wasOverInitialZoom,
|
||
|
||
_isEqualPoints = function(p1, p2) {
|
||
return p1.x === p2.x && p1.y === p2.y;
|
||
},
|
||
_isNearbyPoints = function(touch0, touch1) {
|
||
return Math.abs(touch0.x - touch1.x) < DOUBLE_TAP_RADIUS && Math.abs(touch0.y - touch1.y) < DOUBLE_TAP_RADIUS;
|
||
},
|
||
_calculatePointsDistance = function(p1, p2) {
|
||
_tempPoint.x = Math.abs( p1.x - p2.x );
|
||
_tempPoint.y = Math.abs( p1.y - p2.y );
|
||
return Math.sqrt(_tempPoint.x * _tempPoint.x + _tempPoint.y * _tempPoint.y);
|
||
},
|
||
_stopDragUpdateLoop = function() {
|
||
if(_dragAnimFrame) {
|
||
_cancelAF(_dragAnimFrame);
|
||
_dragAnimFrame = null;
|
||
}
|
||
},
|
||
_dragUpdateLoop = function() {
|
||
if(_isDragging) {
|
||
_dragAnimFrame = _requestAF(_dragUpdateLoop);
|
||
_renderMovement();
|
||
}
|
||
},
|
||
_canPan = function() {
|
||
return !(_options.scaleMode === 'fit' && _currZoomLevel === self.currItem.initialZoomLevel);
|
||
},
|
||
|
||
// find the closest parent DOM element
|
||
_closestElement = function(el, fn) {
|
||
if(!el || el === document) {
|
||
return false;
|
||
}
|
||
|
||
// don't search elements above pswp__scroll-wrap
|
||
if(el.getAttribute('class') && el.getAttribute('class').indexOf('pswp__scroll-wrap') > -1 ) {
|
||
return false;
|
||
}
|
||
|
||
if( fn(el) ) {
|
||
return el;
|
||
}
|
||
|
||
return _closestElement(el.parentNode, fn);
|
||
},
|
||
|
||
_preventObj = {},
|
||
_preventDefaultEventBehaviour = function(e, isDown) {
|
||
_preventObj.prevent = !_closestElement(e.target, _options.isClickableElement);
|
||
|
||
_shout('preventDragEvent', e, isDown, _preventObj);
|
||
return _preventObj.prevent;
|
||
|
||
},
|
||
_convertTouchToPoint = function(touch, p) {
|
||
p.x = touch.pageX;
|
||
p.y = touch.pageY;
|
||
p.id = touch.identifier;
|
||
return p;
|
||
},
|
||
_findCenterOfPoints = function(p1, p2, pCenter) {
|
||
pCenter.x = (p1.x + p2.x) * 0.5;
|
||
pCenter.y = (p1.y + p2.y) * 0.5;
|
||
},
|
||
_pushPosPoint = function(time, x, y) {
|
||
if(time - _gestureCheckSpeedTime > 50) {
|
||
var o = _posPoints.length > 2 ? _posPoints.shift() : {};
|
||
o.x = x;
|
||
o.y = y;
|
||
_posPoints.push(o);
|
||
_gestureCheckSpeedTime = time;
|
||
}
|
||
},
|
||
|
||
_calculateVerticalDragOpacityRatio = function() {
|
||
var yOffset = _panOffset.y - self.currItem.initialPosition.y; // difference between initial and current position
|
||
return 1 - Math.abs( yOffset / (_viewportSize.y / 2) );
|
||
},
|
||
|
||
|
||
// points pool, reused during touch events
|
||
_ePoint1 = {},
|
||
_ePoint2 = {},
|
||
_tempPointsArr = [],
|
||
_tempCounter,
|
||
_getTouchPoints = function(e) {
|
||
// clean up previous points, without recreating array
|
||
while(_tempPointsArr.length > 0) {
|
||
_tempPointsArr.pop();
|
||
}
|
||
|
||
if(!_pointerEventEnabled) {
|
||
if(e.type.indexOf('touch') > -1) {
|
||
|
||
if(e.touches && e.touches.length > 0) {
|
||
_tempPointsArr[0] = _convertTouchToPoint(e.touches[0], _ePoint1);
|
||
if(e.touches.length > 1) {
|
||
_tempPointsArr[1] = _convertTouchToPoint(e.touches[1], _ePoint2);
|
||
}
|
||
}
|
||
|
||
} else {
|
||
_ePoint1.x = e.pageX;
|
||
_ePoint1.y = e.pageY;
|
||
_ePoint1.id = '';
|
||
_tempPointsArr[0] = _ePoint1;//_ePoint1;
|
||
}
|
||
} else {
|
||
_tempCounter = 0;
|
||
// we can use forEach, as pointer events are supported only in modern browsers
|
||
_currPointers.forEach(function(p) {
|
||
if(_tempCounter === 0) {
|
||
_tempPointsArr[0] = p;
|
||
} else if(_tempCounter === 1) {
|
||
_tempPointsArr[1] = p;
|
||
}
|
||
_tempCounter++;
|
||
|
||
});
|
||
}
|
||
return _tempPointsArr;
|
||
},
|
||
|
||
_panOrMoveMainScroll = function(axis, delta) {
|
||
|
||
var panFriction,
|
||
overDiff = 0,
|
||
newOffset = _panOffset[axis] + delta[axis],
|
||
startOverDiff,
|
||
dir = delta[axis] > 0,
|
||
newMainScrollPosition = _mainScrollPos.x + delta.x,
|
||
mainScrollDiff = _mainScrollPos.x - _startMainScrollPos.x,
|
||
newPanPos,
|
||
newMainScrollPos;
|
||
|
||
// calculate fdistance over the bounds and friction
|
||
if(newOffset > _currPanBounds.min[axis] || newOffset < _currPanBounds.max[axis]) {
|
||
panFriction = _options.panEndFriction;
|
||
// Linear increasing of friction, so at 1/4 of viewport it's at max value.
|
||
// Looks not as nice as was expected. Left for history.
|
||
// panFriction = (1 - (_panOffset[axis] + delta[axis] + panBounds.min[axis]) / (_viewportSize[axis] / 4) );
|
||
} else {
|
||
panFriction = 1;
|
||
}
|
||
|
||
newOffset = _panOffset[axis] + delta[axis] * panFriction;
|
||
|
||
// move main scroll or start panning
|
||
if(_options.allowPanToNext || _currZoomLevel === self.currItem.initialZoomLevel) {
|
||
|
||
|
||
if(!_currZoomElementStyle) {
|
||
|
||
newMainScrollPos = newMainScrollPosition;
|
||
|
||
} else if(_direction === 'h' && axis === 'x' && !_zoomStarted ) {
|
||
|
||
if(dir) {
|
||
if(newOffset > _currPanBounds.min[axis]) {
|
||
panFriction = _options.panEndFriction;
|
||
overDiff = _currPanBounds.min[axis] - newOffset;
|
||
startOverDiff = _currPanBounds.min[axis] - _startPanOffset[axis];
|
||
}
|
||
|
||
// drag right
|
||
if( (startOverDiff <= 0 || mainScrollDiff < 0) && _getNumItems() > 1 ) {
|
||
newMainScrollPos = newMainScrollPosition;
|
||
if(mainScrollDiff < 0 && newMainScrollPosition > _startMainScrollPos.x) {
|
||
newMainScrollPos = _startMainScrollPos.x;
|
||
}
|
||
} else {
|
||
if(_currPanBounds.min.x !== _currPanBounds.max.x) {
|
||
newPanPos = newOffset;
|
||
}
|
||
|
||
}
|
||
|
||
} else {
|
||
|
||
if(newOffset < _currPanBounds.max[axis] ) {
|
||
panFriction =_options.panEndFriction;
|
||
overDiff = newOffset - _currPanBounds.max[axis];
|
||
startOverDiff = _startPanOffset[axis] - _currPanBounds.max[axis];
|
||
}
|
||
|
||
if( (startOverDiff <= 0 || mainScrollDiff > 0) && _getNumItems() > 1 ) {
|
||
newMainScrollPos = newMainScrollPosition;
|
||
|
||
if(mainScrollDiff > 0 && newMainScrollPosition < _startMainScrollPos.x) {
|
||
newMainScrollPos = _startMainScrollPos.x;
|
||
}
|
||
|
||
} else {
|
||
if(_currPanBounds.min.x !== _currPanBounds.max.x) {
|
||
newPanPos = newOffset;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//
|
||
}
|
||
|
||
if(axis === 'x') {
|
||
|
||
if(newMainScrollPos !== undefined) {
|
||
_moveMainScroll(newMainScrollPos, true);
|
||
if(newMainScrollPos === _startMainScrollPos.x) {
|
||
_mainScrollShifted = false;
|
||
} else {
|
||
_mainScrollShifted = true;
|
||
}
|
||
}
|
||
|
||
if(_currPanBounds.min.x !== _currPanBounds.max.x) {
|
||
if(newPanPos !== undefined) {
|
||
_panOffset.x = newPanPos;
|
||
} else if(!_mainScrollShifted) {
|
||
_panOffset.x += delta.x * panFriction;
|
||
}
|
||
}
|
||
|
||
return newMainScrollPos !== undefined;
|
||
}
|
||
|
||
}
|
||
|
||
if(!_mainScrollAnimating) {
|
||
|
||
if(!_mainScrollShifted) {
|
||
if(_currZoomLevel > self.currItem.fitRatio) {
|
||
_panOffset[axis] += delta[axis] * panFriction;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
},
|
||
|
||
// Pointerdown/touchstart/mousedown handler
|
||
_onDragStart = function(e) {
|
||
|
||
// Allow dragging only via left mouse button.
|
||
// As this handler is not added in IE8 - we ignore e.which
|
||
//
|
||
// http://www.quirksmode.org/js/events_properties.html
|
||
// https://developer.mozilla.org/en-US/docs/Web/API/event.button
|
||
if(e.type === 'mousedown' && e.button > 0 ) {
|
||
return;
|
||
}
|
||
|
||
if(_initialZoomRunning) {
|
||
e.preventDefault();
|
||
return;
|
||
}
|
||
|
||
if(_oldAndroidTouchEndTimeout && e.type === 'mousedown') {
|
||
return;
|
||
}
|
||
|
||
if(_preventDefaultEventBehaviour(e, true)) {
|
||
// if(device_type!='d'){
|
||
// var obj = e.srcElement ? e.srcElement : e.target;
|
||
// if($(obj).parents('.pswp__button--rotate-left').length) {
|
||
// _imgRotate('','','.pswp__item','.pswp__img:visible',1);
|
||
// }
|
||
// if($(obj).parents('.pswp__button--rotate-right').length) {
|
||
// _imgRotate('','','.pswp__item','.pswp__img:visible',2);
|
||
// }
|
||
// }
|
||
e.preventDefault();
|
||
}
|
||
|
||
|
||
|
||
_shout('pointerDown');
|
||
|
||
if(_pointerEventEnabled) {
|
||
var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
|
||
if(pointerIndex < 0) {
|
||
pointerIndex = _currPointers.length;
|
||
}
|
||
_currPointers[pointerIndex] = {x:e.pageX, y:e.pageY, id: e.pointerId};
|
||
}
|
||
|
||
|
||
|
||
var startPointsList = _getTouchPoints(e),
|
||
numPoints = startPointsList.length;
|
||
|
||
_currentPoints = null;
|
||
|
||
_stopAllAnimations();
|
||
|
||
// init drag
|
||
if(!_isDragging || numPoints === 1) {
|
||
|
||
|
||
|
||
_isDragging = _isFirstMove = true;
|
||
framework.bind(window, _upMoveEvents, self);
|
||
|
||
_isZoomingIn =
|
||
_wasOverInitialZoom =
|
||
_opacityChanged =
|
||
_verticalDragInitiated =
|
||
_mainScrollShifted =
|
||
_moved =
|
||
_isMultitouch =
|
||
_zoomStarted = false;
|
||
|
||
_direction = null;
|
||
|
||
_shout('firstTouchStart', startPointsList);
|
||
|
||
_equalizePoints(_startPanOffset, _panOffset);
|
||
|
||
_currPanDist.x = _currPanDist.y = 0;
|
||
_equalizePoints(_currPoint, startPointsList[0]);
|
||
_equalizePoints(_startPoint, _currPoint);
|
||
|
||
//_equalizePoints(_startMainScrollPos, _mainScrollPos);
|
||
_startMainScrollPos.x = _slideSize.x * _currPositionIndex;
|
||
|
||
_posPoints = [{
|
||
x: _currPoint.x,
|
||
y: _currPoint.y
|
||
}];
|
||
|
||
_gestureCheckSpeedTime = _gestureStartTime = _getCurrentTime();
|
||
|
||
//_mainScrollAnimationEnd(true);
|
||
_calculatePanBounds( _currZoomLevel, true );
|
||
|
||
// Start rendering
|
||
_stopDragUpdateLoop();
|
||
_dragUpdateLoop();
|
||
|
||
}
|
||
|
||
// init zoom
|
||
if(!_isZooming && numPoints > 1 && !_mainScrollAnimating && !_mainScrollShifted) {
|
||
_startZoomLevel = _currZoomLevel;
|
||
_zoomStarted = false; // true if zoom changed at least once
|
||
|
||
_isZooming = _isMultitouch = true;
|
||
_currPanDist.y = _currPanDist.x = 0;
|
||
|
||
_equalizePoints(_startPanOffset, _panOffset);
|
||
|
||
_equalizePoints(p, startPointsList[0]);
|
||
_equalizePoints(p2, startPointsList[1]);
|
||
|
||
_findCenterOfPoints(p, p2, _currCenterPoint);
|
||
|
||
_midZoomPoint.x = Math.abs(_currCenterPoint.x) - _panOffset.x;
|
||
_midZoomPoint.y = Math.abs(_currCenterPoint.y) - _panOffset.y;
|
||
_currPointsDistance = _startPointsDistance = _calculatePointsDistance(p, p2);
|
||
}
|
||
|
||
|
||
},
|
||
|
||
// Pointermove/touchmove/mousemove handler
|
||
_onDragMove = function(e) {
|
||
|
||
e.preventDefault();
|
||
|
||
if(_pointerEventEnabled) {
|
||
var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
|
||
if(pointerIndex > -1) {
|
||
var p = _currPointers[pointerIndex];
|
||
p.x = e.pageX;
|
||
p.y = e.pageY;
|
||
}
|
||
}
|
||
|
||
if(_isDragging) {
|
||
var touchesList = _getTouchPoints(e);
|
||
if(!_direction && !_moved && !_isZooming) {
|
||
|
||
if(_mainScrollPos.x !== _slideSize.x * _currPositionIndex) {
|
||
// if main scroll position is shifted – direction is always horizontal
|
||
_direction = 'h';
|
||
} else {
|
||
var diff = Math.abs(touchesList[0].x - _currPoint.x) - Math.abs(touchesList[0].y - _currPoint.y);
|
||
// check the direction of movement
|
||
if(Math.abs(diff) >= DIRECTION_CHECK_OFFSET) {
|
||
_direction = diff > 0 ? 'h' : 'v';
|
||
_currentPoints = touchesList;
|
||
}
|
||
}
|
||
|
||
} else {
|
||
_currentPoints = touchesList;
|
||
}
|
||
}
|
||
},
|
||
//
|
||
_renderMovement = function() {
|
||
|
||
if(!_currentPoints) {
|
||
return;
|
||
}
|
||
|
||
var numPoints = _currentPoints.length;
|
||
|
||
if(numPoints === 0) {
|
||
return;
|
||
}
|
||
|
||
_equalizePoints(p, _currentPoints[0]);
|
||
|
||
delta.x = p.x - _currPoint.x;
|
||
delta.y = p.y - _currPoint.y;
|
||
|
||
if(_isZooming && numPoints > 1) {
|
||
// Handle behaviour for more than 1 point
|
||
|
||
_currPoint.x = p.x;
|
||
_currPoint.y = p.y;
|
||
|
||
// check if one of two points changed
|
||
if( !delta.x && !delta.y && _isEqualPoints(_currentPoints[1], p2) ) {
|
||
return;
|
||
}
|
||
|
||
_equalizePoints(p2, _currentPoints[1]);
|
||
|
||
|
||
if(!_zoomStarted) {
|
||
_zoomStarted = true;
|
||
_shout('zoomGestureStarted');
|
||
}
|
||
|
||
// Distance between two points
|
||
var pointsDistance = _calculatePointsDistance(p,p2);
|
||
|
||
var zoomLevel = _calculateZoomLevel(pointsDistance);
|
||
|
||
// slightly over the of initial zoom level
|
||
if(zoomLevel > self.currItem.initialZoomLevel + self.currItem.initialZoomLevel / 15) {
|
||
_wasOverInitialZoom = true;
|
||
}
|
||
|
||
// Apply the friction if zoom level is out of the bounds
|
||
var zoomFriction = 1,
|
||
minZoomLevel = _getMinZoomLevel(),
|
||
maxZoomLevel = _getMaxZoomLevel();
|
||
|
||
if ( zoomLevel < minZoomLevel ) {
|
||
|
||
if(_options.pinchToClose && !_wasOverInitialZoom && _startZoomLevel <= self.currItem.initialZoomLevel) {
|
||
// fade out background if zooming out
|
||
var minusDiff = minZoomLevel - zoomLevel;
|
||
var percent = 1 - minusDiff / (minZoomLevel / 1.2);
|
||
|
||
_applyBgOpacity(percent);
|
||
_shout('onPinchClose', percent);
|
||
_opacityChanged = true;
|
||
} else {
|
||
zoomFriction = (minZoomLevel - zoomLevel) / minZoomLevel;
|
||
if(zoomFriction > 1) {
|
||
zoomFriction = 1;
|
||
}
|
||
zoomLevel = minZoomLevel - zoomFriction * (minZoomLevel / 3);
|
||
}
|
||
|
||
} else if ( zoomLevel > maxZoomLevel ) {
|
||
// 1.5 - extra zoom level above the max. E.g. if max is x6, real max 6 + 1.5 = 7.5
|
||
zoomFriction = (zoomLevel - maxZoomLevel) / ( minZoomLevel * 6 );
|
||
if(zoomFriction > 1) {
|
||
zoomFriction = 1;
|
||
}
|
||
zoomLevel = maxZoomLevel + zoomFriction * minZoomLevel;
|
||
}
|
||
|
||
if(zoomFriction < 0) {
|
||
zoomFriction = 0;
|
||
}
|
||
|
||
// distance between touch points after friction is applied
|
||
_currPointsDistance = pointsDistance;
|
||
|
||
// _centerPoint - The point in the middle of two pointers
|
||
_findCenterOfPoints(p, p2, _centerPoint);
|
||
|
||
// paning with two pointers pressed
|
||
_currPanDist.x += _centerPoint.x - _currCenterPoint.x;
|
||
_currPanDist.y += _centerPoint.y - _currCenterPoint.y;
|
||
_equalizePoints(_currCenterPoint, _centerPoint);
|
||
|
||
_panOffset.x = _calculatePanOffset('x', zoomLevel);
|
||
_panOffset.y = _calculatePanOffset('y', zoomLevel);
|
||
|
||
_isZoomingIn = zoomLevel > _currZoomLevel;
|
||
_currZoomLevel = zoomLevel;
|
||
_applyCurrentZoomPan();
|
||
|
||
} else {
|
||
|
||
// handle behaviour for one point (dragging or panning)
|
||
|
||
if(!_direction) {
|
||
return;
|
||
}
|
||
|
||
if(_isFirstMove) {
|
||
_isFirstMove = false;
|
||
|
||
// subtract drag distance that was used during the detection direction
|
||
|
||
if( Math.abs(delta.x) >= DIRECTION_CHECK_OFFSET) {
|
||
delta.x -= _currentPoints[0].x - _startPoint.x;
|
||
}
|
||
|
||
if( Math.abs(delta.y) >= DIRECTION_CHECK_OFFSET) {
|
||
delta.y -= _currentPoints[0].y - _startPoint.y;
|
||
}
|
||
}
|
||
|
||
_currPoint.x = p.x;
|
||
_currPoint.y = p.y;
|
||
|
||
// do nothing if pointers position hasn't changed
|
||
if(delta.x === 0 && delta.y === 0) {
|
||
return;
|
||
}
|
||
|
||
if(_direction === 'v' && _options.closeOnVerticalDrag) {
|
||
if(!_canPan()) {
|
||
_currPanDist.y += delta.y;
|
||
_panOffset.y += delta.y;
|
||
|
||
var opacityRatio = _calculateVerticalDragOpacityRatio();
|
||
|
||
_verticalDragInitiated = true;
|
||
_shout('onVerticalDrag', opacityRatio);
|
||
|
||
_applyBgOpacity(opacityRatio);
|
||
_applyCurrentZoomPan();
|
||
return ;
|
||
}
|
||
}
|
||
|
||
_pushPosPoint(_getCurrentTime(), p.x, p.y);
|
||
|
||
_moved = true;
|
||
_currPanBounds = self.currItem.bounds;
|
||
|
||
var mainScrollChanged = _panOrMoveMainScroll('x', delta);
|
||
if(!mainScrollChanged) {
|
||
_panOrMoveMainScroll('y', delta);
|
||
|
||
_roundPoint(_panOffset);
|
||
_applyCurrentZoomPan();
|
||
}
|
||
|
||
}
|
||
|
||
},
|
||
|
||
// Pointerup/pointercancel/touchend/touchcancel/mouseup event handler
|
||
_onDragRelease = function(e) {
|
||
|
||
if(_features.isOldAndroid ) {
|
||
|
||
if(_oldAndroidTouchEndTimeout && e.type === 'mouseup') {
|
||
return;
|
||
}
|
||
|
||
// on Android (v4.1, 4.2, 4.3 & possibly older)
|
||
// ghost mousedown/up event isn't preventable via e.preventDefault,
|
||
// which causes fake mousedown event
|
||
// so we block mousedown/up for 600ms
|
||
if( e.type.indexOf('touch') > -1 ) {
|
||
clearTimeout(_oldAndroidTouchEndTimeout);
|
||
_oldAndroidTouchEndTimeout = setTimeout(function() {
|
||
_oldAndroidTouchEndTimeout = 0;
|
||
}, 600);
|
||
}
|
||
|
||
}
|
||
|
||
_shout('pointerUp');
|
||
|
||
if(_preventDefaultEventBehaviour(e, false)) {
|
||
e.preventDefault();
|
||
}
|
||
|
||
var releasePoint;
|
||
|
||
if(_pointerEventEnabled) {
|
||
var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
|
||
|
||
if(pointerIndex > -1) {
|
||
releasePoint = _currPointers.splice(pointerIndex, 1)[0];
|
||
|
||
if(navigator.pointerEnabled) {
|
||
releasePoint.type = e.pointerType || 'mouse';
|
||
} else {
|
||
var MSPOINTER_TYPES = {
|
||
4: 'mouse', // event.MSPOINTER_TYPE_MOUSE
|
||
2: 'touch', // event.MSPOINTER_TYPE_TOUCH
|
||
3: 'pen' // event.MSPOINTER_TYPE_PEN
|
||
};
|
||
releasePoint.type = MSPOINTER_TYPES[e.pointerType];
|
||
|
||
if(!releasePoint.type) {
|
||
releasePoint.type = e.pointerType || 'mouse';
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
var touchList = _getTouchPoints(e),
|
||
gestureType,
|
||
numPoints = touchList.length;
|
||
|
||
if(e.type === 'mouseup') {
|
||
numPoints = 0;
|
||
}
|
||
|
||
// Do nothing if there were 3 touch points or more
|
||
if(numPoints === 2) {
|
||
_currentPoints = null;
|
||
return true;
|
||
}
|
||
|
||
// if second pointer released
|
||
if(numPoints === 1) {
|
||
_equalizePoints(_startPoint, touchList[0]);
|
||
}
|
||
|
||
|
||
// pointer hasn't moved, send "tap release" point
|
||
if(numPoints === 0 && !_direction && !_mainScrollAnimating) {
|
||
if(!releasePoint) {
|
||
if(e.type === 'mouseup') {
|
||
releasePoint = {x: e.pageX, y: e.pageY, type:'mouse'};
|
||
} else if(e.changedTouches && e.changedTouches[0]) {
|
||
releasePoint = {x: e.changedTouches[0].pageX, y: e.changedTouches[0].pageY, type:'touch'};
|
||
}
|
||
}
|
||
|
||
_shout('touchRelease', e, releasePoint);
|
||
}
|
||
|
||
// Difference in time between releasing of two last touch points (zoom gesture)
|
||
var releaseTimeDiff = -1;
|
||
|
||
// Gesture completed, no pointers left
|
||
if(numPoints === 0) {
|
||
_isDragging = false;
|
||
framework.unbind(window, _upMoveEvents, self);
|
||
|
||
_stopDragUpdateLoop();
|
||
|
||
if(_isZooming) {
|
||
// Two points released at the same time
|
||
releaseTimeDiff = 0;
|
||
} else if(_lastReleaseTime !== -1) {
|
||
releaseTimeDiff = _getCurrentTime() - _lastReleaseTime;
|
||
}
|
||
}
|
||
_lastReleaseTime = numPoints === 1 ? _getCurrentTime() : -1;
|
||
|
||
if(releaseTimeDiff !== -1 && releaseTimeDiff < 150) {
|
||
gestureType = 'zoom';
|
||
} else {
|
||
gestureType = 'swipe';
|
||
}
|
||
|
||
if(_isZooming && numPoints < 2) {
|
||
_isZooming = false;
|
||
|
||
// Only second point released
|
||
if(numPoints === 1) {
|
||
gestureType = 'zoomPointerUp';
|
||
}
|
||
_shout('zoomGestureEnded');
|
||
}
|
||
|
||
_currentPoints = null;
|
||
if(!_moved && !_zoomStarted && !_mainScrollAnimating && !_verticalDragInitiated) {
|
||
// nothing to animate
|
||
return;
|
||
}
|
||
|
||
_stopAllAnimations();
|
||
|
||
|
||
if(!_releaseAnimData) {
|
||
_releaseAnimData = _initDragReleaseAnimationData();
|
||
}
|
||
|
||
_releaseAnimData.calculateSwipeSpeed('x');
|
||
|
||
|
||
if(_verticalDragInitiated) {
|
||
|
||
var opacityRatio = _calculateVerticalDragOpacityRatio();
|
||
|
||
if(opacityRatio < _options.verticalDragRange) {
|
||
self.close();
|
||
} else {
|
||
var initalPanY = _panOffset.y,
|
||
initialBgOpacity = _bgOpacity;
|
||
|
||
_animateProp('verticalDrag', 0, 1, 300, framework.easing.cubic.out, function(now) {
|
||
|
||
_panOffset.y = (self.currItem.initialPosition.y - initalPanY) * now + initalPanY;
|
||
|
||
_applyBgOpacity( (1 - initialBgOpacity) * now + initialBgOpacity );
|
||
_applyCurrentZoomPan();
|
||
});
|
||
|
||
_shout('onVerticalDrag', 1);
|
||
}
|
||
|
||
return;
|
||
}
|
||
|
||
|
||
// main scroll
|
||
if( (_mainScrollShifted || _mainScrollAnimating) && numPoints === 0) {
|
||
var itemChanged = _finishSwipeMainScrollGesture(gestureType, _releaseAnimData);
|
||
if(itemChanged) {
|
||
return;
|
||
}
|
||
gestureType = 'zoomPointerUp';
|
||
}
|
||
|
||
// prevent zoom/pan animation when main scroll animation runs
|
||
if(_mainScrollAnimating) {
|
||
return;
|
||
}
|
||
|
||
// Complete simple zoom gesture (reset zoom level if it's out of the bounds)
|
||
if(gestureType !== 'swipe') {
|
||
_completeZoomGesture();
|
||
return;
|
||
}
|
||
|
||
// Complete pan gesture if main scroll is not shifted, and it's possible to pan current image
|
||
if(!_mainScrollShifted && _currZoomLevel > self.currItem.fitRatio) {
|
||
_completePanGesture(_releaseAnimData);
|
||
}
|
||
},
|
||
|
||
|
||
// Returns object with data about gesture
|
||
// It's created only once and then reused
|
||
_initDragReleaseAnimationData = function() {
|
||
// temp local vars
|
||
var lastFlickDuration,
|
||
tempReleasePos;
|
||
|
||
// s = this
|
||
var s = {
|
||
lastFlickOffset: {},
|
||
lastFlickDist: {},
|
||
lastFlickSpeed: {},
|
||
slowDownRatio: {},
|
||
slowDownRatioReverse: {},
|
||
speedDecelerationRatio: {},
|
||
speedDecelerationRatioAbs: {},
|
||
distanceOffset: {},
|
||
backAnimDestination: {},
|
||
backAnimStarted: {},
|
||
calculateSwipeSpeed: function(axis) {
|
||
|
||
|
||
if( _posPoints.length > 1) {
|
||
lastFlickDuration = _getCurrentTime() - _gestureCheckSpeedTime + 50;
|
||
tempReleasePos = _posPoints[_posPoints.length-2][axis];
|
||
} else {
|
||
lastFlickDuration = _getCurrentTime() - _gestureStartTime; // total gesture duration
|
||
tempReleasePos = _startPoint[axis];
|
||
}
|
||
s.lastFlickOffset[axis] = _currPoint[axis] - tempReleasePos;
|
||
s.lastFlickDist[axis] = Math.abs(s.lastFlickOffset[axis]);
|
||
if(s.lastFlickDist[axis] > 20) {
|
||
s.lastFlickSpeed[axis] = s.lastFlickOffset[axis] / lastFlickDuration;
|
||
} else {
|
||
s.lastFlickSpeed[axis] = 0;
|
||
}
|
||
if( Math.abs(s.lastFlickSpeed[axis]) < 0.1 ) {
|
||
s.lastFlickSpeed[axis] = 0;
|
||
}
|
||
|
||
s.slowDownRatio[axis] = 0.95;
|
||
s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis];
|
||
s.speedDecelerationRatio[axis] = 1;
|
||
},
|
||
|
||
calculateOverBoundsAnimOffset: function(axis, speed) {
|
||
if(!s.backAnimStarted[axis]) {
|
||
|
||
if(_panOffset[axis] > _currPanBounds.min[axis]) {
|
||
s.backAnimDestination[axis] = _currPanBounds.min[axis];
|
||
|
||
} else if(_panOffset[axis] < _currPanBounds.max[axis]) {
|
||
s.backAnimDestination[axis] = _currPanBounds.max[axis];
|
||
}
|
||
|
||
if(s.backAnimDestination[axis] !== undefined) {
|
||
s.slowDownRatio[axis] = 0.7;
|
||
s.slowDownRatioReverse[axis] = 1 - s.slowDownRatio[axis];
|
||
if(s.speedDecelerationRatioAbs[axis] < 0.05) {
|
||
|
||
s.lastFlickSpeed[axis] = 0;
|
||
s.backAnimStarted[axis] = true;
|
||
|
||
_animateProp('bounceZoomPan'+axis,_panOffset[axis],
|
||
s.backAnimDestination[axis],
|
||
speed || 300,
|
||
framework.easing.sine.out,
|
||
function(pos) {
|
||
_panOffset[axis] = pos;
|
||
_applyCurrentZoomPan();
|
||
}
|
||
);
|
||
|
||
}
|
||
}
|
||
}
|
||
},
|
||
|
||
// Reduces the speed by slowDownRatio (per 10ms)
|
||
calculateAnimOffset: function(axis) {
|
||
if(!s.backAnimStarted[axis]) {
|
||
s.speedDecelerationRatio[axis] = s.speedDecelerationRatio[axis] * (s.slowDownRatio[axis] +
|
||
s.slowDownRatioReverse[axis] -
|
||
s.slowDownRatioReverse[axis] * s.timeDiff / 10);
|
||
|
||
s.speedDecelerationRatioAbs[axis] = Math.abs(s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis]);
|
||
s.distanceOffset[axis] = s.lastFlickSpeed[axis] * s.speedDecelerationRatio[axis] * s.timeDiff;
|
||
_panOffset[axis] += s.distanceOffset[axis];
|
||
|
||
}
|
||
},
|
||
|
||
panAnimLoop: function() {
|
||
if ( _animations.zoomPan ) {
|
||
_animations.zoomPan.raf = _requestAF(s.panAnimLoop);
|
||
|
||
s.now = _getCurrentTime();
|
||
s.timeDiff = s.now - s.lastNow;
|
||
s.lastNow = s.now;
|
||
|
||
s.calculateAnimOffset('x');
|
||
s.calculateAnimOffset('y');
|
||
|
||
_applyCurrentZoomPan();
|
||
|
||
s.calculateOverBoundsAnimOffset('x');
|
||
s.calculateOverBoundsAnimOffset('y');
|
||
|
||
|
||
if (s.speedDecelerationRatioAbs.x < 0.05 && s.speedDecelerationRatioAbs.y < 0.05) {
|
||
|
||
// round pan position
|
||
_panOffset.x = Math.round(_panOffset.x);
|
||
_panOffset.y = Math.round(_panOffset.y);
|
||
_applyCurrentZoomPan();
|
||
|
||
_stopAnimation('zoomPan');
|
||
return;
|
||
}
|
||
}
|
||
|
||
}
|
||
};
|
||
return s;
|
||
},
|
||
|
||
_completePanGesture = function(animData) {
|
||
// calculate swipe speed for Y axis (paanning)
|
||
animData.calculateSwipeSpeed('y');
|
||
|
||
_currPanBounds = self.currItem.bounds;
|
||
|
||
animData.backAnimDestination = {};
|
||
animData.backAnimStarted = {};
|
||
|
||
// Avoid acceleration animation if speed is too low
|
||
if(Math.abs(animData.lastFlickSpeed.x) <= 0.05 && Math.abs(animData.lastFlickSpeed.y) <= 0.05 ) {
|
||
animData.speedDecelerationRatioAbs.x = animData.speedDecelerationRatioAbs.y = 0;
|
||
|
||
// Run pan drag release animation. E.g. if you drag image and release finger without momentum.
|
||
animData.calculateOverBoundsAnimOffset('x');
|
||
animData.calculateOverBoundsAnimOffset('y');
|
||
return true;
|
||
}
|
||
|
||
// Animation loop that controls the acceleration after pan gesture ends
|
||
_registerStartAnimation('zoomPan');
|
||
animData.lastNow = _getCurrentTime();
|
||
animData.panAnimLoop();
|
||
},
|
||
|
||
|
||
_finishSwipeMainScrollGesture = function(gestureType, _releaseAnimData) {
|
||
var itemChanged;
|
||
if(!_mainScrollAnimating) {
|
||
_currZoomedItemIndex = _currentItemIndex;
|
||
}
|
||
|
||
|
||
|
||
var itemsDiff;
|
||
|
||
if(gestureType === 'swipe') {
|
||
var totalShiftDist = _currPoint.x - _startPoint.x,
|
||
isFastLastFlick = _releaseAnimData.lastFlickDist.x < 10;
|
||
|
||
// if container is shifted for more than MIN_SWIPE_DISTANCE,
|
||
// and last flick gesture was in right direction
|
||
if(totalShiftDist > MIN_SWIPE_DISTANCE &&
|
||
(isFastLastFlick || _releaseAnimData.lastFlickOffset.x > 20) ) {
|
||
// go to prev item
|
||
itemsDiff = -1;
|
||
} else if(totalShiftDist < -MIN_SWIPE_DISTANCE &&
|
||
(isFastLastFlick || _releaseAnimData.lastFlickOffset.x < -20) ) {
|
||
// go to next item
|
||
itemsDiff = 1;
|
||
}
|
||
}
|
||
|
||
var nextCircle;
|
||
|
||
if(itemsDiff) {
|
||
|
||
_currentItemIndex += itemsDiff;
|
||
|
||
if(_currentItemIndex < 0) {
|
||
_currentItemIndex = _options.loop ? _getNumItems()-1 : 0;
|
||
nextCircle = true;
|
||
} else if(_currentItemIndex >= _getNumItems()) {
|
||
_currentItemIndex = _options.loop ? 0 : _getNumItems()-1;
|
||
nextCircle = true;
|
||
}
|
||
|
||
if(!nextCircle || _options.loop) {
|
||
_indexDiff += itemsDiff;
|
||
_currPositionIndex -= itemsDiff;
|
||
itemChanged = true;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
var animateToX = _slideSize.x * _currPositionIndex;
|
||
var animateToDist = Math.abs( animateToX - _mainScrollPos.x );
|
||
var finishAnimDuration;
|
||
|
||
|
||
if(!itemChanged && animateToX > _mainScrollPos.x !== _releaseAnimData.lastFlickSpeed.x > 0) {
|
||
// "return to current" duration, e.g. when dragging from slide 0 to -1
|
||
finishAnimDuration = 333;
|
||
} else {
|
||
finishAnimDuration = Math.abs(_releaseAnimData.lastFlickSpeed.x) > 0 ?
|
||
animateToDist / Math.abs(_releaseAnimData.lastFlickSpeed.x) :
|
||
333;
|
||
|
||
finishAnimDuration = Math.min(finishAnimDuration, 400);
|
||
finishAnimDuration = Math.max(finishAnimDuration, 250);
|
||
}
|
||
|
||
if(_currZoomedItemIndex === _currentItemIndex) {
|
||
itemChanged = false;
|
||
}
|
||
|
||
_mainScrollAnimating = true;
|
||
|
||
_shout('mainScrollAnimStart');
|
||
|
||
_animateProp('mainScroll', _mainScrollPos.x, animateToX, finishAnimDuration, framework.easing.cubic.out,
|
||
_moveMainScroll,
|
||
function() {
|
||
_stopAllAnimations();
|
||
_mainScrollAnimating = false;
|
||
_currZoomedItemIndex = -1;
|
||
|
||
if(itemChanged || _currZoomedItemIndex !== _currentItemIndex) {
|
||
self.updateCurrItem();
|
||
}
|
||
|
||
_shout('mainScrollAnimComplete');
|
||
}
|
||
);
|
||
|
||
if(itemChanged) {
|
||
self.updateCurrItem(true);
|
||
}
|
||
|
||
return itemChanged;
|
||
},
|
||
|
||
_calculateZoomLevel = function(touchesDistance) {
|
||
return 1 / _startPointsDistance * touchesDistance * _startZoomLevel;
|
||
},
|
||
|
||
// Resets zoom if it's out of bounds
|
||
_completeZoomGesture = function() {
|
||
var destZoomLevel = _currZoomLevel,
|
||
minZoomLevel = _getMinZoomLevel(),
|
||
maxZoomLevel = _getMaxZoomLevel();
|
||
|
||
if ( _currZoomLevel < minZoomLevel ) {
|
||
destZoomLevel = minZoomLevel;
|
||
} else if ( _currZoomLevel > maxZoomLevel ) {
|
||
destZoomLevel = maxZoomLevel;
|
||
}
|
||
|
||
var destOpacity = 1,
|
||
onUpdate,
|
||
initialOpacity = _bgOpacity;
|
||
|
||
if(_opacityChanged && !_isZoomingIn && !_wasOverInitialZoom && _currZoomLevel < minZoomLevel) {
|
||
//_closedByScroll = true;
|
||
self.close();
|
||
return true;
|
||
}
|
||
|
||
if(_opacityChanged) {
|
||
onUpdate = function(now) {
|
||
_applyBgOpacity( (destOpacity - initialOpacity) * now + initialOpacity );
|
||
};
|
||
}
|
||
|
||
self.zoomTo(destZoomLevel, 0, 200, framework.easing.cubic.out, onUpdate);
|
||
return true;
|
||
};
|
||
|
||
|
||
_registerModule('Gestures', {
|
||
publicMethods: {
|
||
|
||
initGestures: function() {
|
||
|
||
// helper function that builds touch/pointer/mouse events
|
||
var addEventNames = function(pref, down, move, up, cancel) {
|
||
_dragStartEvent = pref + down;
|
||
_dragMoveEvent = pref + move;
|
||
_dragEndEvent = pref + up;
|
||
if(cancel) {
|
||
_dragCancelEvent = pref + cancel;
|
||
} else {
|
||
_dragCancelEvent = '';
|
||
}
|
||
};
|
||
|
||
_pointerEventEnabled = _features.pointerEvent;
|
||
if(_pointerEventEnabled && _features.touch) {
|
||
// we don't need touch events, if browser supports pointer events
|
||
_features.touch = false;
|
||
}
|
||
|
||
if(_pointerEventEnabled) {
|
||
if(navigator.pointerEnabled) {
|
||
addEventNames('pointer', 'down', 'move', 'up', 'cancel');
|
||
} else {
|
||
// IE10 pointer events are case-sensitive
|
||
addEventNames('MSPointer', 'Down', 'Move', 'Up', 'Cancel');
|
||
}
|
||
} else if(_features.touch) {
|
||
addEventNames('touch', 'start', 'move', 'end', 'cancel');
|
||
_likelyTouchDevice = true;
|
||
} else {
|
||
addEventNames('mouse', 'down', 'move', 'up');
|
||
}
|
||
|
||
_upMoveEvents = _dragMoveEvent + ' ' + _dragEndEvent + ' ' + _dragCancelEvent;
|
||
_downEvents = _dragStartEvent;
|
||
|
||
if(_pointerEventEnabled && !_likelyTouchDevice) {
|
||
_likelyTouchDevice = (navigator.maxTouchPoints > 1) || (navigator.msMaxTouchPoints > 1);
|
||
}
|
||
// make variable public
|
||
self.likelyTouchDevice = _likelyTouchDevice;
|
||
|
||
_globalEventHandlers[_dragStartEvent] = _onDragStart;
|
||
_globalEventHandlers[_dragMoveEvent] = _onDragMove;
|
||
_globalEventHandlers[_dragEndEvent] = _onDragRelease; // the Kraken
|
||
|
||
if(_dragCancelEvent) {
|
||
_globalEventHandlers[_dragCancelEvent] = _globalEventHandlers[_dragEndEvent];
|
||
}
|
||
|
||
// Bind mouse events on device with detected hardware touch support, in case it supports multiple types of input.
|
||
if(_features.touch) {
|
||
_downEvents += ' mousedown';
|
||
_upMoveEvents += ' mousemove mouseup';
|
||
_globalEventHandlers.mousedown = _globalEventHandlers[_dragStartEvent];
|
||
_globalEventHandlers.mousemove = _globalEventHandlers[_dragMoveEvent];
|
||
_globalEventHandlers.mouseup = _globalEventHandlers[_dragEndEvent];
|
||
}
|
||
|
||
if(!_likelyTouchDevice) {
|
||
// don't allow pan to next slide from zoomed state on Desktop
|
||
_options.allowPanToNext = false;
|
||
}
|
||
}
|
||
|
||
}
|
||
});
|
||
|
||
|
||
/*>>gestures*/
|
||
|
||
/*>>show-hide-transition*/
|
||
/**
|
||
* show-hide-transition.js:
|
||
*
|
||
* Manages initial opening or closing transition.
|
||
*
|
||
* If you're not planning to use transition for gallery at all,
|
||
* you may set options hideAnimationDuration and showAnimationDuration to 0,
|
||
* and just delete startAnimation function.
|
||
*
|
||
*/
|
||
|
||
|
||
var _showOrHideTimeout,
|
||
_showOrHide = function(item, img, out, completeFn) {
|
||
|
||
if(_showOrHideTimeout) {
|
||
clearTimeout(_showOrHideTimeout);
|
||
}
|
||
|
||
_initialZoomRunning = true;
|
||
_initialContentSet = true;
|
||
|
||
// dimensions of small thumbnail {x:,y:,w:}.
|
||
// Height is optional, as calculated based on large image.
|
||
var thumbBounds;
|
||
if(item.initialLayout) {
|
||
thumbBounds = item.initialLayout;
|
||
item.initialLayout = null;
|
||
} else {
|
||
thumbBounds = _options.getThumbBoundsFn && _options.getThumbBoundsFn(_currentItemIndex);
|
||
}
|
||
|
||
var duration = out ? _options.hideAnimationDuration : _options.showAnimationDuration;
|
||
|
||
var onComplete = function() {
|
||
_stopAnimation('initialZoom');
|
||
if(!out) {
|
||
_applyBgOpacity(1);
|
||
if(img) {
|
||
img.style.display = 'block';
|
||
}
|
||
framework.addClass(template, 'pswp--animated-in');
|
||
_shout('initialZoom' + (out ? 'OutEnd' : 'InEnd'));
|
||
} else {
|
||
self.template.removeAttribute('style');
|
||
self.bg.removeAttribute('style');
|
||
}
|
||
|
||
if(completeFn) {
|
||
completeFn();
|
||
}
|
||
_initialZoomRunning = false;
|
||
};
|
||
|
||
// if bounds aren't provided, just open gallery without animation
|
||
if(!duration || !thumbBounds || thumbBounds.x === undefined) {
|
||
|
||
_shout('initialZoom' + (out ? 'Out' : 'In') );
|
||
|
||
_currZoomLevel = item.initialZoomLevel;
|
||
_equalizePoints(_panOffset, item.initialPosition );
|
||
_applyCurrentZoomPan();
|
||
|
||
template.style.opacity = out ? 0 : 1;
|
||
_applyBgOpacity(1);
|
||
|
||
if(duration) {
|
||
setTimeout(function() {
|
||
onComplete();
|
||
}, duration);
|
||
} else {
|
||
onComplete();
|
||
}
|
||
|
||
return;
|
||
}
|
||
|
||
var startAnimation = function() {
|
||
var closeWithRaf = _closedByScroll,
|
||
fadeEverything = !self.currItem.src || self.currItem.loadError || _options.showHideOpacity;
|
||
|
||
// apply hw-acceleration to image
|
||
if(item.miniImg) {
|
||
item.miniImg.style.webkitBackfaceVisibility = 'hidden';
|
||
}
|
||
|
||
if(!out) {
|
||
_currZoomLevel = thumbBounds.w / item.w;
|
||
_panOffset.x = thumbBounds.x;
|
||
_panOffset.y = thumbBounds.y - _initalWindowScrollY;
|
||
|
||
self[fadeEverything ? 'template' : 'bg'].style.opacity = 0.001;
|
||
_applyCurrentZoomPan();
|
||
}
|
||
|
||
_registerStartAnimation('initialZoom');
|
||
|
||
if(out && !closeWithRaf) {
|
||
framework.removeClass(template, 'pswp--animated-in');
|
||
}
|
||
|
||
if(fadeEverything) {
|
||
if(out) {
|
||
framework[ (closeWithRaf ? 'remove' : 'add') + 'Class' ](template, 'pswp--animate_opacity');
|
||
} else {
|
||
setTimeout(function() {
|
||
framework.addClass(template, 'pswp--animate_opacity');
|
||
}, 30);
|
||
}
|
||
}
|
||
|
||
_showOrHideTimeout = setTimeout(function() {
|
||
|
||
_shout('initialZoom' + (out ? 'Out' : 'In') );
|
||
|
||
|
||
if(!out) {
|
||
|
||
// "in" animation always uses CSS transitions (instead of rAF).
|
||
// CSS transition work faster here,
|
||
// as developer may also want to animate other things,
|
||
// like ui on top of sliding area, which can be animated just via CSS
|
||
|
||
_currZoomLevel = item.initialZoomLevel;
|
||
_equalizePoints(_panOffset, item.initialPosition );
|
||
_applyCurrentZoomPan();
|
||
_applyBgOpacity(1);
|
||
|
||
if(fadeEverything) {
|
||
template.style.opacity = 1;
|
||
} else {
|
||
_applyBgOpacity(1);
|
||
}
|
||
|
||
_showOrHideTimeout = setTimeout(onComplete, duration + 20);
|
||
} else {
|
||
|
||
// "out" animation uses rAF only when PhotoSwipe is closed by browser scroll, to recalculate position
|
||
var destZoomLevel = thumbBounds.w / item.w,
|
||
initialPanOffset = {
|
||
x: _panOffset.x,
|
||
y: _panOffset.y
|
||
},
|
||
initialZoomLevel = _currZoomLevel,
|
||
initalBgOpacity = _bgOpacity,
|
||
onUpdate = function(now) {
|
||
|
||
if(now === 1) {
|
||
_currZoomLevel = destZoomLevel;
|
||
_panOffset.x = thumbBounds.x;
|
||
_panOffset.y = thumbBounds.y - _currentWindowScrollY;
|
||
} else {
|
||
_currZoomLevel = (destZoomLevel - initialZoomLevel) * now + initialZoomLevel;
|
||
_panOffset.x = (thumbBounds.x - initialPanOffset.x) * now + initialPanOffset.x;
|
||
_panOffset.y = (thumbBounds.y - _currentWindowScrollY - initialPanOffset.y) * now + initialPanOffset.y;
|
||
}
|
||
|
||
_applyCurrentZoomPan();
|
||
if(fadeEverything) {
|
||
template.style.opacity = 1 - now;
|
||
} else {
|
||
_applyBgOpacity( initalBgOpacity - now * initalBgOpacity );
|
||
}
|
||
};
|
||
|
||
if(closeWithRaf) {
|
||
_animateProp('initialZoom', 0, 1, duration, framework.easing.cubic.out, onUpdate, onComplete);
|
||
} else {
|
||
onUpdate(1);
|
||
_showOrHideTimeout = setTimeout(onComplete, duration + 20);
|
||
}
|
||
}
|
||
|
||
}, out ? 25 : 90); // Main purpose of this delay is to give browser time to paint and
|
||
// create composite layers of PhotoSwipe UI parts (background, controls, caption, arrows).
|
||
// Which avoids lag at the beginning of scale transition.
|
||
};
|
||
startAnimation();
|
||
|
||
|
||
};
|
||
|
||
/*>>show-hide-transition*/
|
||
|
||
/*>>items-controller*/
|
||
/**
|
||
*
|
||
* Controller manages gallery items, their dimensions, and their content.
|
||
*
|
||
*/
|
||
|
||
var _items,
|
||
_tempPanAreaSize = {},
|
||
_imagesToAppendPool = [],
|
||
_initialContentSet,
|
||
_initialZoomRunning,
|
||
_controllerDefaultOptions = {
|
||
index: 0,
|
||
errorMsg: '<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',
|
||
forceProgressiveLoading: false, // TODO
|
||
preload: [1,1],
|
||
getNumItemsFn: function() {
|
||
return _items.length;
|
||
}
|
||
};
|
||
|
||
|
||
var _getItemAt,
|
||
_getNumItems,
|
||
_initialIsLoop,
|
||
_getZeroBounds = function() {
|
||
return {
|
||
center:{x:0,y:0},
|
||
max:{x:0,y:0},
|
||
min:{x:0,y:0}
|
||
};
|
||
},
|
||
_calculateSingleItemPanBounds = function(item, realPanElementW, realPanElementH ) {
|
||
var bounds = item.bounds;
|
||
|
||
// position of element when it's centered
|
||
bounds.center.x = Math.round((_tempPanAreaSize.x - realPanElementW) / 2);
|
||
bounds.center.y = Math.round((_tempPanAreaSize.y - realPanElementH) / 2) + item.vGap.top;
|
||
|
||
// maximum pan position
|
||
bounds.max.x = (realPanElementW > _tempPanAreaSize.x) ?
|
||
Math.round(_tempPanAreaSize.x - realPanElementW) :
|
||
bounds.center.x;
|
||
|
||
bounds.max.y = (realPanElementH > _tempPanAreaSize.y) ?
|
||
Math.round(_tempPanAreaSize.y - realPanElementH) + item.vGap.top :
|
||
bounds.center.y;
|
||
|
||
// minimum pan position
|
||
bounds.min.x = (realPanElementW > _tempPanAreaSize.x) ? 0 : bounds.center.x;
|
||
bounds.min.y = (realPanElementH > _tempPanAreaSize.y) ? item.vGap.top : bounds.center.y;
|
||
},
|
||
_calculateItemSize = function(item, viewportSize, zoomLevel) {
|
||
|
||
if (item.src && !item.loadError) {
|
||
var isInitial = !zoomLevel;
|
||
|
||
if(isInitial) {
|
||
if(!item.vGap) {
|
||
item.vGap = {top:0,bottom:0};
|
||
}
|
||
// allows overriding vertical margin for individual items
|
||
_shout('parseVerticalMargin', item);
|
||
}
|
||
|
||
|
||
_tempPanAreaSize.x = viewportSize.x;
|
||
_tempPanAreaSize.y = viewportSize.y - item.vGap.top - item.vGap.bottom;
|
||
|
||
if (isInitial) {
|
||
var hRatio = _tempPanAreaSize.x / item.w;
|
||
var vRatio = _tempPanAreaSize.y / item.h;
|
||
|
||
item.fitRatio = hRatio < vRatio ? hRatio : vRatio;
|
||
//item.fillRatio = hRatio > vRatio ? hRatio : vRatio;
|
||
|
||
var scaleMode = _options.scaleMode;
|
||
|
||
if (scaleMode === 'orig') {
|
||
zoomLevel = 1;
|
||
} else if (scaleMode === 'fit') {
|
||
zoomLevel = item.fitRatio;
|
||
}
|
||
|
||
if (zoomLevel > 1) {
|
||
zoomLevel = 1;
|
||
}
|
||
|
||
item.initialZoomLevel = zoomLevel;
|
||
|
||
if(!item.bounds) {
|
||
// reuse bounds object
|
||
item.bounds = _getZeroBounds();
|
||
}
|
||
}
|
||
|
||
if(!zoomLevel) {
|
||
return;
|
||
}
|
||
|
||
_calculateSingleItemPanBounds(item, item.w * zoomLevel, item.h * zoomLevel);
|
||
|
||
if (isInitial && zoomLevel === item.initialZoomLevel) {
|
||
item.initialPosition = item.bounds.center;
|
||
}
|
||
|
||
return item.bounds;
|
||
} else {
|
||
item.w = item.h = 0;
|
||
item.initialZoomLevel = item.fitRatio = 1;
|
||
item.bounds = _getZeroBounds();
|
||
item.initialPosition = item.bounds.center;
|
||
|
||
// if it's not image, we return zero bounds (content is not zoomable)
|
||
return item.bounds;
|
||
}
|
||
|
||
},
|
||
|
||
|
||
|
||
|
||
_appendImage = function(index, item, baseDiv, img, preventAnimation, keepPlaceholder) {
|
||
|
||
|
||
if(item.loadError) {
|
||
return;
|
||
}
|
||
|
||
if(img) {
|
||
|
||
item.imageAppended = true;
|
||
_setImageSize(item, img, (item === self.currItem && _renderMaxResolution) );
|
||
|
||
baseDiv.appendChild(img);
|
||
|
||
if(keepPlaceholder) {
|
||
setTimeout(function() {
|
||
if(item && item.loaded && item.placeholder) {
|
||
item.placeholder.style.display = 'none';
|
||
item.placeholder = null;
|
||
}
|
||
}, 500);
|
||
}
|
||
}
|
||
},
|
||
|
||
|
||
|
||
_preloadImage = function(item) {
|
||
item.loading = true;
|
||
item.loaded = false;
|
||
var img = item.img = framework.createEl('pswp__img', 'img');
|
||
var onComplete = function() {
|
||
item.loading = false;
|
||
item.loaded = true;
|
||
|
||
if(item.loadComplete) {
|
||
item.loadComplete(item);
|
||
} else {
|
||
item.img = null; // no need to store image object
|
||
}
|
||
img.onload = img.onerror = null;
|
||
img = null;
|
||
};
|
||
img.onload = onComplete;
|
||
img.onerror = function() {
|
||
item.loadError = true;
|
||
onComplete();
|
||
};
|
||
|
||
img.src = item.src;// + '?a=' + Math.random();
|
||
|
||
return img;
|
||
},
|
||
_checkForError = function(item, cleanUp) {
|
||
if(item.src && item.loadError && item.container) {
|
||
|
||
if(cleanUp) {
|
||
item.container.innerHTML = '';
|
||
}
|
||
|
||
item.container.innerHTML = _options.errorMsg.replace('%url%', item.src );
|
||
return true;
|
||
|
||
}
|
||
},
|
||
_setImageSize = function(item, img, maxRes) {
|
||
if(!item.src) {
|
||
return;
|
||
}
|
||
|
||
if(!img) {
|
||
img = item.container.lastChild;
|
||
}
|
||
|
||
var w = maxRes ? item.w : Math.round(item.w * item.fitRatio),
|
||
h = maxRes ? item.h : Math.round(item.h * item.fitRatio);
|
||
|
||
if(item.placeholder && !item.loaded) {
|
||
item.placeholder.style.width = w + 'px';
|
||
item.placeholder.style.height = h + 'px';
|
||
}
|
||
|
||
img.style.width = w + 'px';
|
||
img.style.height = h + 'px';
|
||
},
|
||
_appendImagesPool = function() {
|
||
|
||
if(_imagesToAppendPool.length) {
|
||
var poolItem;
|
||
|
||
for(var i = 0; i < _imagesToAppendPool.length; i++) {
|
||
poolItem = _imagesToAppendPool[i];
|
||
if( poolItem.holder.index === poolItem.index ) {
|
||
_appendImage(poolItem.index, poolItem.item, poolItem.baseDiv, poolItem.img, false, poolItem.clearPlaceholder);
|
||
}
|
||
}
|
||
_imagesToAppendPool = [];
|
||
}
|
||
};
|
||
|
||
|
||
|
||
_registerModule('Controller', {
|
||
|
||
publicMethods: {
|
||
|
||
lazyLoadItem: function(index) {
|
||
index = _getLoopedId(index);
|
||
var item = _getItemAt(index);
|
||
|
||
if(!item || ((item.loaded || item.loading) && !_itemsNeedUpdate)) {
|
||
return;
|
||
}
|
||
|
||
_shout('gettingData', index, item);
|
||
|
||
if (!item.src) {
|
||
return;
|
||
}
|
||
|
||
_preloadImage(item);
|
||
},
|
||
initController: function() {
|
||
framework.extend(_options, _controllerDefaultOptions, true);
|
||
self.items = _items = items;
|
||
_getItemAt = self.getItemAt;
|
||
_getNumItems = _options.getNumItemsFn; //self.getNumItems;
|
||
|
||
|
||
|
||
_initialIsLoop = _options.loop;
|
||
if(_getNumItems() < 3) {
|
||
_options.loop = false; // disable loop if less then 3 items
|
||
}
|
||
|
||
_listen('beforeChange', function(diff) {
|
||
|
||
var p = _options.preload,
|
||
isNext = diff === null ? true : (diff >= 0),
|
||
preloadBefore = Math.min(p[0], _getNumItems() ),
|
||
preloadAfter = Math.min(p[1], _getNumItems() ),
|
||
i;
|
||
|
||
|
||
for(i = 1; i <= (isNext ? preloadAfter : preloadBefore); i++) {
|
||
self.lazyLoadItem(_currentItemIndex+i);
|
||
}
|
||
for(i = 1; i <= (isNext ? preloadBefore : preloadAfter); i++) {
|
||
self.lazyLoadItem(_currentItemIndex-i);
|
||
}
|
||
});
|
||
|
||
_listen('initialLayout', function() {
|
||
self.currItem.initialLayout = _options.getThumbBoundsFn && _options.getThumbBoundsFn(_currentItemIndex);
|
||
});
|
||
|
||
_listen('mainScrollAnimComplete', _appendImagesPool);
|
||
_listen('initialZoomInEnd', _appendImagesPool);
|
||
|
||
|
||
|
||
_listen('destroy', function() {
|
||
var item;
|
||
for(var i = 0; i < _items.length; i++) {
|
||
item = _items[i];
|
||
// remove reference to DOM elements, for GC
|
||
if(item.container) {
|
||
item.container = null;
|
||
}
|
||
if(item.placeholder) {
|
||
item.placeholder = null;
|
||
}
|
||
if(item.img) {
|
||
item.img = null;
|
||
}
|
||
if(item.preloader) {
|
||
item.preloader = null;
|
||
}
|
||
if(item.loadError) {
|
||
item.loaded = item.loadError = false;
|
||
}
|
||
}
|
||
_imagesToAppendPool = null;
|
||
});
|
||
},
|
||
|
||
|
||
getItemAt: function(index) {
|
||
if (index >= 0) {
|
||
return _items[index] !== undefined ? _items[index] : false;
|
||
}
|
||
return false;
|
||
},
|
||
|
||
allowProgressiveImg: function() {
|
||
// 1. Progressive image loading isn't working on webkit/blink
|
||
// when hw-acceleration (e.g. translateZ) is applied to IMG element.
|
||
// That's why in PhotoSwipe parent element gets zoom transform, not image itself.
|
||
//
|
||
// 2. Progressive image loading sometimes blinks in webkit/blink when applying animation to parent element.
|
||
// That's why it's disabled on touch devices (mainly because of swipe transition)
|
||
//
|
||
// 3. Progressive image loading sometimes doesn't work in IE (up to 11).
|
||
|
||
// Don't allow progressive loading on non-large touch devices
|
||
return _options.forceProgressiveLoading || !_likelyTouchDevice || _options.mouseUsed || screen.width > 1200;
|
||
// 1200 - to eliminate touch devices with large screen (like Chromebook Pixel)
|
||
},
|
||
|
||
setContent: function(holder, index) {
|
||
|
||
if(_options.loop) {
|
||
index = _getLoopedId(index);
|
||
}
|
||
|
||
var prevItem = self.getItemAt(holder.index);
|
||
if(prevItem) {
|
||
prevItem.container = null;
|
||
}
|
||
|
||
var item = self.getItemAt(index),
|
||
img;
|
||
|
||
if(!item) {
|
||
holder.el.innerHTML = '';
|
||
return;
|
||
}
|
||
|
||
// allow to override data
|
||
_shout('gettingData', index, item);
|
||
|
||
holder.index = index;
|
||
holder.item = item;
|
||
|
||
// base container DIV is created only once for each of 3 holders
|
||
var baseDiv = item.container = framework.createEl('pswp__zoom-wrap');
|
||
|
||
|
||
|
||
if(!item.src && item.html) {
|
||
if(item.html.tagName) {
|
||
baseDiv.appendChild(item.html);
|
||
} else {
|
||
baseDiv.innerHTML = item.html;
|
||
}
|
||
}
|
||
|
||
_checkForError(item);
|
||
|
||
_calculateItemSize(item, _viewportSize);
|
||
|
||
if(item.src && !item.loadError && !item.loaded) {
|
||
|
||
item.loadComplete = function(item) {
|
||
|
||
// gallery closed before image finished loading
|
||
if(!_isOpen) {
|
||
return;
|
||
}
|
||
|
||
// check if holder hasn't changed while image was loading
|
||
if(holder && holder.index === index ) {
|
||
if( _checkForError(item, true) ) {
|
||
item.loadComplete = item.img = null;
|
||
_calculateItemSize(item, _viewportSize);
|
||
_applyZoomPanToItem(item);
|
||
|
||
if(holder.index === _currentItemIndex) {
|
||
// recalculate dimensions
|
||
self.updateCurrZoomItem();
|
||
}
|
||
return;
|
||
}
|
||
if( !item.imageAppended ) {
|
||
if(_features.transform && (_mainScrollAnimating || _initialZoomRunning) ) {
|
||
_imagesToAppendPool.push({
|
||
item:item,
|
||
baseDiv:baseDiv,
|
||
img:item.img,
|
||
index:index,
|
||
holder:holder,
|
||
clearPlaceholder:true
|
||
});
|
||
} else {
|
||
_appendImage(index, item, baseDiv, item.img, _mainScrollAnimating || _initialZoomRunning, true);
|
||
}
|
||
} else {
|
||
// remove preloader & mini-img
|
||
if(!_initialZoomRunning && item.placeholder) {
|
||
item.placeholder.style.display = 'none';
|
||
item.placeholder = null;
|
||
}
|
||
}
|
||
}
|
||
|
||
item.loadComplete = null;
|
||
item.img = null; // no need to store image element after it's added
|
||
|
||
_shout('imageLoadComplete', index, item);
|
||
};
|
||
|
||
if(framework.features.transform) {
|
||
|
||
var placeholderClassName = 'pswp__img pswp__img--placeholder';
|
||
placeholderClassName += (item.msrc ? '' : ' pswp__img--placeholder--blank');
|
||
|
||
var placeholder = framework.createEl(placeholderClassName, item.msrc ? 'img' : '');
|
||
if(item.src) {
|
||
placeholder.src = item.src;
|
||
placeholder.style.display='none';
|
||
}
|
||
|
||
_setImageSize(item, placeholder);
|
||
baseDiv.appendChild(placeholder);
|
||
setTimeout(function(){
|
||
$('.pswp__img--placeholder').fadeIn();
|
||
},100)
|
||
item.placeholder = placeholder;
|
||
}
|
||
|
||
|
||
if(!item.loading) {
|
||
_preloadImage(item);
|
||
}
|
||
|
||
|
||
if( self.allowProgressiveImg() ) {
|
||
// just append image
|
||
if(!_initialContentSet && _features.transform) {
|
||
_imagesToAppendPool.push({
|
||
item:item,
|
||
baseDiv:baseDiv,
|
||
img:item.img,
|
||
index:index,
|
||
holder:holder
|
||
});
|
||
} else {
|
||
_appendImage(index, item, baseDiv, item.img, true, true);
|
||
}
|
||
}
|
||
|
||
} else if(item.src && !item.loadError) {
|
||
// image object is created every time, due to bugs of image loading & delay when switching images
|
||
img = framework.createEl('pswp__img', 'img');
|
||
img.style.opacity = 1;
|
||
img.src = item.src;
|
||
_setImageSize(item, img);
|
||
_appendImage(index, item, baseDiv, img, true);
|
||
}
|
||
|
||
|
||
if(!_initialContentSet && index === _currentItemIndex) {
|
||
_currZoomElementStyle = baseDiv.style;
|
||
_showOrHide(item, (img ||item.img) );
|
||
} else {
|
||
_applyZoomPanToItem(item);
|
||
}
|
||
|
||
holder.el.innerHTML = '';
|
||
holder.el.appendChild(baseDiv);
|
||
},
|
||
|
||
cleanSlide: function( item ) {
|
||
if(item.img ) {
|
||
item.img.onload = item.img.onerror = null;
|
||
}
|
||
item.loaded = item.loading = item.img = item.imageAppended = false;
|
||
}
|
||
|
||
}
|
||
});
|
||
|
||
/*>>items-controller*/
|
||
|
||
/*>>tap*/
|
||
/**
|
||
* tap.js:
|
||
*
|
||
* Displatches tap and double-tap events.
|
||
*
|
||
*/
|
||
|
||
var tapTimer,
|
||
tapReleasePoint = {},
|
||
_dispatchTapEvent = function(origEvent, releasePoint, pointerType) {
|
||
var e = document.createEvent( 'CustomEvent' ),
|
||
eDetail = {
|
||
origEvent:origEvent,
|
||
target:origEvent.target,
|
||
releasePoint: releasePoint,
|
||
pointerType:pointerType || 'touch'
|
||
};
|
||
|
||
e.initCustomEvent( 'pswpTap', true, true, eDetail );
|
||
origEvent.target.dispatchEvent(e);
|
||
};
|
||
|
||
_registerModule('Tap', {
|
||
publicMethods: {
|
||
initTap: function() {
|
||
_listen('firstTouchStart', self.onTapStart);
|
||
_listen('touchRelease', self.onTapRelease);
|
||
_listen('destroy', function() {
|
||
tapReleasePoint = {};
|
||
tapTimer = null;
|
||
});
|
||
},
|
||
onTapStart: function(touchList) {
|
||
if(touchList.length > 1) {
|
||
clearTimeout(tapTimer);
|
||
tapTimer = null;
|
||
}
|
||
},
|
||
onTapRelease: function(e, releasePoint) {
|
||
if(!releasePoint) {
|
||
return;
|
||
}
|
||
|
||
if(!_moved && !_isMultitouch && !_numAnimations) {
|
||
var p0 = releasePoint;
|
||
if(tapTimer) {
|
||
clearTimeout(tapTimer);
|
||
tapTimer = null;
|
||
|
||
// Check if taped on the same place
|
||
if ( _isNearbyPoints(p0, tapReleasePoint) ) {
|
||
_shout('doubleTap', p0);
|
||
return;
|
||
}
|
||
}
|
||
|
||
if(releasePoint.type === 'mouse') {
|
||
_dispatchTapEvent(e, releasePoint, 'mouse');
|
||
return;
|
||
}
|
||
|
||
var clickedTagName = e.target.tagName.toUpperCase();
|
||
// avoid double tap delay on buttons and elements that have class pswp__single-tap
|
||
if(clickedTagName === 'BUTTON' || framework.hasClass(e.target, 'pswp__single-tap') ) {
|
||
_dispatchTapEvent(e, releasePoint);
|
||
return;
|
||
}
|
||
|
||
_equalizePoints(tapReleasePoint, p0);
|
||
|
||
tapTimer = setTimeout(function() {
|
||
_dispatchTapEvent(e, releasePoint);
|
||
tapTimer = null;
|
||
}, 300);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
/*>>tap*/
|
||
|
||
/*>>desktop-zoom*/
|
||
/**
|
||
*
|
||
* desktop-zoom.js:
|
||
*
|
||
* - Binds mousewheel event for paning zoomed image.
|
||
* - Manages "dragging", "zoomed-in", "zoom-out" classes.
|
||
* (which are used for cursors and zoom icon)
|
||
* - Adds toggleDesktopZoom function.
|
||
*
|
||
*/
|
||
|
||
var _wheelDelta;
|
||
|
||
_registerModule('DesktopZoom', {
|
||
|
||
publicMethods: {
|
||
|
||
initDesktopZoom: function() {
|
||
|
||
if(_oldIE) {
|
||
// no zoom for old IE (<=8)
|
||
return;
|
||
}
|
||
|
||
if(_likelyTouchDevice) {
|
||
// if detected hardware touch support, we wait until mouse is used,
|
||
// and only then apply desktop-zoom features
|
||
_listen('mouseUsed', function() {
|
||
self.setupDesktopZoom();
|
||
});
|
||
} else {
|
||
self.setupDesktopZoom(true);
|
||
}
|
||
|
||
},
|
||
|
||
setupDesktopZoom: function(onInit) {
|
||
|
||
_wheelDelta = {};
|
||
|
||
var events = 'wheel mousewheel DOMMouseScroll';
|
||
|
||
_listen('bindEvents', function() {
|
||
framework.bind(template, events, self.handleMouseWheel);
|
||
});
|
||
|
||
_listen('unbindEvents', function() {
|
||
if(_wheelDelta) {
|
||
framework.unbind(template, events, self.handleMouseWheel);
|
||
}
|
||
});
|
||
|
||
self.mouseZoomedIn = false;
|
||
|
||
var hasDraggingClass,
|
||
updateZoomable = function() {
|
||
if(self.mouseZoomedIn) {
|
||
framework.removeClass(template, 'pswp--zoomed-in');
|
||
self.mouseZoomedIn = false;
|
||
}
|
||
// if(_currZoomLevel < 1) {
|
||
framework.addClass(template, 'pswp--zoom-allowed');
|
||
// } else {
|
||
// framework.removeClass(template, 'pswp--zoom-allowed');
|
||
// }
|
||
removeDraggingClass();
|
||
},
|
||
removeDraggingClass = function() {
|
||
if(hasDraggingClass) {
|
||
framework.removeClass(template, 'pswp--dragging');
|
||
hasDraggingClass = false;
|
||
}
|
||
};
|
||
|
||
_listen('resize' , updateZoomable);
|
||
_listen('afterChange' , updateZoomable);
|
||
_listen('pointerDown', function() {
|
||
if(self.mouseZoomedIn) {
|
||
hasDraggingClass = true;
|
||
framework.addClass(template, 'pswp--dragging');
|
||
}
|
||
});
|
||
_listen('pointerUp', removeDraggingClass);
|
||
|
||
if(!onInit) {
|
||
updateZoomable();
|
||
}
|
||
|
||
},
|
||
|
||
handleMouseWheel: function(e) {
|
||
|
||
if(_currZoomLevel <= self.currItem.fitRatio) {
|
||
if( _options.modal ) {
|
||
|
||
if (!_options.closeOnScroll || _numAnimations || _isDragging) {
|
||
e.preventDefault();
|
||
} else if(_transformKey && Math.abs(e.deltaY) > 2) {
|
||
// close PhotoSwipe
|
||
// if browser supports transforms & scroll changed enough
|
||
_closedByScroll = true;
|
||
self.close();
|
||
}
|
||
|
||
}
|
||
return true;
|
||
}
|
||
|
||
// allow just one event to fire
|
||
e.stopPropagation();
|
||
|
||
// https://developer.mozilla.org/en-US/docs/Web/Events/wheel
|
||
_wheelDelta.x = 0;
|
||
|
||
if('deltaX' in e) {
|
||
if(e.deltaMode === 1 /* DOM_DELTA_LINE */) {
|
||
// 18 - average line height
|
||
_wheelDelta.x = e.deltaX * 18;
|
||
_wheelDelta.y = e.deltaY * 18;
|
||
} else {
|
||
_wheelDelta.x = e.deltaX;
|
||
_wheelDelta.y = e.deltaY;
|
||
}
|
||
} else if('wheelDelta' in e) {
|
||
if(e.wheelDeltaX) {
|
||
_wheelDelta.x = -0.16 * e.wheelDeltaX;
|
||
}
|
||
if(e.wheelDeltaY) {
|
||
_wheelDelta.y = -0.16 * e.wheelDeltaY;
|
||
} else {
|
||
_wheelDelta.y = -0.16 * e.wheelDelta;
|
||
}
|
||
} else if('detail' in e) {
|
||
_wheelDelta.y = e.detail;
|
||
} else {
|
||
return;
|
||
}
|
||
|
||
_calculatePanBounds(_currZoomLevel, true);
|
||
|
||
var newPanX = _panOffset.x - _wheelDelta.x,
|
||
newPanY = _panOffset.y - _wheelDelta.y;
|
||
|
||
// only prevent scrolling in nonmodal mode when not at edges
|
||
if (_options.modal ||
|
||
(
|
||
newPanX <= _currPanBounds.min.x && newPanX >= _currPanBounds.max.x &&
|
||
newPanY <= _currPanBounds.min.y && newPanY >= _currPanBounds.max.y
|
||
) ) {
|
||
e.preventDefault();
|
||
}
|
||
|
||
// TODO: use rAF instead of mousewheel?
|
||
self.panTo(newPanX, newPanY);
|
||
},
|
||
|
||
toggleDesktopZoom: function(centerPoint) {
|
||
centerPoint = centerPoint || {x:_viewportSize.x/2 + _offset.x, y:_viewportSize.y/2 + _offset.y };
|
||
|
||
var doubleTapZoomLevel = _options.getDoubleTapZoom(true, self.currItem);
|
||
var zoomOut = _currZoomLevel === doubleTapZoomLevel;
|
||
|
||
self.mouseZoomedIn = !zoomOut;
|
||
|
||
self.zoomTo(zoomOut ? self.currItem.initialZoomLevel : doubleTapZoomLevel, centerPoint, 333);
|
||
framework[ (!zoomOut ? 'add' : 'remove') + 'Class'](template, 'pswp--zoomed-in');
|
||
}
|
||
|
||
}
|
||
});
|
||
|
||
|
||
/*>>desktop-zoom*/
|
||
|
||
/*>>history*/
|
||
/**
|
||
*
|
||
* history.js:
|
||
*
|
||
* - Back button to close gallery.
|
||
*
|
||
* - Unique URL for each slide: example.com/&pid=1&gid=3
|
||
* (where PID is picture index, and GID and gallery index)
|
||
*
|
||
* - Switch URL when slides change.
|
||
*
|
||
*/
|
||
|
||
|
||
var _historyDefaultOptions = {
|
||
history: true,
|
||
galleryUID: 1
|
||
};
|
||
|
||
var _historyUpdateTimeout,
|
||
_hashChangeTimeout,
|
||
_hashAnimCheckTimeout,
|
||
_hashChangedByScript,
|
||
_hashChangedByHistory,
|
||
_hashReseted,
|
||
_initialHash,
|
||
_historyChanged,
|
||
_closedFromURL,
|
||
_urlChangedOnce,
|
||
_windowLoc,
|
||
|
||
_supportsPushState,
|
||
|
||
_getHash = function() {
|
||
return _windowLoc.hash.substring(1);
|
||
},
|
||
_cleanHistoryTimeouts = function() {
|
||
|
||
if(_historyUpdateTimeout) {
|
||
clearTimeout(_historyUpdateTimeout);
|
||
}
|
||
|
||
if(_hashAnimCheckTimeout) {
|
||
clearTimeout(_hashAnimCheckTimeout);
|
||
}
|
||
},
|
||
|
||
// pid - Picture index
|
||
// gid - Gallery index
|
||
_parseItemIndexFromURL = function() {
|
||
var hash = _getHash(),
|
||
params = {};
|
||
|
||
if(hash.length < 5) { // pid=1
|
||
return params;
|
||
}
|
||
|
||
var i, vars = hash.split('&');
|
||
for (i = 0; i < vars.length; i++) {
|
||
if(!vars[i]) {
|
||
continue;
|
||
}
|
||
var pair = vars[i].split('=');
|
||
if(pair.length < 2) {
|
||
continue;
|
||
}
|
||
params[pair[0]] = pair[1];
|
||
}
|
||
if(_options.galleryPIDs) {
|
||
// detect custom pid in hash and search for it among the items collection
|
||
var searchfor = params.pid;
|
||
params.pid = 0; // if custom pid cannot be found, fallback to the first item
|
||
for(i = 0; i < _items.length; i++) {
|
||
if(_items[i].pid === searchfor) {
|
||
params.pid = i;
|
||
break;
|
||
}
|
||
}
|
||
} else {
|
||
params.pid = parseInt(params.pid,10)-1;
|
||
}
|
||
if( params.pid < 0 ) {
|
||
params.pid = 0;
|
||
}
|
||
return params;
|
||
},
|
||
_updateHash = function() {
|
||
|
||
if(_hashAnimCheckTimeout) {
|
||
clearTimeout(_hashAnimCheckTimeout);
|
||
}
|
||
|
||
|
||
if(_numAnimations || _isDragging) {
|
||
// changing browser URL forces layout/paint in some browsers, which causes noticable lag during animation
|
||
// that's why we update hash only when no animations running
|
||
_hashAnimCheckTimeout = setTimeout(_updateHash, 500);
|
||
return;
|
||
}
|
||
|
||
if(_hashChangedByScript) {
|
||
clearTimeout(_hashChangeTimeout);
|
||
} else {
|
||
_hashChangedByScript = true;
|
||
}
|
||
|
||
|
||
var pid = (_currentItemIndex + 1);
|
||
var item = _getItemAt( _currentItemIndex );
|
||
if(item.hasOwnProperty('pid')) {
|
||
// carry forward any custom pid assigned to the item
|
||
pid = item.pid;
|
||
}
|
||
var newHash = _initialHash + '&' + 'gid=' + _options.galleryUID + '&' + 'pid=' + pid;
|
||
|
||
if(!_historyChanged) {
|
||
if(_windowLoc.hash.indexOf(newHash) === -1) {
|
||
_urlChangedOnce = true;
|
||
}
|
||
// first time - add new hisory record, then just replace
|
||
}
|
||
|
||
var newURL = _windowLoc.href.split('#')[0] + '#' + newHash;
|
||
|
||
if( _supportsPushState ) {
|
||
|
||
if('#' + newHash !== window.location.hash) {
|
||
history[_historyChanged ? 'replaceState' : 'pushState']('', document.title, newURL);
|
||
}
|
||
|
||
} else {
|
||
if(_historyChanged) {
|
||
_windowLoc.replace( newURL );
|
||
} else {
|
||
_windowLoc.hash = newHash;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
_historyChanged = true;
|
||
_hashChangeTimeout = setTimeout(function() {
|
||
_hashChangedByScript = false;
|
||
}, 60);
|
||
};
|
||
|
||
|
||
|
||
|
||
|
||
_registerModule('History', {
|
||
|
||
|
||
|
||
publicMethods: {
|
||
initHistory: function() {
|
||
|
||
framework.extend(_options, _historyDefaultOptions, true);
|
||
|
||
if( !_options.history ) {
|
||
return;
|
||
}
|
||
|
||
|
||
_windowLoc = window.location;
|
||
_urlChangedOnce = false;
|
||
_closedFromURL = false;
|
||
_historyChanged = false;
|
||
_initialHash = _getHash();
|
||
_supportsPushState = ('pushState' in history);
|
||
|
||
|
||
if(_initialHash.indexOf('gid=') > -1) {
|
||
_initialHash = _initialHash.split('&gid=')[0];
|
||
_initialHash = _initialHash.split('?gid=')[0];
|
||
}
|
||
|
||
|
||
_listen('afterChange', self.updateURL);
|
||
_listen('unbindEvents', function() {
|
||
framework.unbind(window, 'hashchange', self.onHashChange);
|
||
});
|
||
|
||
|
||
var returnToOriginal = function() {
|
||
_hashReseted = true;
|
||
if(!_closedFromURL) {
|
||
|
||
if(_urlChangedOnce) {
|
||
history.back();
|
||
} else {
|
||
|
||
if(_initialHash) {
|
||
_windowLoc.hash = _initialHash;
|
||
} else {
|
||
if (_supportsPushState) {
|
||
|
||
// remove hash from url without refreshing it or scrolling to top
|
||
history.pushState('', document.title, _windowLoc.pathname + _windowLoc.search );
|
||
} else {
|
||
_windowLoc.hash = '';
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
_cleanHistoryTimeouts();
|
||
};
|
||
|
||
|
||
_listen('unbindEvents', function() {
|
||
if(_closedByScroll) {
|
||
// if PhotoSwipe is closed by scroll, we go "back" before the closing animation starts
|
||
// this is done to keep the scroll position
|
||
returnToOriginal();
|
||
}
|
||
});
|
||
_listen('destroy', function() {
|
||
if(!_hashReseted) {
|
||
returnToOriginal();
|
||
}
|
||
});
|
||
_listen('firstUpdate', function() {
|
||
_currentItemIndex = _parseItemIndexFromURL().pid;
|
||
});
|
||
|
||
|
||
|
||
|
||
var index = _initialHash.indexOf('pid=');
|
||
if(index > -1) {
|
||
_initialHash = _initialHash.substring(0, index);
|
||
if(_initialHash.slice(-1) === '&') {
|
||
_initialHash = _initialHash.slice(0, -1);
|
||
}
|
||
}
|
||
|
||
|
||
setTimeout(function() {
|
||
if(_isOpen) { // hasn't destroyed yet
|
||
framework.bind(window, 'hashchange', self.onHashChange);
|
||
}
|
||
}, 40);
|
||
|
||
},
|
||
onHashChange: function() {
|
||
|
||
if(_getHash() === _initialHash) {
|
||
|
||
_closedFromURL = true;
|
||
self.close();
|
||
return;
|
||
}
|
||
if(!_hashChangedByScript) {
|
||
|
||
_hashChangedByHistory = true;
|
||
self.goTo( _parseItemIndexFromURL().pid );
|
||
_hashChangedByHistory = false;
|
||
}
|
||
|
||
},
|
||
updateURL: function() {
|
||
|
||
// Delay the update of URL, to avoid lag during transition,
|
||
// and to not to trigger actions like "refresh page sound" or "blinking favicon" to often
|
||
|
||
_cleanHistoryTimeouts();
|
||
|
||
|
||
if(_hashChangedByHistory) {
|
||
return;
|
||
}
|
||
|
||
if(!_historyChanged) {
|
||
_updateHash(); // first time
|
||
} else {
|
||
_historyUpdateTimeout = setTimeout(_updateHash, 50);
|
||
}
|
||
}
|
||
|
||
}
|
||
});
|
||
|
||
|
||
/*>>history*/
|
||
framework.extend(self, publicMethods); };
|
||
return PhotoSwipe;
|
||
});
|
||
/*! PhotoSwipe Default UI - 4.1.0 - 2015-09-04
|
||
* http://photoswipe.com
|
||
* Copyright (c) 2015 Dmitry Semenov; */
|
||
!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.PhotoSwipeUI_Default=b()}(this,function(){"use strict";var a=function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=this,w=!1,x=!0,y=!0,z={barsSize:{top:44,bottom:"auto"},closeElClasses:["item","caption","zoom-wrap","ui","top-bar"],timeToIdle:4e3,timeToIdleOutside:1e3,loadingIndicatorDelay:1e3,addCaptionHTMLFn:function(a,b){return a.title?(b.children[0].innerHTML=a.title,!0):(b.children[0].innerHTML="",!1)},closeEl:!0,captionEl:!0,fullscreenEl:!0,zoomEl:!0,shareEl:!0,counterEl:!0,arrowEl:!0,preloaderEl:!0,tapToClose:!1,tapToToggleControls:!0,clickToCloseNonZoomable:!0,shareButtons:[{id:"facebook",label:"Share on Facebook",url:"https://www.facebook.com/sharer/sharer.php?u={{url}}"},{id:"twitter",label:"Tweet",url:"https://twitter.com/intent/tweet?text={{text}}&url={{url}}"},{id:"pinterest",label:"Pin it",url:"http://www.pinterest.com/pin/create/button/?url={{url}}&media={{image_url}}&description={{text}}"},{id:"download",label:"Download image",url:"{{raw_image_url}}",download:!0}],getImageURLForShare:function(){return a.currItem.src||""},getPageURLForShare:function(){return window.location.href},getTextForShare:function(){return a.currItem.title||""},indexIndicatorSep:" / "},A=function(a){if(r)return!0;a=a||window.event,q.timeToIdle&&q.mouseUsed&&!k&&K();for(var c,d,e=a.target||a.srcElement,f=e.className,g=0;g<S.length;g++)c=S[g],c.onTap&&f.indexOf("pswp__"+c.name)>-1&&(c.onTap(),d=!0);if(d){a.stopPropagation&&a.stopPropagation(),r=!0;var h=b.features.isOldAndroid?600:30;s=setTimeout(function(){r=!1},h)}},B=function(){return!a.likelyTouchDevice||q.mouseUsed||screen.width>1200},C=function(a,c,d){b[(d?"add":"remove")+"Class"](a,"pswp__"+c)},D=function(){var a=1===q.getNumItemsFn();a!==p&&(C(d,"ui--one-slide",a),p=a)},E=function(){C(i,"share-modal--hidden",y)},F=function(){return y=!y,y?(b.removeClass(i,"pswp__share-modal--fade-in"),setTimeout(function(){y&&E()},300)):(E(),setTimeout(function(){y||b.addClass(i,"pswp__share-modal--fade-in")},30)),y||H(),!1},G=function(b){b=b||window.event;var c=b.target||b.srcElement;return a.shout("shareLinkClick",b,c),c.href?c.hasAttribute("download")?!0:(window.open(c.href,"pswp_share","scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=550,height=420,top=100,left="+(window.screen?Math.round(screen.width/2-275):100)),y||F(),!1):!1},H=function(){for(var a,b,c,d,e,f="",g=0;g<q.shareButtons.length;g++)a=q.shareButtons[g],c=q.getImageURLForShare(a),d=q.getPageURLForShare(a),e=q.getTextForShare(a),b=a.url.replace("{{url}}",encodeURIComponent(d)).replace("{{image_url}}",encodeURIComponent(c)).replace("{{raw_image_url}}",c).replace("{{text}}",encodeURIComponent(e)),f+='<a href="'+b+'" target="_blank" class="pswp__share--'+a.id+'"'+(a.download?"download":"")+">"+a.label+"</a>",q.parseShareButtonOut&&(f=q.parseShareButtonOut(a,f));i.children[0].innerHTML=f,i.children[0].onclick=G},I=function(a){for(var c=0;c<q.closeElClasses.length;c++)if(b.hasClass(a,"pswp__"+q.closeElClasses[c]))return!0},J=0,K=function(){clearTimeout(u),J=0,k&&v.setIdle(!1)},L=function(a){a=a?a:window.event;var b=a.relatedTarget||a.toElement;b&&"HTML"!==b.nodeName||(clearTimeout(u),u=setTimeout(function(){v.setIdle(!0)},q.timeToIdleOutside))},M=function(){q.fullscreenEl&&!b.features.isOldAndroid&&(c||(c=v.getFullscreenAPI()),c?(b.bind(document,c.eventK,v.updateFullscreen),v.updateFullscreen(),b.addClass(a.template,"pswp--supports-fs")):b.removeClass(a.template,"pswp--supports-fs"))},N=function(){q.preloaderEl&&(O(!0),l("beforeChange",function(){clearTimeout(o),o=setTimeout(function(){a.currItem&&a.currItem.loading?(!a.allowProgressiveImg()||a.currItem.img&&!a.currItem.img.naturalWidth)&&O(!1):O(!0)},q.loadingIndicatorDelay)}),l("imageLoadComplete",function(b,c){a.currItem===c&&O(!0)}))},O=function(a){n!==a&&(C(m,"preloader--active",!a),n=a)},P=function(a){var c=a.vGap;if(B()){var g=q.barsSize;if(q.captionEl&&"auto"===g.bottom)if(f||(f=b.createEl("pswp__caption pswp__caption--fake"),f.appendChild(b.createEl("pswp__caption__center")),d.insertBefore(f,e),b.addClass(d,"pswp__ui--fit")),q.addCaptionHTMLFn(a,f,!0)){var h=f.clientHeight;c.bottom=parseInt(h,10)||44}else c.bottom=g.top;else c.bottom="auto"===g.bottom?0:g.bottom;c.top=g.top}else c.top=c.bottom=0},Q=function(){q.timeToIdle&&l("mouseUsed",function(){b.bind(document,"mousemove",K),b.bind(document,"mouseout",L),t=setInterval(function(){J++,2===J&&v.setIdle(!0)},q.timeToIdle/2)})},R=function(){l("onVerticalDrag",function(a){x&&.95>a?v.hideControls():!x&&a>=.95&&v.showControls()});var a;l("onPinchClose",function(b){x&&.9>b?(v.hideControls(),a=!0):a&&!x&&b>.9&&v.showControls()}),l("zoomGestureEnded",function(){a=!1,a&&!x&&v.showControls()})},S=[{name:"caption",option:"captionEl",onInit:function(a){e=a}},{name:"share-modal",option:"shareEl",onInit:function(a){i=a},onTap:function(){F()}},{name:"button--share",option:"shareEl",onInit:function(a){h=a},onTap:function(){F()}},{name:"button--zoom",option:"zoomEl",onTap:a.toggleDesktopZoom},{name:"counter",option:"counterEl",onInit:function(a){g=a}},{name:"button--close",option:"closeEl",onTap:a.close},{name:"button--arrow--left",option:"arrowEl",onTap:a.prev},{name:"button--arrow--right",option:"arrowEl",onTap:a.next},{name:"button--fs",option:"fullscreenEl",onTap:function(){c.isFullscreen()?c.exit():c.enter()}},{name:"preloader",option:"preloaderEl",onInit:function(a){m=a}}],T=function(){var a,c,e,f=function(d){if(d)for(var f=d.length,g=0;f>g;g++){a=d[g],c=a.className;for(var h=0;h<S.length;h++)e=S[h],c.indexOf("pswp__"+e.name)>-1&&(q[e.option]?(b.removeClass(a,"pswp__element--disabled"),e.onInit&&e.onInit(a)):b.addClass(a,"pswp__element--disabled"))}};f(d.children);var g=b.getChildByClass(d,"pswp__top-bar");g&&f(g.children)};v.init=function(){b.extend(a.options,z,!0),q=a.options,d=b.getChildByClass(a.scrollWrap,"pswp__ui"),l=a.listen,R(),l("beforeChange",v.update),l("doubleTap",function(b){var c=a.currItem.initialZoomLevel;a.getZoomLevel()!==c?a.zoomTo(c,b,333):a.zoomTo(q.getDoubleTapZoom(!1,a.currItem),b,333)}),l("preventDragEvent",function(a,b,c){var d=a.target||a.srcElement;d&&d.className&&a.type.indexOf("mouse")>-1&&(d.className.indexOf("__caption")>0||/(SMALL|STRONG|EM)/i.test(d.tagName))&&(c.prevent=!1)}),l("bindEvents",function(){b.bind(d,"pswpTap click",A),b.bind(a.scrollWrap,"pswpTap",v.onGlobalTap),a.likelyTouchDevice||b.bind(a.scrollWrap,"mouseover",v.onMouseOver)}),l("unbindEvents",function(){y||F(),t&&clearInterval(t),b.unbind(document,"mouseout",L),b.unbind(document,"mousemove",K),b.unbind(d,"pswpTap click",A),b.unbind(a.scrollWrap,"pswpTap",v.onGlobalTap),b.unbind(a.scrollWrap,"mouseover",v.onMouseOver),c&&(b.unbind(document,c.eventK,v.updateFullscreen),c.isFullscreen()&&(q.hideAnimationDuration=0,c.exit()),c=null)}),l("destroy",function(){q.captionEl&&(f&&d.removeChild(f),b.removeClass(e,"pswp__caption--empty")),i&&(i.children[0].onclick=null),b.removeClass(d,"pswp__ui--over-close"),b.addClass(d,"pswp__ui--hidden"),v.setIdle(!1)}),q.showAnimationDuration||b.removeClass(d,"pswp__ui--hidden"),l("initialZoomIn",function(){q.showAnimationDuration&&b.removeClass(d,"pswp__ui--hidden")}),l("initialZoomOut",function(){b.addClass(d,"pswp__ui--hidden")}),l("parseVerticalMargin",P),T(),q.shareEl&&h&&i&&(y=!0),D(),Q(),M(),N()},v.setIdle=function(a){k=a,C(d,"ui--idle",a)},v.update=function(){x&&a.currItem?(v.updateIndexIndicator(),q.captionEl&&(q.addCaptionHTMLFn(a.currItem,e),C(e,"caption--empty",!a.currItem.title)),w=!0):w=!1,y||F(),D()},v.updateFullscreen=function(d){d&&setTimeout(function(){a.setScrollOffset(0,b.getScrollY())},50),b[(c.isFullscreen()?"add":"remove")+"Class"](a.template,"pswp--fs")},v.updateIndexIndicator=function(){q.counterEl&&(g.innerHTML=a.getCurrentIndex()+1+q.indexIndicatorSep+q.getNumItemsFn())},v.onGlobalTap=function(c){c=c||window.event;var d=c.target||c.srcElement;if(!r)if(c.detail&&"mouse"===c.detail.pointerType){if(I(d))return void a.close();b.hasClass(d,"pswp__img")&&(1===a.getZoomLevel()&&a.getZoomLevel()<=a.currItem.fitRatio?q.clickToCloseNonZoomable&&a.close():a.toggleDesktopZoom(c.detail.releasePoint))}else if(q.tapToToggleControls&&(x?v.hideControls():v.showControls()),q.tapToClose&&(b.hasClass(d,"pswp__img")||I(d)))return void a.close()},v.onMouseOver=function(a){a=a||window.event;var b=a.target||a.srcElement;C(d,"ui--over-close",I(b))},v.hideControls=function(){b.addClass(d,"pswp__ui--hidden"),x=!1},v.showControls=function(){x=!0,w||v.update(),b.removeClass(d,"pswp__ui--hidden")},v.supportsFullscreen=function(){var a=document;return!!(a.exitFullscreen||a.mozCancelFullScreen||a.webkitExitFullscreen||a.msExitFullscreen)},v.getFullscreenAPI=function(){var b,c=document.documentElement,d="fullscreenchange";return c.requestFullscreen?b={enterK:"requestFullscreen",exitK:"exitFullscreen",elementK:"fullscreenElement",eventK:d}:c.mozRequestFullScreen?b={enterK:"mozRequestFullScreen",exitK:"mozCancelFullScreen",elementK:"mozFullScreenElement",eventK:"moz"+d}:c.webkitRequestFullscreen?b={enterK:"webkitRequestFullscreen",exitK:"webkitExitFullscreen",elementK:"webkitFullscreenElement",eventK:"webkit"+d}:c.msRequestFullscreen&&(b={enterK:"msRequestFullscreen",exitK:"msExitFullscreen",elementK:"msFullscreenElement",eventK:"MSFullscreenChange"}),b&&(b.enter=function(){return j=q.closeOnScroll,q.closeOnScroll=!1,"webkitRequestFullscreen"!==this.enterK?a.template[this.enterK]():void a.template[this.enterK](Element.ALLOW_KEYBOARD_INPUT)},b.exit=function(){return q.closeOnScroll=j,document[this.exitK]()},b.isFullscreen=function(){return document[this.elementK]}),b}};return a});
|
||
$.initPhotoSwipeFromDOM = function(gallerySelector,medDom) {
|
||
var parseThumbnailElements = function(el) {
|
||
var thumbElements = $(medDom,el),
|
||
numNodes = thumbElements.length,
|
||
items = [],
|
||
el,
|
||
childElements,
|
||
thumbnailEl,
|
||
size,
|
||
item;
|
||
for (var i = 0; i < numNodes; i++) {
|
||
el = thumbElements[i];
|
||
// include only element nodes
|
||
if (el.nodeType !== 1) {
|
||
continue;
|
||
}
|
||
childElements = el.children;
|
||
size = el.getAttribute('data-size').split('x');
|
||
// create slide object
|
||
item = {
|
||
src: el.getAttribute('href'),
|
||
w: parseInt(size[0], 10),
|
||
h: parseInt(size[1], 10),
|
||
author: el.getAttribute('data-author')
|
||
};
|
||
item.el = el; // save link to element for getThumbBoundsFn
|
||
if (childElements.length > 0) {
|
||
item.msrc = childElements[0].getAttribute('src'); // thumbnail url
|
||
if (childElements.length > 1) {
|
||
item.title = childElements[1].innerHTML/*childElements[0].getAttribute('alt')*/; // caption (contents of figure)
|
||
}
|
||
}
|
||
var mediumSrc = el.getAttribute('data-med');
|
||
if (mediumSrc) {
|
||
size = el.getAttribute('data-med-size').split('x');
|
||
// "medium-sized" image
|
||
item.m = {
|
||
src: mediumSrc,
|
||
w: parseInt(size[0], 10),
|
||
h: parseInt(size[1], 10)
|
||
};
|
||
}
|
||
// original image
|
||
item.o = {
|
||
src: item.src,
|
||
w: item.w,
|
||
h: item.h
|
||
};
|
||
items.push(item);
|
||
}
|
||
return items;
|
||
};
|
||
// find nearest parent element
|
||
var closest = function closest(el, fn) {
|
||
return el && (fn(el) ? el : closest(el.parentNode, fn));
|
||
};
|
||
var onThumbnailsClick = function(e,parents) {
|
||
e = e || window.event;
|
||
e.preventDefault ? e.preventDefault() : e.returnValue = false;
|
||
var eTarget = e.target || e.srcElement;
|
||
var clickedListItem = closest(eTarget, function(el) {
|
||
return el.tagName === 'A';
|
||
});
|
||
if (!clickedListItem) {
|
||
return;
|
||
}
|
||
var clickedGallery = parents,
|
||
clickedListItemMed=$(clickedListItem).data('med'),
|
||
index;
|
||
$(medDom,parents).each(function(i, el) {
|
||
if($(this).data('med')==clickedListItemMed){
|
||
index=i;
|
||
return false;
|
||
}
|
||
});
|
||
if (index >= 0) {
|
||
openPhotoSwipe(index, clickedGallery);
|
||
}
|
||
return false;
|
||
};
|
||
var photoswipeParseHash = function() {
|
||
var hash = window.location.hash.substring(1),
|
||
params = {};
|
||
if (hash.length < 5) { // pid=1
|
||
return params;
|
||
}
|
||
var vars = hash.split('&');
|
||
for (var i = 0; i < vars.length; i++) {
|
||
if (!vars[i]) {
|
||
continue;
|
||
}
|
||
var pair = vars[i].split('=');
|
||
if (pair.length < 2) {
|
||
continue;
|
||
}
|
||
params[pair[0]] = pair[1];
|
||
}
|
||
if (params.gid) {
|
||
params.gid = parseInt(params.gid, 10);
|
||
}
|
||
return params;
|
||
};
|
||
var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
|
||
if(!$('.pswp').length){
|
||
var pswp_html='<div id="photoswipe-gallery" class="pswp" tabindex="-1" role="dialog" aria-hidden="true">'
|
||
+'<div class="pswp__bg"></div>'
|
||
+'<div class="pswp__scroll-wrap">'
|
||
+'<div class="pswp__container">'
|
||
+'<div class="pswp__item"></div>'
|
||
+'<div class="pswp__item"></div>'
|
||
+'<div class="pswp__item"></div>'
|
||
+'</div>'
|
||
+'<div class="pswp__ui pswp__ui--hidden">'
|
||
+'<div class="pswp__top-bar">'
|
||
+'<div class="pswp__counter"></div>'
|
||
+'<button class="pswp__button pswp__button--close" title="退出画廊"></button>'
|
||
+'<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>'
|
||
+'<button class="pswp__button pswp__button--zoom" title="放大 / 缩小"></button>'
|
||
// +'<button class="pswp__button pswp__button--rotate-left" title="逆时针旋转"><i class="icon md-rotate-ccw" aria-hidden="true"></i></button>'
|
||
// +'<button class="pswp__button pswp__button--rotate-right" title="顺时针旋转"><i class="icon md-rotate-cw" aria-hidden="true"></i></button>'
|
||
+'<div class="pswp__preloader">'
|
||
+'<div class="pswp__preloader__icn">'
|
||
+'<div class="pswp__preloader__cut">'
|
||
+'<div class="pswp__preloader__donut"></div>'
|
||
+'</div>'
|
||
+'</div>'
|
||
+'</div>'
|
||
+'</div>'
|
||
+'<div class="pswp__loading-indicator">'
|
||
+'<div class="pswp__loading-indicator__line"></div>'
|
||
+'</div>'
|
||
+'<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button>'
|
||
+'<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button>'
|
||
+'<div class="pswp__caption">'
|
||
+'<div class="pswp__caption__center"></div>'
|
||
+'</div>'
|
||
+'</div>'
|
||
+'</div>'
|
||
+'</div>';
|
||
$('body').append(pswp_html);
|
||
}
|
||
var pswpElement = document.querySelectorAll('.pswp')[0],
|
||
gallery,
|
||
options,
|
||
items;
|
||
items = parseThumbnailElements(galleryElement);
|
||
// define options (if needed)
|
||
options = {
|
||
galleryUID: galleryElement.getAttribute('data-pswp-uid'),
|
||
getThumbBoundsFn: function(index) {
|
||
// See Options->getThumbBoundsFn section of docs for more info
|
||
var thumbnail = items[index].el.children[0],
|
||
pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
|
||
rect = thumbnail.getBoundingClientRect();
|
||
return {
|
||
x: rect.left,
|
||
y: rect.top + pageYScroll,
|
||
w: rect.width
|
||
};
|
||
},
|
||
addCaptionHTMLFn: function(item, captionEl, isFake) {
|
||
if (!item.title) {
|
||
captionEl.children[0].innerText = '';
|
||
return false;
|
||
}
|
||
captionEl.children[0].innerHTML = item.title/* + '<br/><small>Photo: ' + item.author + '</small>'*/;
|
||
return true;
|
||
},
|
||
closeOnScroll:false,
|
||
tapToClose:true,
|
||
tapToToggleControls:false,
|
||
fullscreenEl:false,
|
||
// captionEl:false,
|
||
shareEl:false,
|
||
errorMsg:'<div class="pswp__error-msg"><a href="%url%" target="_blank">图片</a> 加载失败</div>'
|
||
};
|
||
if (fromURL) {
|
||
if (options.galleryPIDs) {
|
||
// parse real index when custom PIDs are used
|
||
// http://photoswipe.com/documentation/faq.html#custom-pid-in-url
|
||
for (var j = 0; j < items.length; j++) {
|
||
if (items[j].pid == index) {
|
||
options.index = j;
|
||
break;
|
||
}
|
||
}
|
||
} else {
|
||
options.index = parseInt(index, 10) - 1;
|
||
}
|
||
} else {
|
||
options.index = parseInt(index, 10);
|
||
}
|
||
// exit if index not found
|
||
if (isNaN(options.index)) {
|
||
return;
|
||
}
|
||
if (disableAnimation) {
|
||
options.showAnimationDuration = 0;
|
||
}
|
||
// Pass data to PhotoSwipe and initialize it
|
||
gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
|
||
// see: http://photoswipe.com/documentation/responsive-images.html
|
||
var realViewportWidth,
|
||
useLargeImages = false,
|
||
firstResize = true,
|
||
imageSrcWillChange;
|
||
gallery.listen('beforeResize', function() {
|
||
var dpiRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
|
||
dpiRatio = Math.min(dpiRatio, 2.5);
|
||
realViewportWidth = gallery.viewportSize.x * dpiRatio;
|
||
if (realViewportWidth >= 1200 || (!gallery.likelyTouchDevice && realViewportWidth > 800) || screen.width > 1200) {
|
||
if (!useLargeImages) {
|
||
useLargeImages = true;
|
||
imageSrcWillChange = true;
|
||
}
|
||
|
||
} else {
|
||
if (useLargeImages) {
|
||
useLargeImages = false;
|
||
imageSrcWillChange = true;
|
||
}
|
||
}
|
||
if (imageSrcWillChange && !firstResize) {
|
||
gallery.invalidateCurrItems();
|
||
}
|
||
if (firstResize) {
|
||
firstResize = false;
|
||
}
|
||
imageSrcWillChange = false;
|
||
});
|
||
gallery.listen('gettingData', function(index, item) {
|
||
if (useLargeImages) {
|
||
item.src = item.o.src;
|
||
item.w = item.o.w;
|
||
item.h = item.o.h;
|
||
} else {
|
||
item.src = item.m.src;
|
||
item.w = item.m.w;
|
||
item.h = item.m.h;
|
||
}
|
||
});
|
||
gallery.init();
|
||
};
|
||
// select all gallery elements
|
||
// var galleryElements = document.querySelectorAll(gallerySelector),
|
||
var galleryElements = $(gallerySelector),
|
||
medDom=medDom||'[data-med]';
|
||
$(gallerySelector).each(function(index, el) {
|
||
$(this).attr({'data-pswp-uid':index + 1}).click(function(e) {
|
||
onThumbnailsClick(e,this);
|
||
});
|
||
});
|
||
// Parse URL and open gallery if it contains #&pid=3&gid=1
|
||
var hashData = photoswipeParseHash();
|
||
if (hashData.pid && hashData.gid) {
|
||
// openPhotoSwipe(hashData.pid, galleryElements[hashData.gid - 1], true, true);
|
||
openPhotoSwipe(hashData.pid, galleryElements.eq(hashData.gid - 1), true, true);
|
||
}
|
||
};
|
||
if(location.hash.indexOf('#&gid=')>=0 && location.hash.indexOf('&pid=')>=0) window.history.back();
|
||
/*!
|
||
* Lazy Load - jQuery plugin for lazy loading images
|
||
*
|
||
* Copyright (c) 2007-2015 Mika Tuupola
|
||
*
|
||
* Licensed under the MIT license:
|
||
* http://www.opensource.org/licenses/mit-license.php
|
||
*
|
||
* Project home:
|
||
* http://www.appelsiini.net/projects/lazyload
|
||
*
|
||
* Version: 1.9.7
|
||
*
|
||
*/
|
||
(function($, window, document, undefined) {
|
||
var $window = $(window),
|
||
canvasPosition=function(from_dom,to_dom){ // canvas设置
|
||
var top=from_dom.position().top,
|
||
left=from_dom.position().left,
|
||
width=from_dom.width(),
|
||
height=from_dom.height();
|
||
to_dom.css({top:top,left:left}).width(width).height(height);
|
||
},
|
||
canvasControl=function(dom,canvas_id){
|
||
$.stackBlurImage(dom, canvas_id, 10, false);
|
||
if(dom.is(':visible')) canvasPosition(dom,$('#'+canvas_id));
|
||
$(window).resize(function() {
|
||
if(dom.is(":visible")) canvasPosition(dom,$('#'+canvas_id));
|
||
});
|
||
$('#'+canvas_id).attr({'data-load':true});
|
||
},
|
||
thumbdir=M['weburl']+'include/thumb.php?dir=',
|
||
placeholder_base64='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC';
|
||
$.fn.lazyload = function(options) {
|
||
var elements = this;
|
||
var $container;
|
||
var settings = {
|
||
threshold : 30,
|
||
failure_limit : 1000,
|
||
event : "scroll",
|
||
effect : "fadeIn",
|
||
effect_speed : null,
|
||
container : window,
|
||
data_attribute : "original",
|
||
data_srcset : 'srcset',
|
||
skip_invisible : true,
|
||
appear : null,
|
||
load : null,
|
||
placeholder : met_lazyloadbg,// 'base64',met_lazyloadbg,'blur'
|
||
};
|
||
|
||
function update() {
|
||
var counter = 0;
|
||
|
||
elements.each(function() {
|
||
var $this = $(this),
|
||
$this_canvas=$this.next('canvas');
|
||
if (settings.skip_invisible && !$this.is(":visible")) {
|
||
return;
|
||
}
|
||
if($this_canvas.length && !$this_canvas.attr('data-load') && $.stackBlurImage) canvasControl($this,$this_canvas.attr('id'));
|
||
if ($.abovethetop(this, settings) ||
|
||
$.leftofbegin(this, settings)) {
|
||
/* Nothing. */
|
||
} else if (!$.belowthefold(this, settings) &&
|
||
!$.rightoffold(this, settings)) {
|
||
$this.trigger("appear");
|
||
/* if we found an image we'll load, reset the counter */
|
||
counter = 0;
|
||
} else {
|
||
if (++counter > settings.failure_limit) {
|
||
return false;
|
||
}
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
if(options) {
|
||
/* Maintain BC for a couple of versions. */
|
||
if (undefined !== options.failurelimit) {
|
||
options.failure_limit = options.failurelimit;
|
||
delete options.failurelimit;
|
||
}
|
||
if (undefined !== options.effectspeed) {
|
||
options.effect_speed = options.effectspeed;
|
||
delete options.effectspeed;
|
||
}
|
||
|
||
$.extend(settings, options);
|
||
}
|
||
|
||
/* Cache container as jQuery as object. */
|
||
$container = (settings.container === undefined ||
|
||
settings.container === window) ? $window : $(settings.container);
|
||
|
||
/* Fire one scroll event per scroll. Not one scroll event per image. */
|
||
if (0 === settings.event.indexOf("scroll")) {
|
||
$container.on(settings.event, function() {
|
||
return update();
|
||
});
|
||
}
|
||
if(settings.placeholder=='base64') settings.placeholder=placeholder_base64;
|
||
this.attr({'data-lazyload':true});
|
||
this.each(function(index) {
|
||
var self = this,
|
||
$self = $(self),
|
||
original = $self.attr("data-" + settings.data_attribute),
|
||
placeholder=settings.placeholder,
|
||
placeholder_ok=placeholder!=placeholder_base64?true:false;
|
||
self.loaded = false;
|
||
|
||
/* If no src attribute given use data:uri. */
|
||
if ($self.is("img") && original && (!$self.attr("src") || $self.attr("src")!=original)) {
|
||
if(placeholder=='blur' && $.stackBlurImage){
|
||
// 图片高斯模糊加载小图
|
||
if(!$self.attr('data-minimg')){
|
||
// 设置小图路径
|
||
var thumb=original.replace(M['weburl'],M['weburl']),
|
||
original_array=thumb.split('&');
|
||
if(thumb.indexOf('http')<0 || (thumb.indexOf('http')>=0 && thumb.indexOf(M['weburl'])>=0)){
|
||
if(original.indexOf('include/thumb.php?dir=')>-1){
|
||
var data_minimg=original_array[0]+'&x=50';
|
||
}else{
|
||
var data_minimg=thumbdir+thumb+'&x=50';
|
||
}
|
||
if(original_array && original_array.length==3){
|
||
scale_x=original_array[1].substring(2);
|
||
scale_y=original_array[2].substring(2);
|
||
scale=scale_y/scale_x;
|
||
minimg_h=Math.round(50*scale);
|
||
data_minimg+='&y='+minimg_h;
|
||
}
|
||
$(this).attr({src:data_minimg,'data-minimg':true});
|
||
// 高斯模糊小图
|
||
var img=new Image();
|
||
img.src=$self.attr("src");
|
||
img.onload=function(){
|
||
setTimeout(function(){
|
||
var $self_canvas=$self.next('canvas');
|
||
if($self.attr('src')!=original && !$self_canvas.length){
|
||
var canvas_id="imgcanvas"+index;
|
||
$self.wrapAll('<section style="position: relative;"></section>').after('<canvas id="'+canvas_id+'" data-load="false" width="'+$self.width()+'" height="'+$self.height()+'" style="position:absolute;z-index:10;"></canvas>');
|
||
if(!settings.skip_invisible || $self.is(":visible")) canvasControl($self,canvas_id);
|
||
}else if($self_canvas.length){
|
||
canvasPosition($self,$self_canvas);
|
||
}
|
||
},30)
|
||
}
|
||
}
|
||
}
|
||
}else{
|
||
if(placeholder=='blur') placeholder=met_lazyloadbg;
|
||
$self.attr("src", placeholder);
|
||
if(placeholder_ok && !$self.hasClass('imgloading')) $self.addClass('imgloading');
|
||
}
|
||
}
|
||
|
||
/* When appear is triggered load original image. */
|
||
$self.one("appear", function() {
|
||
if (!this.loaded) {
|
||
if (settings.appear) {
|
||
var elements_left = elements.length;
|
||
settings.appear.call(self, elements_left, settings);
|
||
}
|
||
var srcset = $self.attr("data-" + settings.data_srcset);
|
||
$("<img />")
|
||
.one("load", function() {
|
||
$self.hide();
|
||
if ($self.is("img")/* || $self.is("source") || $self.is("video") || $self.is("audio") || $self.is("iframe") || $self.is("script") || $self.is("link")*/) {
|
||
if(srcset) $self.attr("srcset", srcset);
|
||
$self.attr("src", original);
|
||
} else {
|
||
$self.css("background-image", "url('" + original + "')");
|
||
if(srcset) $self.css("background-image", "-webkit-image-set(" + srcset + ")");
|
||
}
|
||
$self[settings.effect](settings.effect_speed);
|
||
$self.one('load', function() {
|
||
$self.removeClass('imgloading');
|
||
$self.next('canvas').fadeOut("normal",function(){
|
||
$self.next('canvas').remove();
|
||
});
|
||
});
|
||
|
||
self.loaded = true;
|
||
|
||
/* Remove image from array so it is not looped next time. */
|
||
var temp = $.grep(elements, function(element) {
|
||
return !element.loaded;
|
||
});
|
||
elements = $(temp);
|
||
|
||
if (settings.load) {
|
||
var elements_left = elements.length;
|
||
settings.load.call(self, elements_left, settings);
|
||
}
|
||
}).attr({srcset:srcset,src:original}).removeClass('imgloading').next('canvas').fadeOut("normal",function(){
|
||
$("<img />").next('canvas').remove();
|
||
});
|
||
}
|
||
});
|
||
|
||
/* When wanted event is triggered load original image */
|
||
/* by triggering appear. */
|
||
if (0 !== settings.event.indexOf("scroll")) {
|
||
$self.on(settings.event, function() {
|
||
if (!self.loaded) {
|
||
$self.trigger("appear");
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
/* Check if something appears when window is resized. */
|
||
$window.on("resize", function() {
|
||
update();
|
||
});
|
||
|
||
/* With IOS5 force loading images when navigating with back button. */
|
||
/* Non optimal workaround. */
|
||
if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
|
||
$window.on("pageshow", function(event) {
|
||
if (event.originalEvent && event.originalEvent.persisted) {
|
||
elements.each(function() {
|
||
$(this).trigger("appear");
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
/* Force initial check if images should appear. */
|
||
$(document).ready(function() {
|
||
update();
|
||
});
|
||
|
||
return this;
|
||
};
|
||
|
||
/* Convenience methods in jQuery namespace. */
|
||
/* Use as $.belowthefold(element, {threshold : 100, container : window}) */
|
||
|
||
$.belowthefold = function(element, settings) {
|
||
var fold;
|
||
|
||
if (settings.container === undefined || settings.container === window) {
|
||
fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
|
||
} else {
|
||
fold = $(settings.container).offset().top + $(settings.container).height();
|
||
}
|
||
|
||
return fold <= $(element).offset().top - settings.threshold;
|
||
};
|
||
|
||
$.rightoffold = function(element, settings) {
|
||
var fold;
|
||
|
||
if (settings.container === undefined || settings.container === window) {
|
||
fold = $window.width() + $window.scrollLeft();
|
||
} else {
|
||
fold = $(settings.container).offset().left + $(settings.container).width();
|
||
}
|
||
|
||
return fold <= $(element).offset().left - settings.threshold;
|
||
};
|
||
|
||
$.abovethetop = function(element, settings) {
|
||
var fold;
|
||
|
||
if (settings.container === undefined || settings.container === window) {
|
||
fold = $window.scrollTop();
|
||
} else {
|
||
fold = $(settings.container).offset().top;
|
||
}
|
||
|
||
return fold >= $(element).offset().top + settings.threshold + $(element).height();
|
||
};
|
||
|
||
$.leftofbegin = function(element, settings) {
|
||
var fold;
|
||
|
||
if (settings.container === undefined || settings.container === window) {
|
||
fold = $window.scrollLeft();
|
||
} else {
|
||
fold = $(settings.container).offset().left;
|
||
}
|
||
|
||
return fold >= $(element).offset().left + settings.threshold + $(element).width();
|
||
};
|
||
|
||
$.inviewport = function(element, settings) {
|
||
return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
|
||
!$.belowthefold(element, settings) && !$.abovethetop(element, settings);
|
||
};
|
||
|
||
/* Custom selectors for your convenience. */
|
||
/* Use as $("img:below-the-fold").something() or */
|
||
/* $("img").filter(":below-the-fold").something() which is faster */
|
||
|
||
$.extend($.expr[":"], {
|
||
"below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
|
||
"above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
|
||
"right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
|
||
"left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
|
||
"in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); },
|
||
/* Maintain BC for couple of versions. */
|
||
"above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
|
||
"right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); },
|
||
"left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); }
|
||
});
|
||
|
||
})(jQuery, window, document);
|
||
|
||
/*
|
||
编辑器内容处理功能
|
||
*/
|
||
$(function(){
|
||
// 编辑器响应式表格(需调用tablesaw插件)
|
||
var $meteditor_table=$(".met-editor table");
|
||
if($meteditor_table.length) $meteditor_table.tablexys();
|
||
if(M['device_type']=='m'){
|
||
var editorimg_gallery_open=true;
|
||
// 编辑器画廊
|
||
$(".met-editor").each(function(){
|
||
if($("img",this).length && !$(this).hasClass('no-gallery')){
|
||
// 图片画廊参数设置
|
||
var $self=$(this),
|
||
imgsizeset=true;
|
||
$("img",this).one('click',function(){
|
||
if(imgsizeset){
|
||
$self.find('img').each(function(){
|
||
var src=$(this).attr('src'),
|
||
size='500x500';
|
||
if($(this).data('width')){
|
||
size=$(this).data('width')+'x'+$(this).data('height');
|
||
}else if($(this).attr('width') && $(this).attr('height')){
|
||
size=$(this).attr('width')+'x'+$(this).attr('height');
|
||
}
|
||
if(!($(this).parents('a').length && $(this).parents('a').find('img').length==1)) $(this).wrapAll('<a class="photoswipe-a"></a>');
|
||
$(this).parents('.photoswipe-a').attr({href:src,'data-size':size,'data-med':src,'data-med-size':size});
|
||
});
|
||
imgsizeset=false;
|
||
}
|
||
if(editorimg_gallery_open){
|
||
$.initPhotoSwipeFromDOM('.met-editor');//(需调用PhotoSwipe插件)
|
||
editorimg_gallery_open=false;
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
});
|
||
/**
|
||
* marked v0.3.3 - a markdown parser
|
||
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
|
||
* https://github.com/chjj/marked
|
||
*/
|
||
(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]="right"}else{if(/^ *:-+: *$/.test(item.align[i])){item.align[i]="center"}else{if(/^ *:-+ *$/.test(item.align[i])){item.align[i]="left"}else{item.align[i]=null}}}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].split(/ *\| */)}this.tokens.push(item);continue}if(cap=this.rules.lheading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[2]==="="?1:2,text:cap[1]});continue}if(cap=this.rules.hr.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"hr"});continue}if(cap=this.rules.blockquote.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"blockquote_start"});cap=cap[0].replace(/^ *> ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i<l;i++){item=cap[i];space=item.length;item=item.replace(/^ *([*+-]|\d+\.) +/,"");if(~item.indexOf("\n ")){space-=item.length;item=!this.options.pedantic?item.replace(new RegExp("^ {1,"+space+"}","gm"),""):item.replace(/^ {1,4}/gm,"")}if(this.options.smartLists&&i!==l-1){b=block.bullet.exec(cap[i+1])[0];if(bull!==b&&!(bull.length>1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose){loose=next}}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);
|
||
this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script"||cap[1]==="style",text:cap[0]});continue}if((!bq&&top)&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i<item.align.length;i++){if(/^ *-+: *$/.test(item.align[i])){item.align[i]="right"}else{if(/^ *:-+: *$/.test(item.align[i])){item.align[i]="center"}else{if(/^ *:-+ *$/.test(item.align[i])){item.align[i]="left"}else{item.align[i]=null}}}}for(i=0;i<item.cells.length;i++){item.cells[i]=item.cells[i].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */)}this.tokens.push(item);continue}if(top&&(cap=this.rules.paragraph.exec(src))){src=src.substring(cap[0].length);this.tokens.push({type:"paragraph",text:cap[1].charAt(cap[1].length-1)==="\n"?cap[1].slice(0,-1):cap[1]});continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"text",text:cap[0]});continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return this.tokens};var inline={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};inline._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;inline._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else{if(this.options.pedantic){this.rules=inline.pedantic}}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^<a /i.test(cap[0])){this.inLink=true}else{if(this.inLink&&/^<\/a>/i.test(cap[0])){this.inLink=false}}src=src.substring(cap[0].length);out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue
|
||
}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(this.smartypants(cap[0]));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants){return text}return text.replace(/--/g,"\u2014").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1\u2018").replace(/'/g,"\u2019").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1\u201c").replace(/"/g,"\u201d").replace(/\.{3}/g,"\u2026")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i<l;i++){ch=text.charCodeAt(i);if(Math.random()>0.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"<pre><code>"+(escaped?code:escape(code,true))+"\n</code></pre>"}return'<pre><code class="'+this.options.langPrefix+escape(lang,true)+'">'+(escaped?code:escape(code,true))+"\n</code></pre>\n"};Renderer.prototype.blockquote=function(quote){return"<blockquote>\n"+quote+"</blockquote>\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"<h"+level+' id="'+this.options.headerPrefix+raw.toLowerCase().replace(/[^\w]+/g,"-")+'">'+text+"</h"+level+">\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"</"+type+">\n"};Renderer.prototype.listitem=function(text){return"<li>"+text+"</li>\n"};Renderer.prototype.paragraph=function(text){return"<p>"+text+"</p>\n"};Renderer.prototype.table=function(header,body){return"<table>\n"+"<thead>\n"+header+"</thead>\n"+"<tbody>\n"+body+"</tbody>\n"+"</table>\n"};Renderer.prototype.tablerow=function(content){return"<tr>\n"+content+"</tr>\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"</"+type+">\n"};Renderer.prototype.strong=function(text){return"<strong>"+text+"</strong>"};Renderer.prototype.em=function(text){return"<em>"+text+"</em>"};Renderer.prototype.codespan=function(text){return"<code>"+text+"</code>"};Renderer.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"};Renderer.prototype.del=function(text){return"<del>"+text+"</del>"};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0||prot.indexOf("vbscript:")===0){return""}}var out='<a href="'+href+'"';if(title){out+=' title="'+title+'"'}out+=">"+text+"</a>";return out};Renderer.prototype.image=function(href,title,text){var src=typeof M !== 'undefined'?'height="100" data-original':'src';var out='<img '+src+'="'+href+'" alt="'+text+'"';if(title){out+=' title="'+title+'"'}out+=this.options.xhtml?"/>":">";return out};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i<this.token.header.length;i++){flags={header:true,align:this.token.align[i]};cell+=this.renderer.tablecell(this.inline.output(this.token.header[i]),{header:true,align:this.token.align[i]})
|
||
}header+=this.renderer.tablerow(cell);for(i=0;i<this.token.cells.length;i++){row=this.token.cells[i];cell="";for(j=0;j<row.length;j++){cell+=this.renderer.tablecell(this.inline.output(row[j]),{header:false,align:this.token.align[j]})}body+=this.renderer.tablerow(cell)}return this.renderer.table(header,body);case"blockquote_start":var body="";while(this.next().type!=="blockquote_end"){body+=this.tok()}return this.renderer.blockquote(body);case"list_start":var body="",ordered=this.token.ordered;while(this.next().type!=="list_end"){body+=this.tok()}return this.renderer.list(body,ordered);case"list_item_start":var body="";while(this.next().type!=="list_item_end"){body+=this.token.type==="text"?this.parseText():this.tok()}return this.renderer.listitem(body);case"loose_item_start":var body="";while(this.next().type!=="list_item_end"){body+=this.tok()}return this.renderer.listitem(body);case"html":var html=!this.token.pre&&!this.options.pedantic?this.inline.output(this.token.text):this.token.text;return this.renderer.html(html);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}};function escape(html,encode){return html.replace(!encode?/&(?!#?\w+;)/g:/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon"){return":"}if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name){return new RegExp(regex,opt)}val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;i<arguments.length;i++){target=arguments[i];for(key in target){if(Object.prototype.hasOwnProperty.call(target,key)){obj[key]=target[key]}}}return obj}function marked(src,opt,callback){if(callback||typeof opt==="function"){if(!callback){callback=opt;opt=null}opt=merge({},marked.defaults,opt||{});var highlight=opt.highlight,tokens,pending,i=0;try{tokens=Lexer.lex(src,opt)}catch(e){return callback(e)}pending=tokens.length;var done=function(err){if(err){opt.highlight=highlight;return callback(err)}var out;try{out=Parser.parse(tokens,opt)}catch(e){err=e}opt.highlight=highlight;return err?callback(err):callback(null,out)};if(!highlight||highlight.length<3){return done()}delete opt.highlight;if(!pending){return done()}for(;i<tokens.length;i++){(function(token){if(token.type!=="code"){return --pending||done()}return highlight(token.text,token.lang,function(err,code){if(err){return done(err)}if(code==null||code===token.text){return --pending||done()}token.text=code;token.escaped=true;--pending||done()})})(tokens[i])}return}try{if(opt){opt=merge({},marked.defaults,opt)}return Parser.parse(Lexer.lex(src,opt),opt)}catch(e){e.message+="\nPlease report this to https://github.com/chjj/marked.";if((opt||marked.defaults).silent){return"<p>An error occured:</p><pre>"+escape(e.message+"",true)+"</pre>"}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else{if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}}).call(function(){return this||(typeof window!=="undefined"?window:global)}());
|
||
// Copyright (C) 2006 Google Inc.
|
||
//
|
||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||
// you may not use this file except in compliance with the License.
|
||
// You may obtain a copy of the License at
|
||
//
|
||
// http://www.apache.org/licenses/LICENSE-2.0
|
||
//
|
||
// Unless required by applicable law or agreed to in writing, software
|
||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
// See the License for the specific language governing permissions and
|
||
// limitations under the License.
|
||
|
||
var IN_GLOBAL_SCOPE=true;window["PR_SHOULD_USE_CONTINUATION"]=true;var prettyPrintOne;var prettyPrint;(function(){var P=window;var i=["break,continue,do,else,for,if,return,while"];var u=[i,"auto,case,char,const,default,"+"double,enum,extern,float,goto,inline,int,long,register,short,signed,"+"sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,"+"new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,"+"concept,concept_map,const_cast,constexpr,decltype,delegate,"+"dynamic_cast,explicit,export,friend,generic,late_check,"+"mutable,namespace,nullptr,property,reinterpret_cast,static_assert,"+"static_cast,template,typeid,typename,using,virtual,where"];var y=[p,"abstract,assert,boolean,byte,extends,final,finally,implements,import,"+"instanceof,interface,null,native,package,strictfp,super,synchronized,"+"throws,transient"];var U=[y,"as,base,by,checked,decimal,delegate,descending,dynamic,event,"+"fixed,foreach,from,group,implicit,in,internal,into,is,let,"+"lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,"+"sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,"+"var,virtual,where"];var r="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";var x=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,"+"Infinity,NaN"];var s="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";var K=[i,"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"];var g=[i,"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"];var z=[i,"as,assert,const,copy,drop,"+"enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,"+"pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"];var J=[i,"case,done,elif,esac,eval,fi,"+"function,in,local,set,then,until"];var C=[l,U,x,s,K,g,J];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;var E="str";var B="kwd";var j="com";var R="typ";var I="lit";var N="pun";var H="pln";var m="tag";var G="dec";var L="src";var S="atn";var n="atv";var Q="nocode";var O="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<<?=?|>>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(ac){var ag=0;var V=false;var af=false;for(var Y=0,X=ac.length;Y<X;++Y){var ah=ac[Y];if(ah.ignoreCase){af=true}else{if(/[a-z]/i.test(ah.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){V=true;af=false;break}}}var ab={"b":8,"t":9,"n":10,"v":11,"f":12,"r":13};function ae(ak){var aj=ak.charCodeAt(0);if(aj!==92){return aj}var ai=ak.charAt(1);aj=ab[ai];if(aj){return aj}else{if("0"<=ai&&ai<="7"){return parseInt(ak.substring(1),8)}else{if(ai==="u"||ai==="x"){return parseInt(ak.substring(2),16)}else{return ak.charCodeAt(1)}}}}function W(ai){if(ai<32){return(ai<16?"\\x0":"\\x")+ai.toString(16)}var aj=String.fromCharCode(ai);return(aj==="\\"||aj==="-"||aj==="]"||aj==="^")?"\\"+aj:aj}function aa(ao){var at=ao.substring(1,ao.length-1).match(new 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"));var ai=[];var aq=at[0]==="^";var ap=["["];if(aq){ap.push("^")}for(var au=aq?1:0,am=at.length;au<am;++au){var ak=at[au];if(/\\[bdsw]/i.test(ak)){ap.push(ak)}else{var aj=ae(ak);var an;if(au+2<am&&"-"===at[au+1]){an=ae(at[au+2]);au+=2}else{an=aj}ai.push([aj,an]);if(!(an<65||aj>122)){if(!(an<65||aj>90)){ai.push([Math.max(65,aj)|32,Math.min(an,90)|32])}if(!(an<97||aj>122)){ai.push([Math.max(97,aj)&~32,Math.min(an,122)&~32])}}}}ai.sort(function(ax,aw){return(ax[0]-aw[0])||(aw[1]-ax[1])});var al=[];var ar=[];for(var au=0;au<ai.length;++au){var av=ai[au];if(av[0]<=ar[1]+1){ar[1]=Math.max(ar[1],av[1])}else{al.push(ar=av)}}for(var au=0;au<al.length;++au){var av=al[au];ap.push(W(av[0]));if(av[1]>av[0]){if(av[1]+1>av[0]){ap.push("-")}ap.push(W(av[1]))}}ap.push("]");return ap.join("")}function Z(ao){var am=ao.source.match(new RegExp("(?:"+"\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]"+"|\\\\u[A-Fa-f0-9]{4}"+"|\\\\x[A-Fa-f0-9]{2}"+"|\\\\[0-9]+"+"|\\\\[^ux0-9]"+"|\\(\\?[:!=]"+"|[\\(\\)\\^]"+"|[^\\x5B\\x5C\\(\\)\\^]+"+")","g"));var ak=am.length;var aq=[];for(var an=0,ap=0;an<ak;++an){var aj=am[an];if(aj==="("){++ap}else{if("\\"===aj.charAt(0)){var ai=+aj.substring(1);if(ai){if(ai<=ap){aq[ai]=-1}else{am[an]=W(ai)}}}}}for(var an=1;an<aq.length;++an){if(-1===aq[an]){aq[an]=++ag}}for(var an=0,ap=0;an<ak;++an){var aj=am[an];if(aj==="("){++ap;if(!aq[ap]){am[an]="(?:"}}else{if("\\"===aj.charAt(0)){var ai=+aj.substring(1);if(ai&&ai<=ap){am[an]="\\"+aq[ai]}}}}for(var an=0;an<ak;++an){if("^"===am[an]&&"^"!==am[an+1]){am[an]=""}}if(ao.ignoreCase&&V){for(var an=0;an<ak;++an){var aj=am[an];var al=aj.charAt(0);if(aj.length>=2&&al==="["){am[an]=aa(aj)}else{if(al!=="\\"){am[an]=aj.replace(/[a-zA-Z]/g,function(ar){var at=ar.charCodeAt(0);return"["+String.fromCharCode(at&~32,at|32)+"]"})}}}}return am.join("")}var ad=[];for(var Y=0,X=ac.length;Y<X;++Y){var ah=ac[Y];if(ah.global||ah.multiline){throw new Error(""+ah)}ad.push("(?:"+Z(ah)+")")}return new RegExp(ad.join("|"),af?"gi":"g")}function b(ab,Z){var X=/(?:^|\s)nocode(?:\s|$)/;var ac=[];var aa=0;var Y=[];var W=0;function V(ae){var ad=ae.nodeType;if(ad==1){if(X.test(ae.className)){return}for(var ah=ae.firstChild;ah;ah=ah.nextSibling){V(ah)}var ag=ae.nodeName.toLowerCase();if("br"===ag||"li"===ag){ac[W]="\n";Y[W<<1]=aa++;Y[(W++<<1)|1]=ae}}else{if(ad==3||ad==4){var af=ae.nodeValue;if(af.length){if(!Z){af=af.replace(/[ \t\r\n]+/g," ")}else{af=af.replace(/\r\n?/g,"\n")}ac[W]=af;Y[W<<1]=aa;aa+=af.length;Y[(W++<<1)|1]=ae}}}}V(ab);return{sourceCode:ac.join("").replace(/\n$/,""),spans:Y}}function D(V,X,Z,W){if(!X){return}var Y={sourceCode:X,basePos:V};Z(Y);W.push.apply(W,Y.decorations)}var v=/\S/;function o(V){var Y=undefined;for(var X=V.firstChild;X;X=X.nextSibling){var W=X.nodeType;Y=(W===1)?(Y?V:X):(W===3)?(v.test(X.nodeValue)?V:Y):Y}return Y===V?undefined:Y}function f(X,W){var V={};var Y;(function(){var ag=X.concat(W);var ak=[];var aj={};for(var ae=0,ac=ag.length;ae<ac;++ae){var ab=ag[ae];var af=ab[3];if(af){for(var ah=af.length;--ah>=0;){V[af.charAt(ah)]=ab}}var ai=ab[1];var ad=""+ai;if(!aj.hasOwnProperty(ad)){ak.push(ai);aj[ad]=null}}ak.push(/[\0-\uffff]/);Y=k(ak)})();var aa=W.length;var Z=function(ak){var ac=ak.sourceCode,ab=ak.basePos;var ag=[ab,H];var ai=0;var aq=ac.match(Y)||[];var am={};for(var ah=0,au=aq.length;ah<au;++ah){var aj=aq[ah];var at=am[aj];var al=void 0;var ap;if(typeof at==="string"){ap=false}else{var ad=V[aj.charAt(0)];if(ad){al=aj.match(ad[1]);at=ad[0]}else{for(var ar=0;ar<aa;++ar){ad=W[ar];al=aj.match(ad[1]);if(al){at=ad[0];break}}if(!al){at=H}}ap=at.length>=5&&"lang-"===at.substring(0,5);if(ap&&!(al&&typeof al[1]==="string")){ap=false;at=L}if(!ap){am[aj]=at}}var ae=ai;ai+=aj.length;if(!ap){ag.push(ab+ae,at)}else{var ao=al[1];var an=aj.indexOf(ao);var af=an+ao.length;if(al[2]){af=aj.length-al[2].length;an=af-ao.length}var av=at.substring(5);D(ab+ae,aj.substring(0,an),Z,ag);D(ab+ae+an,ao,q(av,ao),ag);D(ab+ae+af,aj.substring(af),Z,ag)}}ak.decorations=ag};return Z}function h(af){var X=[],ab=[];if(af["tripleQuotedStrings"]){X.push([E,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(af["multiLineStrings"]){X.push([E,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{X.push([E,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(af["verbatimStrings"]){ab.push([E,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var ad=af["hashComments"];if(ad){if(af["cStyleComments"]){if(ad>1){X.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{X.push([j,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}ab.push([E,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])}else{X.push([j,/^#[^\r\n]*/,null,"#"])}}if(af["cStyleComments"]){ab.push([j,/^\/\/[^\r\n]*/,null]);ab.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}var W=af["regexLiterals"];if(W){var Y=W>1?"":"\n\r";var aa=Y?".":"[\\S\\s]";var Z=("/(?=[^/*"+Y+"])"+"(?:[^/\\x5B\\x5C"+Y+"]"+"|\\x5C"+aa+"|\\x5B(?:[^\\x5C\\x5D"+Y+"]"+"|\\x5C"+aa+")*(?:\\x5D|$))+"+"/");ab.push(["lang-regex",RegExp("^"+O+"("+Z+")")])}var ae=af["types"];if(ae){ab.push([R,ae])}var ac=(""+af["keywords"]).replace(/^ | $/g,"");if(ac.length){ab.push([B,new RegExp("^(?:"+ac.replace(/[\s,]+/g,"|")+")\\b"),null])}X.push([H,/^\s+/,null," \r\n\t\xA0"]);var V="^.[^\\s\\w.$@'\"`/\\\\]*";if(af["regexLiterals"]){V+="(?!s*/)"}ab.push([I,/^@[a-z_$][a-z_$@0-9]*/i,null],[R,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[H,/^[a-z_$][a-z_$@0-9]*/i,null],[I,new RegExp("^(?:"+"0x[a-f0-9]+"+"|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)"+"(?:e[+\\-]?\\d+)?"+")"+"[a-z]*","i"),null,"0123456789"],[H,/^\\[\s\S]?/,null],[N,new RegExp(V),null]);return f(X,ab)}var M=h({"keywords":C,"hashComments":true,"cStyleComments":true,"multiLineStrings":true,"regexLiterals":true});function T(X,ai,ab){var W=/(?:^|\s)nocode(?:\s|$)/;var ad=/\r\n?|\n/;var ae=X.ownerDocument;var ah=ae.createElement("li");while(X.firstChild){ah.appendChild(X.firstChild)}var Y=[ah];function ag(ao){var an=ao.nodeType;if(an==1&&!W.test(ao.className)){if("br"===ao.nodeName){af(ao);if(ao.parentNode){ao.parentNode.removeChild(ao)}}else{for(var aq=ao.firstChild;aq;aq=aq.nextSibling){ag(aq)}}}else{if((an==3||an==4)&&ab){var ap=ao.nodeValue;var al=ap.match(ad);if(al){var ak=ap.substring(0,al.index);ao.nodeValue=ak;var aj=ap.substring(al.index+al[0].length);if(aj){var am=ao.parentNode;am.insertBefore(ae.createTextNode(aj),ao.nextSibling)}af(ao);if(!ak){ao.parentNode.removeChild(ao)}}}}}function af(am){while(!am.nextSibling){am=am.parentNode;if(!am){return}}function ak(an,au){var at=au?an.cloneNode(false):an;var aq=an.parentNode;if(aq){var ar=ak(aq,1);var ap=an.nextSibling;ar.appendChild(at);for(var ao=ap;ao;ao=ap){ap=ao.nextSibling;ar.appendChild(ao)}}return at}var aj=ak(am.nextSibling,0);for(var al;(al=aj.parentNode)&&al.nodeType===1;){aj=al}Y.push(aj)}for(var aa=0;aa<Y.length;++aa){ag(Y[aa])}if(ai===(ai|0)){Y[0].setAttribute("value",ai)}var ac=ae.createElement("ol");ac.className="linenums";var Z=Math.max(0,((ai-1))|0)||0;for(var aa=0,V=Y.length;aa<V;++aa){ah=Y[aa];ah.className="L"+((aa+Z)%10);if(!ah.firstChild){ah.appendChild(ae.createTextNode("\xA0"))}ac.appendChild(ah)}X.appendChild(ac)}function F(ag){var Y=/\bMSIE\s(\d+)/.exec(navigator.userAgent);Y=Y&&+Y[1]<=8;var ap=/\n/g;var ao=ag.sourceCode;var aq=ao.length;var Z=0;var ae=ag.spans;var W=ae.length;var ak=0;var ab=ag.decorations;var ac=ab.length;var ad=0;ab[ac]=aq;var aw,au;for(au=aw=0;au<ac;){if(ab[au]!==ab[au+2]){ab[aw++]=ab[au++];ab[aw++]=ab[au++]}else{au+=2}}ac=aw;for(au=aw=0;au<ac;){var ax=ab[au];var af=ab[au+1];var aa=au+2;while(aa+2<=ac&&ab[aa+1]===af){aa+=2}ab[aw++]=ax;ab[aw++]=af;au=aa}ac=ab.length=aw;var av=ag.sourceNode;var al;if(av){al=av.style.display;av.style.display="none"}try{var ai=null;while(ak<W){var aj=ae[ak];var V=ae[ak+2]||aq;var at=ab[ad+2]||aq;var aa=Math.min(V,at);var an=ae[ak+1];var X;if(an.nodeType!==1&&(X=ao.substring(Z,aa))){if(Y){X=X.replace(ap,"\r")}an.nodeValue=X;var am=an.ownerDocument;var ar=am.createElement("span");ar.className=ab[ad+1];var ah=an.parentNode;ah.replaceChild(ar,an);ar.appendChild(an);if(Z<V){ae[ak+1]=an=am.createTextNode(ao.substring(aa,V));ah.insertBefore(an,ar.nextSibling)}}Z=aa;if(Z>=V){ak+=2}if(Z>=at){ad+=2}}}finally{if(av){av.style.display=al}}}var t={};function c(X,Y){for(var V=Y.length;--V>=0;){var W=Y[V];if(!t.hasOwnProperty(W)){t[W]=X}else{if(P["console"]){console["warn"]("cannot override language handler %s",W)}}}}function q(W,V){if(!(W&&t.hasOwnProperty(W))){W=/^\s*</.test(V)?"default-markup":"default-code"}return t[W]}c(M,["default-code"]);c(f([],[[H,/^[^<?]+/],[G,/^<!\w[^>]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[N,/^(?:<[%?]|[%?]>)/],["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"]);c(f([[H,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[S,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[N,/^[=<>\/]+/],["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"]);c(f([],[[n,/^[\s\S]+/]]),["uq.val"]);c(h({"keywords":l,"hashComments":true,"cStyleComments":true,"types":e}),["c","cc","cpp","cxx","cyc","m"]);c(h({"keywords":"null,true,false"}),["json"]);c(h({"keywords":U,"hashComments":true,"cStyleComments":true,"verbatimStrings":true,"types":e}),["cs"]);c(h({"keywords":y,"cStyleComments":true}),["java"]);c(h({"keywords":J,"hashComments":true,"multiLineStrings":true}),["bash","bsh","csh","sh"]);c(h({"keywords":K,"hashComments":true,"multiLineStrings":true,"tripleQuotedStrings":true}),["cv","py","python"]);c(h({"keywords":s,"hashComments":true,"multiLineStrings":true,"regexLiterals":2}),["perl","pl","pm"]);c(h({"keywords":g,"hashComments":true,"multiLineStrings":true,"regexLiterals":true}),["rb","ruby"]);c(h({"keywords":x,"cStyleComments":true,"regexLiterals":true}),["javascript","js"]);c(h({"keywords":r,"hashComments":3,"cStyleComments":true,"multilineStrings":true,"tripleQuotedStrings":true,"regexLiterals":true}),["coffee"]);c(h({"keywords":z,"cStyleComments":true,"multilineStrings":true}),["rc","rs","rust"]);c(f([],[[E,/^[\s\S]+/]]),["regex"]);function d(Y){var X=Y.langExtension;try{var V=b(Y.sourceNode,Y.pre);var W=V.sourceCode;Y.sourceCode=W;Y.spans=V.spans;Y.basePos=0;q(X,W)(Y);F(Y)}catch(Z){if(P["console"]){console["log"](Z&&Z["stack"]||Z)}}}function A(Z,Y,X){var V=document.createElement("div");V.innerHTML="<pre>"+Z+"</pre>";V=V.firstChild;if(X){T(V,X,true)}var W={langExtension:Y,numberLines:X,sourceNode:V,pre:1};d(W);return V.innerHTML}function w(al,ab){var ah=ab||document.body;var ao=ah.ownerDocument||document;function aa(aq){return ah.getElementsByTagName(aq)}var ad=[aa("pre"),aa("code"),aa("xmp")];var ae=[];for(var ak=0;ak<ad.length;++ak){for(var aj=0,ag=ad[ak].length;aj<ag;++aj){ae.push(ad[ak][aj])}}ad=null;var ap=Date;if(!ap["now"]){ap={"now":function(){return +(new Date)}}}var ai=0;var ac;var X=/\blang(?:uage)?-([\w.]+)(?!\S)/;var an=/\bprettyprint\b/;var W=/\bprettyprinted\b/;var Z=/pre|xmp/i;var V=/^code$/i;var Y=/^(?:pre|code|xmp)$/i;var am={};function af(){var ay=(P["PR_SHOULD_USE_CONTINUATION"]?ap["now"]()+250:Infinity);for(;ai<ae.length&&ap["now"]()<ay;ai++){var aA=ae[ai];var aH=am;for(var ax=aA;(ax=ax.previousSibling);){var aE=ax.nodeType;var aF=(aE===7||aE===8)&&ax.nodeValue;if(aF?!/^\??prettify\b/.test(aF):(aE!==3||/\S/.test(ax.nodeValue))){break}if(aF){aH={};aF.replace(/\b(\w+)=([\w:.%+-]+)/g,function(aJ,aI,aK){aH[aI]=aK});break}}var aB=aA.className;if((aH!==am||an.test(aB))&&!W.test(aB)){var aD=false;for(var au=aA.parentNode;au;au=au.parentNode){var aG=au.tagName;if(Y.test(aG)&&au.className&&an.test(au.className)){aD=true;break}}if(!aD){aA.className+=" prettyprinted";var aw=aH["lang"];if(!aw){aw=aB.match(X);var ar;if(!aw&&(ar=o(aA))&&V.test(ar.tagName)){aw=ar.className.match(X)}if(aw){aw=aw[1]}}var av;if(Z.test(aA.tagName)){av=1}else{var at=aA["currentStyle"];var az=ao.defaultView;var aq=(at?at["whiteSpace"]:(az&&az.getComputedStyle)?az.getComputedStyle(aA,null).getPropertyValue("white-space"):0);av=aq&&"pre"===aq.substring(0,3)}var aC=aH["linenums"];if(!(aC=aC==="true"||+aC)){aC=aB.match(/\blinenums\b(?::(\d+))?/);aC=aC?aC[1]&&aC[1].length?+aC[1]:true:false}if(aC){T(aA,aC,av)}ac={langExtension:aw,sourceNode:aA,numberLines:aC,pre:av};d(ac)}}}if(ai<ae.length){setTimeout(af,250)}else{if("function"===typeof al){al()}}}af()}var a=P["PR"]={"createSimpleLexer":f,"registerLangHandler":c,"sourceDecorator":h,"PR_ATTRIB_NAME":S,"PR_ATTRIB_VALUE":n,"PR_COMMENT":j,"PR_DECLARATION":G,"PR_KEYWORD":B,"PR_LITERAL":I,"PR_NOCODE":Q,"PR_PLAIN":H,"PR_PUNCTUATION":N,"PR_SOURCE":L,"PR_STRING":E,"PR_TAG":m,"PR_TYPE":R,"prettyPrintOne":IN_GLOBAL_SCOPE?(P["prettyPrintOne"]=A):(prettyPrintOne=A),"prettyPrint":prettyPrint=IN_GLOBAL_SCOPE?(P["prettyPrint"]=w):(prettyPrint=w)};if(typeof define==="function"&&define["amd"]){define("google-code-prettify",[],function(){return a})}})();
|
||
/*! Editor.md v1.5.0 | editormd.min.js | Open source online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-06-09 */
|
||
!function(e){"use strict";"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?module.exports=e:"function"==typeof define?define.amd||define(["jquery"],e):window.editormd=e()}(function(){"use strict";var e="undefined"!=typeof jQuery?jQuery:Zepto;if("undefined"!=typeof e){var t=function(e,i){return new t.fn.init(e,i)};t.title=t.$name="Editor.md",t.version="1.5.0",t.homePage="https://pandao.github.io/editor.md/",t.classPrefix="editormd-",t.toolbarModes={full:["undo","redo","|","bold","del","italic","quote","ucwords","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","link","reference-link","image","code","preformatted-text","code-block","table","datetime","emoji","html-entities","pagebreak","|","goto-line","watch","preview","fullscreen","clear","search","|","help","info"],simple:["undo","redo","|","bold","del","italic","quote","uppercase","lowercase","|","h1","h2","h3","h4","h5","h6","|","list-ul","list-ol","hr","|","watch","preview","fullscreen","|","help","info"],mini:["undo","redo","|","watch","preview","|","help","info"]},t.defaults={mode:"gfm",name:"",value:"",theme:"",editorTheme:"default",previewTheme:"",markdown:"",appendMarkdown:"",width:"100%",height:"100%",path:"./lib/",pluginPath:"",delay:300,autoLoadModules:!0,watch:!0,placeholder:"Enjoy Markdown! coding now...",gotoLine:!0,codeFold:!1,autoHeight:!1,autoFocus:!0,autoCloseTags:!0,searchReplace:!0,syncScrolling:!0,readOnly:!1,tabSize:4,indentUnit:4,lineNumbers:!0,lineWrapping:!0,autoCloseBrackets:!0,showTrailingSpace:!0,matchBrackets:!0,indentWithTabs:!0,styleSelectedText:!0,matchWordHighlight:!0,styleActiveLine:!0,dialogLockScreen:!0,dialogShowMask:!0,dialogDraggable:!0,dialogMaskBgColor:"#fff",dialogMaskOpacity:.1,fontSize:"13px",saveHTMLToTextarea:!1,disabledKeyMaps:[],onload:function(){},onresize:function(){},onchange:function(){},onwatch:null,onunwatch:null,onpreviewing:function(){},onpreviewed:function(){},onfullscreen:function(){},onfullscreenExit:function(){},onscroll:function(){},onpreviewscroll:function(){},imageUpload:!1,imageFormats:["jpg","jpeg","gif","png","bmp","webp"],imageUploadURL:"",crossDomainUpload:!1,uploadCallbackURL:"",toc:!0,tocm:!1,tocTitle:"",tocDropdown:!1,tocContainer:"",tocStartLevel:1,htmlDecode:!1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0,toolbar:!0,toolbarAutoFixed:!0,toolbarIcons:"full",toolbarTitles:{},toolbarHandlers:{ucwords:function(){return t.toolbarHandlers.ucwords},lowercase:function(){return t.toolbarHandlers.lowercase}},toolbarCustomIcons:{lowercase:'<a href="javascript:;" title="Lowercase" unselectable="on"><i class="fa" name="lowercase" style="font-size:24px;margin-top: -10px;">a</i></a>',ucwords:'<a href="javascript:;" title="ucwords" unselectable="on"><i class="fa" name="ucwords" style="font-size:20px;margin-top: -3px;">Aa</i></a>'},toolbarIconsClass:{undo:"fa-undo",redo:"fa-repeat",bold:"fa-bold",del:"fa-strikethrough",italic:"fa-italic",quote:"fa-quote-left",uppercase:"fa-font",h1:t.classPrefix+"bold",h2:t.classPrefix+"bold",h3:t.classPrefix+"bold",h4:t.classPrefix+"bold",h5:t.classPrefix+"bold",h6:t.classPrefix+"bold","list-ul":"fa-list-ul","list-ol":"fa-list-ol",hr:"fa-minus",link:"fa-link","reference-link":"fa-anchor",image:"fa-picture-o",code:"fa-code","preformatted-text":"fa-file-code-o","code-block":"fa-file-code-o",table:"fa-table",datetime:"fa-clock-o",emoji:"fa-smile-o","html-entities":"fa-copyright",pagebreak:"fa-newspaper-o","goto-line":"fa-terminal",watch:"fa-eye-slash",unwatch:"fa-eye",preview:"fa-desktop",search:"fa-search",fullscreen:"fa-arrows-alt",clear:"fa-eraser",help:"fa-question-circle",info:"fa-info-circle"},toolbarIconTexts:{},lang:{name:"zh-cn",description:"开源在线Markdown编辑器<br/>Open source online Markdown editor.",tocTitle:"目录",toolbar:{undo:"撤销(Ctrl+Z)",redo:"重做(Ctrl+Y)",bold:"粗体",del:"删除线",italic:"斜体",quote:"引用",ucwords:"将每个单词首字母转成大写",uppercase:"将所选转换成大写",lowercase:"将所选转换成小写",h1:"标题1",h2:"标题2",h3:"标题3",h4:"标题4",h5:"标题5",h6:"标题6","list-ul":"无序列表","list-ol":"有序列表",hr:"横线",link:"链接","reference-link":"引用链接",image:"添加图片",code:"行内代码","preformatted-text":"预格式文本 / 代码块(缩进风格)","code-block":"代码块(多语言风格)",table:"添加表格",datetime:"日期时间",emoji:"Emoji表情","html-entities":"HTML实体字符",pagebreak:"插入分页符","goto-line":"跳转到行",watch:"关闭实时预览",unwatch:"开启实时预览",preview:"全窗口预览HTML(按 Shift + ESC还原)",fullscreen:"全屏(按ESC还原)",clear:"清空",search:"搜索",help:"使用帮助",info:"关于"+t.title},buttons:{enter:"确定",cancel:"取消",close:"关闭"},dialog:{link:{title:"添加链接",url:"链接地址",urlTitle:"链接标题",urlEmpty:"错误:请填写链接地址。"},referenceLink:{title:"添加引用链接",name:"引用名称",url:"链接地址",urlId:"链接ID",urlTitle:"链接标题",nameEmpty:"错误:引用链接的名称不能为空。",idEmpty:"错误:请填写引用链接的ID。",urlEmpty:"错误:请填写引用链接的URL地址。"},image:{title:"添加图片",url:"图片地址",link:"图片链接",alt:"图片描述",uploadButton:"本地上传",imageURLEmpty:"错误:图片地址不能为空。",uploadFileEmpty:"错误:上传的图片不能为空。",formatNotAllowed:"错误:只允许上传图片文件,允许上传的图片文件格式有:"},preformattedText:{title:"添加预格式文本或代码块",emptyAlert:"错误:请填写预格式文本或代码的内容。"},codeBlock:{title:"添加代码块",selectLabel:"代码语言:",selectDefaultText:"请选择代码语言",otherLanguage:"其他语言",unselectedLanguageAlert:"错误:请选择代码所属的语言类型。",codeEmptyAlert:"错误:请填写代码内容。"},htmlEntities:{title:"HTML 实体字符"},help:{title:"使用帮助"}}}},t.classNames={tex:t.classPrefix+"tex"},t.dialogZindex=99999,t.$katex=null,t.$marked=null,t.$CodeMirror=null,t.$prettyPrint=null;var i,o;t.prototype=t.fn={state:{watching:!1,loaded:!1,preview:!1,fullscreen:!1},init:function(i,o){o=o||{},"object"==typeof i&&(o=i);var r=this.classPrefix=t.classPrefix,n=this.settings=e.extend(!0,t.defaults,o);i="object"==typeof i?n.id:i;var a=this.editor=e("#"+i);this.id=i,this.lang=n.lang;var s=this.classNames={textarea:{html:r+"html-textarea",markdown:r+"markdown-textarea"}};n.pluginPath=""===n.pluginPath?n.path+"../plugins/":n.pluginPath,this.state.watching=n.watch?!0:!1,a.hasClass("editormd")||a.addClass("editormd"),a.css({width:"number"==typeof n.width?n.width+"px":n.width,height:"number"==typeof n.height?n.height+"px":n.height}),n.autoHeight&&a.css("height","auto");var l=this.markdownTextarea=a.children("textarea");l.length<1&&(a.append("<textarea></textarea>"),l=this.markdownTextarea=a.children("textarea")),l.addClass(s.textarea.markdown).attr("placeholder",n.placeholder),("undefined"==typeof l.attr("name")||""===l.attr("name"))&&l.attr("name",""!==n.name?n.name:i+"-markdown-doc");var c=[n.readOnly?"":'<a href="javascript:;" class="fa fa-close '+r+'preview-close-btn"></a>',n.saveHTMLToTextarea?'<textarea class="'+s.textarea.html+'" name="'+i+'-html-code"></textarea>':"",'<div class="'+r+'preview"><div class="markdown-body '+r+'preview-container"></div></div>','<div class="'+r+'container-mask" style="display:block;"></div>','<div class="'+r+'mask"></div>'].join("\n");return a.append(c).addClass(r+"vertical"),""!==n.theme&&a.addClass(r+"theme-"+n.theme),this.mask=a.children("."+r+"mask"),this.containerMask=a.children("."+r+"container-mask"),""!==n.markdown&&l.val(n.markdown),""!==n.appendMarkdown&&l.val(l.val()+n.appendMarkdown),this.htmlTextarea=a.children("."+s.textarea.html),this.preview=a.children("."+r+"preview"),this.previewContainer=this.preview.children("."+r+"preview-container"),""!==n.previewTheme&&this.preview.addClass(r+"preview-theme-"+n.previewTheme),"function"==typeof define&&define.amd&&("undefined"!=typeof katex&&(t.$katex=katex),n.searchReplace&&!n.readOnly&&(t.loadCSS(n.path+"codemirror/addon/dialog/dialog"),t.loadCSS(n.path+"codemirror/addon/search/matchesonscrollbar"))),"function"==typeof define&&define.amd||!n.autoLoadModules?("undefined"!=typeof CodeMirror&&(t.$CodeMirror=CodeMirror),"undefined"!=typeof marked&&(t.$marked=marked),this.setCodeMirror().setToolbar().loadedDisplay()):this.loadQueues(),this},loadQueues:function(){var e=this,i=this.settings,o=i.path,r=function(){return t.isIE8?void e.loadedDisplay():void(i.flowChart||i.sequenceDiagram?t.loadScript(o+"raphael.min",function(){t.loadScript(o+"underscore.min",function(){!i.flowChart&&i.sequenceDiagram?t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()}):i.flowChart&&!i.sequenceDiagram?t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){e.loadedDisplay()})}):i.flowChart&&i.sequenceDiagram&&t.loadScript(o+"flowchart.min",function(){t.loadScript(o+"jquery.flowchart.min",function(){t.loadScript(o+"sequence-diagram.min",function(){e.loadedDisplay()})})})})}):e.loadedDisplay())};return t.loadCSS(o+"codemirror/codemirror.min"),i.searchReplace&&!i.readOnly&&(t.loadCSS(o+"codemirror/addon/dialog/dialog"),t.loadCSS(o+"codemirror/addon/search/matchesonscrollbar")),i.codeFold&&t.loadCSS(o+"codemirror/addon/fold/foldgutter"),t.loadScript(o+"codemirror/codemirror.min",function(){t.$CodeMirror=CodeMirror,t.loadScript(o+"codemirror/modes.min",function(){t.loadScript(o+"codemirror/addons.min",function(){return e.setCodeMirror(),"gfm"!==i.mode&&"markdown"!==i.mode?(e.loadedDisplay(),!1):(e.setToolbar(),void t.loadScript(o+"marked.min",function(){t.$marked=marked,i.previewCodeHighlight?t.loadScript(o+"prettify.min",function(){r()}):r()}))})})}),this},setTheme:function(e){var t=this.editor,i=this.settings.theme,o=this.classPrefix+"theme-";return t.removeClass(o+i).addClass(o+e),this.settings.theme=e,this},setEditorTheme:function(e){var i=this.settings;return i.editorTheme=e,"default"!==e&&t.loadCSS(i.path+"codemirror/theme/"+i.editorTheme),this.cm.setOption("theme",e),this},setCodeMirrorTheme:function(e){return this.setEditorTheme(e),this},setPreviewTheme:function(e){var t=this.preview,i=this.settings.previewTheme,o=this.classPrefix+"preview-theme-";return t.removeClass(o+i).addClass(o+e),this.settings.previewTheme=e,this},setCodeMirror:function(){var e=this.settings,i=this.editor;"default"!==e.editorTheme&&t.loadCSS(e.path+"codemirror/theme/"+e.editorTheme);var o={mode:e.mode,theme:e.editorTheme,tabSize:e.tabSize,dragDrop:!1,autofocus:e.autoFocus,autoCloseTags:e.autoCloseTags,readOnly:e.readOnly?"nocursor":!1,indentUnit:e.indentUnit,lineNumbers:e.lineNumbers,lineWrapping:e.lineWrapping,extraKeys:{"Ctrl-Q":function(e){e.foldCode(e.getCursor())}},foldGutter:e.codeFold,gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],matchBrackets:e.matchBrackets,indentWithTabs:e.indentWithTabs,styleActiveLine:e.styleActiveLine,styleSelectedText:e.styleSelectedText,autoCloseBrackets:e.autoCloseBrackets,showTrailingSpace:e.showTrailingSpace,highlightSelectionMatches:e.matchWordHighlight?{showToken:"onselected"===e.matchWordHighlight?!1:/\w/}:!1};return this.codeEditor=this.cm=t.$CodeMirror.fromTextArea(this.markdownTextarea[0],o),this.codeMirror=this.cmElement=i.children(".CodeMirror"),""!==e.value&&this.cm.setValue(e.value),this.codeMirror.css({fontSize:e.fontSize,width:e.watch?"50%":"100%"}),e.autoHeight&&(this.codeMirror.css("height","auto"),this.cm.setOption("viewportMargin",1/0)),e.lineNumbers||this.codeMirror.find(".CodeMirror-gutters").css("border-right","none"),this},getCodeMirrorOption:function(e){return this.cm.getOption(e)},setCodeMirrorOption:function(e,t){return this.cm.setOption(e,t),this},addKeyMap:function(e,t){return this.cm.addKeyMap(e,t),this},removeKeyMap:function(e){return this.cm.removeKeyMap(e),this},gotoLine:function(t){var i=this.settings;if(!i.gotoLine)return this;var o=this.cm,r=(this.editor,o.lineCount()),n=this.preview;if("string"==typeof t&&("last"===t&&(t=r),"first"===t&&(t=1)),"number"!=typeof t)return alert("Error: The line number must be an integer."),this;if(t=parseInt(t)-1,t>r)return alert("Error: The line number range 1-"+r),this;o.setCursor({line:t,ch:0});var a=o.getScrollInfo(),s=a.clientHeight,l=o.charCoords({line:t,ch:0},"local");if(o.scrollTo(null,(l.top+l.bottom-s)/2),i.watch){var c=this.codeMirror.find(".CodeMirror-scroll")[0],h=e(c).height(),d=c.scrollTop,u=d/c.scrollHeight;n.scrollTop(0===d?0:d+h>=c.scrollHeight-16?n[0].scrollHeight:n[0].scrollHeight*u)}return o.focus(),this},extend:function(){return"undefined"!=typeof arguments[1]&&("function"==typeof arguments[1]&&(arguments[1]=e.proxy(arguments[1],this)),this[arguments[0]]=arguments[1]),"object"==typeof arguments[0]&&"undefined"==typeof arguments[0].length&&e.extend(!0,this,arguments[0]),this},set:function(t,i){return"undefined"!=typeof i&&"function"==typeof i&&(i=e.proxy(i,this)),this[t]=i,this},config:function(t,i){var o=this.settings;return"object"==typeof t&&(o=e.extend(!0,o,t)),"string"==typeof t&&(o[t]=i),this.settings=o,this.recreate(),this},on:function(t,i){var o=this.settings;return"undefined"!=typeof o["on"+t]&&(o["on"+t]=e.proxy(i,this)),this},off:function(e){var t=this.settings;return"undefined"!=typeof t["on"+e]&&(t["on"+e]=function(){}),this},showToolbar:function(t){var i=this.settings;return i.readOnly?this:(i.toolbar&&(this.toolbar.length<1||""===this.toolbar.find("."+this.classPrefix+"menu").html())&&this.setToolbar(),i.toolbar=!0,this.toolbar.show(),this.resize(),e.proxy(t||function(){},this)(),this)},hideToolbar:function(t){var i=this.settings;return i.toolbar=!1,this.toolbar.hide(),this.resize(),e.proxy(t||function(){},this)(),this},setToolbarAutoFixed:function(t){var i=this.state,o=this.editor,r=this.toolbar,n=this.settings;"undefined"!=typeof t&&(n.toolbarAutoFixed=t);var a=function(){var t=e(window),i=t.scrollTop();return n.toolbarAutoFixed?void r.css(i-o.offset().top>10&&i<o.height()?{position:"fixed",width:o.width()+"px",left:(t.width()-o.width())/2+"px"}:{position:"absolute",width:"100%",left:0}):!1};return!i.fullscreen&&!i.preview&&n.toolbar&&n.toolbarAutoFixed&&e(window).bind("scroll",a),this},setToolbar:function(){var e=this.settings;if(e.readOnly)return this;var i=this.editor,o=(this.preview,this.classPrefix),r=this.toolbar=i.children("."+o+"toolbar");if(e.toolbar&&r.length<1){var n='<div class="'+o+'toolbar"><div class="'+o+'toolbar-container"><ul class="'+o+'menu"></ul></div></div>';i.append(n),r=this.toolbar=i.children("."+o+"toolbar")}if(!e.toolbar)return r.hide(),this;r.show();for(var a="function"==typeof e.toolbarIcons?e.toolbarIcons():"string"==typeof e.toolbarIcons?t.toolbarModes[e.toolbarIcons]:e.toolbarIcons,s=r.find("."+this.classPrefix+"menu"),l="",c=!1,h=0,d=a.length;d>h;h++){var u=a[h];if("||"===u)c=!0;else if("|"===u)l+='<li class="divider" unselectable="on">|</li>';else{var f=/h(\d)/.test(u),g=u;"watch"!==u||e.watch||(g="unwatch");var p=e.lang.toolbar[g],m=e.toolbarIconTexts[g],w=e.toolbarIconsClass[g];p="undefined"==typeof p?"":p,m="undefined"==typeof m?"":m,w="undefined"==typeof w?"":w;var v=c?'<li class="pull-right">':"<li>";"undefined"!=typeof e.toolbarCustomIcons[u]&&"function"!=typeof e.toolbarCustomIcons[u]?v+=e.toolbarCustomIcons[u]:(v+='<a href="javascript:;" title="'+p+'" unselectable="on">',v+='<i class="fa '+w+'" name="'+u+'" unselectable="on">'+(f?u.toUpperCase():""===w?m:"")+"</i>",v+="</a>"),v+="</li>",l=c?v+l:l+v}}return s.html(l),s.find('[title="Lowercase"]').attr("title",e.lang.toolbar.lowercase),s.find('[title="ucwords"]').attr("title",e.lang.toolbar.ucwords),this.setToolbarHandler(),this.setToolbarAutoFixed(),this},dialogLockScreen:function(){return e.proxy(t.dialogLockScreen,this)(),this},dialogShowMask:function(i){return e.proxy(t.dialogShowMask,this)(i),this},getToolbarHandles:function(e){var i=this.toolbarHandlers=t.toolbarHandlers;return e&&"undefined"!=typeof toolbarIconHandlers[e]?i[e]:i},setToolbarHandler:function(){var i=this,o=this.settings;if(!o.toolbar||o.readOnly)return this;var r=this.toolbar,n=this.cm,a=this.classPrefix,s=this.toolbarIcons=r.find("."+a+"menu > li > a"),l=this.getToolbarHandles();return s.bind(t.mouseOrTouch("click","touchend"),function(t){var r=e(this).children(".fa"),a=r.attr("name"),s=n.getCursor(),c=n.getSelection();return""!==a?(i.activeIcon=r,"undefined"!=typeof l[a]?e.proxy(l[a],i)(n):"undefined"!=typeof o.toolbarHandlers[a]&&e.proxy(o.toolbarHandlers[a],i)(n,r,s,c),"link"!==a&&"reference-link"!==a&&"image"!==a&&"code-block"!==a&&"preformatted-text"!==a&&"watch"!==a&&"preview"!==a&&"search"!==a&&"fullscreen"!==a&&"info"!==a&&n.focus(),!1):void 0}),this},createDialog:function(i){return e.proxy(t.createDialog,this)(i)},createInfoDialog:function(){var e=this,i=this.editor,o=this.classPrefix,r=['<div class="'+o+"dialog "+o+'dialog-info" style="">','<div class="'+o+'dialog-container">','<h1><i class="editormd-logo editormd-logo-lg editormd-logo-color"></i> '+t.title+"<small>v"+t.version+"</small></h1>","<p>"+this.lang.description+"</p>",'<p style="margin: 10px 0 20px 0;"><a href="'+t.homePage+'" target="_blank">'+t.homePage+' <i class="fa fa-external-link"></i></a></p>','<p style="font-size: 0.85em;">Copyright © 2015 <a href="https://github.com/pandao" target="_blank" class="hover-link">Pandao</a>, The <a href="https://github.com/pandao/editor.md/blob/master/LICENSE" target="_blank" class="hover-link">MIT</a> License.</p>',"</div>",'<a href="javascript:;" class="fa fa-close '+o+'dialog-close"></a>',"</div>"].join("\n");i.append(r);var n=this.infoDialog=i.children("."+o+"dialog-info");return n.find("."+o+"dialog-close").bind(t.mouseOrTouch("click","touchend"),function(){e.hideInfoDialog()}),n.css("border",t.isIE8?"1px solid #ddd":"").css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},infoDialogPosition:function(){var t=this.infoDialog,i=function(){t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"})};return i(),e(window).resize(i),this},showInfoDialog:function(){e("html,body").css("overflow-x","hidden");var i=this.editor,o=this.settings,r=this.infoDialog=i.children("."+this.classPrefix+"dialog-info");return r.length<1&&this.createInfoDialog(),this.lockScreen(!0),this.mask.css({opacity:o.dialogMaskOpacity,backgroundColor:o.dialogMaskBgColor}).show(),r.css("z-index",t.dialogZindex).show(),this.infoDialogPosition(),this},hideInfoDialog:function(){return e("html,body").css("overflow-x",""),this.infoDialog.hide(),this.mask.hide(),this.lockScreen(!1),this},lockScreen:function(e){return t.lockScreen(e),this.resize(),this},recreate:function(){var e=this.editor,t=this.settings;return this.codeMirror.remove(),this.setCodeMirror(),t.readOnly||(e.find(".editormd-dialog").length>0&&e.find(".editormd-dialog").remove(),t.toolbar&&(this.getToolbarHandles(),this.setToolbar())),this.loadedDisplay(!0),this},previewCodeHighlight:function(){var e=this.settings,t=this.previewContainer;return e.previewCodeHighlight&&(t.find("pre").addClass("prettyprint linenums"),"undefined"!=typeof prettyPrint&&prettyPrint()),this},katexRender:function(){return null===i?this:(this.previewContainer.find("."+t.classNames.tex).each(function(){var i=e(this);t.$katex.render(i.text(),i[0]),i.find(".katex").css("font-size","1.6em")}),this)},flowChartAndSequenceDiagramRender:function(){var i=this,r=this.settings,n=this.previewContainer;if(t.isIE8)return this;if(r.flowChart){if(null===o)return this;n.find(".flowchart").flowChart()}r.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"});var a=i.preview,s=i.codeMirror,l=s.find(".CodeMirror-scroll"),c=l.height(),h=l.scrollTop(),d=h/l[0].scrollHeight,u=0;a.find(".markdown-toc-list").each(function(){u+=e(this).height()});var f=a.find(".editormd-toc-menu").height();return f=f?f:0,a.scrollTop(0===h?0:h+c>=l[0].scrollHeight-16?a[0].scrollHeight:(a[0].scrollHeight+u+f)*d),this},registerKeyMaps:function(i){var o=this,r=this.cm,n=this.settings,a=t.toolbarHandlers,s=n.disabledKeyMaps;if(i=i||null){for(var l in i)if(e.inArray(l,s)<0){var c={};c[l]=i[l],r.addKeyMap(i)}}else{for(var h in t.keyMaps){var d=t.keyMaps[h],u="string"==typeof d?e.proxy(a[d],o):e.proxy(d,o);if(e.inArray(h,["F9","F10","F11"])<0&&e.inArray(h,s)<0){var f={};f[h]=u,r.addKeyMap(f)}}e(window).keydown(function(t){var i={120:"F9",121:"F10",122:"F11"};if(e.inArray(i[t.keyCode],s)<0)switch(t.keyCode){case 120:return e.proxy(a.watch,o)(),!1;case 121:return e.proxy(a.preview,o)(),!1;case 122:return e.proxy(a.fullscreen,o)(),!1}})}return this},bindScrollEvent:function(){var i=this,o=this.preview,r=this.settings,n=this.codeMirror,a=t.mouseOrTouch;if(!r.syncScrolling)return this;var s=function(){n.find(".CodeMirror-scroll").bind(a("scroll","touchmove"),function(t){var n=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=0;o.find(".markdown-toc-list").each(function(){l+=e(this).height()});var c=o.find(".editormd-toc-menu").height();c=c?c:0,o.scrollTop(0===a?0:a+n>=e(this)[0].scrollHeight-16?o[0].scrollHeight:(o[0].scrollHeight+l+c)*s),e.proxy(r.onscroll,i)(t)})},l=function(){n.find(".CodeMirror-scroll").unbind(a("scroll","touchmove"))},c=function(){o.bind(a("scroll","touchmove"),function(t){var o=e(this).height(),a=e(this).scrollTop(),s=a/e(this)[0].scrollHeight,l=n.find(".CodeMirror-scroll");l.scrollTop(0===a?0:a+o>=e(this)[0].scrollHeight?l[0].scrollHeight:l[0].scrollHeight*s),e.proxy(r.onpreviewscroll,i)(t)})},h=function(){o.unbind(a("scroll","touchmove"))};return n.bind({mouseover:s,mouseout:l,touchstart:s,touchend:l}),"single"===r.syncScrolling?this:(o.bind({mouseover:c,mouseout:h,touchstart:c,touchend:h}),this)},bindChangeEvent:function(){var e=this,t=this.cm,o=this.settings;return o.syncScrolling?(t.on("change",function(t,r){o.watch&&e.previewContainer.css("padding",o.autoHeight?"20px 20px 50px 40px":"20px"),i=setTimeout(function(){clearTimeout(i),e.save(),i=null},o.delay)}),this):this},loadedDisplay:function(t){t=t||!1;var i=this,o=this.editor,r=this.preview,n=this.settings;return this.containerMask.hide(),this.save(),n.watch&&r.show(),o.data("oldWidth",o.width()).data("oldHeight",o.height()),this.resize(),this.registerKeyMaps(),e(window).resize(function(){i.resize()}),this.bindScrollEvent().bindChangeEvent(),t||e.proxy(n.onload,this)(),this.state.loaded=!0,this},width:function(e){return this.editor.css("width","number"==typeof e?e+"px":e),this.resize(),this},height:function(e){return this.editor.css("height","number"==typeof e?e+"px":e),this.resize(),this},resize:function(t,i){t=t||null,i=i||null;var o=this.state,r=this.editor,n=this.preview,a=this.toolbar,s=this.settings,l=this.codeMirror;if(t&&r.css("width","number"==typeof t?t+"px":t),!s.autoHeight||o.fullscreen||o.preview?(i&&r.css("height","number"==typeof i?i+"px":i),o.fullscreen&&r.height(e(window).height()),s.toolbar&&!s.readOnly?l.css("margin-top",a.height()+1).height(r.height()-a.height()):l.css("margin-top",0).height(r.height())):(r.css("height","auto"),l.css("height","auto")),s.watch)if(l.width(r.width()/2),n.width(o.preview?r.width():r.width()/2),this.previewContainer.css("padding",s.autoHeight?"20px 20px 50px 40px":"20px"),s.toolbar&&!s.readOnly?n.css("top",a.height()+1):n.css("top",0),!s.autoHeight||o.fullscreen||o.preview){var c=s.toolbar&&!s.readOnly?r.height()-a.height():r.height();n.height(c)}else n.height("");else l.width(r.width()),n.hide();return o.loaded&&e.proxy(s.onresize,this)(),this},save:function(){if(null===i)return this;var r=this,n=this.state,a=this.settings,s=this.cm,l=s.getValue(),c=this.previewContainer;if("gfm"!==a.mode&&"markdown"!==a.mode)return this.markdownTextarea.val(l),this;var h=t.$marked,d=this.markdownToC=[],u=this.markedRendererOptions={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,pageBreak:a.pageBreak,taskList:a.taskList,emoji:a.emoji,tex:a.tex,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},f=this.markedOptions={renderer:t.markedRenderer(d,u),gfm:!0,tables:!0,breaks:!0,pedantic:!1,sanitize:a.htmlDecode?!1:!0,smartLists:!0,smartypants:!0};h.setOptions(f);var g=t.$marked(l,f);if(g=t.filterHTMLTags(g,a.htmlDecode),this.markdownTextarea.text(l),s.save(),a.saveHTMLToTextarea&&this.htmlTextarea.text(g),a.watch||!a.watch&&n.preview){if(c.html(g),this.previewCodeHighlight(),a.toc){var p=""===a.tocContainer?c:e(a.tocContainer),m=p.find("."+this.classPrefix+"toc-menu");p.attr("previewContainer",""===a.tocContainer?"true":"false"),""!==a.tocContainer&&m.length>0&&m.remove(),t.markdownToCRenderer(d,p,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||p.find("."+this.classPrefix+"toc-menu").length>0)&&t.tocDropdownMenu(p,""!==a.tocTitle?a.tocTitle:this.lang.tocTitle),""!==a.tocContainer&&c.find(".markdown-toc").css("border","none")}a.tex&&(!t.kaTeXLoaded&&a.autoLoadModules?t.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,r.katexRender()}):(t.$katex=katex,this.katexRender())),(a.flowChart||a.sequenceDiagram)&&(o=setTimeout(function(){clearTimeout(o),r.flowChartAndSequenceDiagramRender(),o=null},10)),n.loaded&&e.proxy(a.onchange,this)()}return this},focus:function(){return this.cm.focus(),this},setCursor:function(e){return this.cm.setCursor(e),this},getCursor:function(){return this.cm.getCursor()},setSelection:function(e,t){return this.cm.setSelection(e,t),this},getSelection:function(){return this.cm.getSelection()},setSelections:function(e){return this.cm.setSelections(e),this},getSelections:function(){return this.cm.getSelections()},replaceSelection:function(e){return this.cm.replaceSelection(e),this},insertValue:function(e){return this.replaceSelection(e),this},appendMarkdown:function(e){var t=(this.settings,this.cm);return t.setValue(t.getValue()+e),this},setMarkdown:function(e){return this.cm.setValue(e||this.settings.markdown),this},getMarkdown:function(){return this.cm.getValue()},getValue:function(){return this.cm.getValue()},setValue:function(e){return this.cm.setValue(e),this},clear:function(){return this.cm.setValue(""),this},getHTML:function(){return this.settings.saveHTMLToTextarea?this.htmlTextarea.val():(alert("Error: settings.saveHTMLToTextarea == false"),!1)},getTextareaSavedHTML:function(){return this.getHTML()},getPreviewedHTML:function(){return this.settings.watch?this.previewContainer.html():(alert("Error: settings.watch == false"),!1)},watch:function(t){var o=this.settings;if(e.inArray(o.mode,["gfm","markdown"])<0)return this;if(this.state.watching=o.watch=!0,this.preview.show(),this.toolbar){var r=o.toolbarIconsClass.watch,n=o.toolbarIconsClass.unwatch,a=this.toolbar.find(".fa[name=watch]");a.parent().attr("title",o.lang.toolbar.watch),a.removeClass(n).addClass(r)}return this.codeMirror.css("border-right","1px solid #ddd").width(this.editor.width()/2),i=0,this.save().resize(),o.onwatch||(o.onwatch=t||function(){}),e.proxy(o.onwatch,this)(),this},unwatch:function(t){var i=this.settings;if(this.state.watching=i.watch=!1,this.preview.hide(),this.toolbar){var o=i.toolbarIconsClass.watch,r=i.toolbarIconsClass.unwatch,n=this.toolbar.find(".fa[name=watch]");n.parent().attr("title",i.lang.toolbar.unwatch),n.removeClass(o).addClass(r)}return this.codeMirror.css("border-right","none").width(this.editor.width()),this.resize(),i.onunwatch||(i.onunwatch=t||function(){}),e.proxy(i.onunwatch,this)(),this},show:function(t){t=t||function(){};var i=this;return this.editor.show(0,function(){e.proxy(t,i)()}),this},hide:function(t){t=t||function(){};var i=this;return this.editor.hide(0,function(){e.proxy(t,i)()}),this},previewing:function(){var i=this,o=this.editor,r=this.preview,n=this.toolbar,a=this.settings,s=this.codeMirror,l=this.previewContainer;if(e.inArray(a.mode,["gfm","markdown"])<0)return this;a.toolbar&&n&&(n.toggle(),n.find(".fa[name=preview]").toggleClass("active")),s.toggle();var c=function(e){e.shiftKey&&27===e.keyCode&&i.previewed()};"none"===s.css("display")?(this.state.preview=!0,this.state.fullscreen&&r.css("background","#fff"),o.find("."+this.classPrefix+"preview-close-btn").show().bind(t.mouseOrTouch("click","touchend"),function(){i.previewed()}),a.watch?l.css("padding",""):this.save(),l.addClass(this.classPrefix+"preview-active"),r.show().css({position:"",top:0,width:o.width(),height:a.autoHeight&&!this.state.fullscreen?"auto":o.height()}),this.state.loaded&&e.proxy(a.onpreviewing,this)(),e(window).bind("keyup",c)):(e(window).unbind("keyup",c),this.previewed())},previewed:function(){var i=this.editor,o=this.preview,r=this.toolbar,n=this.settings,a=this.previewContainer,s=i.find("."+this.classPrefix+"preview-close-btn");return this.state.preview=!1,this.codeMirror.show(),n.toolbar&&r.show(),o[n.watch?"show":"hide"](),s.hide().unbind(t.mouseOrTouch("click","touchend")),a.removeClass(this.classPrefix+"preview-active"),n.watch&&a.css("padding","20px"),o.css({background:null,position:"absolute",width:i.width()/2,height:n.autoHeight&&!this.state.fullscreen?"auto":i.height()-r.height(),top:n.toolbar?r.height():0}),this.state.loaded&&e.proxy(n.onpreviewed,this)(),this},fullscreen:function(){var t=this,i=this.state,o=this.editor,r=(this.preview,this.toolbar),n=this.settings,a=this.classPrefix+"fullscreen";r&&r.find(".fa[name=fullscreen]").parent().toggleClass("active");var s=function(e){e.shiftKey||27!==e.keyCode||i.fullscreen&&t.fullscreenExit()};return o.hasClass(a)?(e(window).unbind("keyup",s),this.fullscreenExit()):(i.fullscreen=!0,e("html,body").css("overflow","hidden"),o.css({width:e(window).width(),height:e(window).height()}).addClass(a),this.resize(),e.proxy(n.onfullscreen,this)(),e(window).bind("keyup",s)),this},fullscreenExit:function(){var t=this.editor,i=this.settings,o=this.toolbar,r=this.classPrefix+"fullscreen";return this.state.fullscreen=!1,o&&o.find(".fa[name=fullscreen]").parent().removeClass("active"),e("html,body").css("overflow",""),t.css({width:t.data("oldWidth"),height:t.data("oldHeight")}).removeClass(r),this.resize(),e.proxy(i.onfullscreenExit,this)(),this},executePlugin:function(i,o){var r=this,n=this.cm,a=this.settings;return o=a.pluginPath+o,"function"==typeof define?"undefined"==typeof this[i]?(alert("Error: "+i+" plugin is not found, you are not load this plugin."),this):(this[i](n),this):(e.inArray(o,t.loadFiles.plugin)<0?t.loadPlugin(o,function(){t.loadPlugins[i]=r[i],r[i](n)}):e.proxy(t.loadPlugins[i],this)(n),this)},search:function(e){var t=this.settings;return t.searchReplace?(t.readOnly||this.cm.execCommand(e||"find"),this):(alert("Error: settings.searchReplace == false"),this)},searchReplace:function(){return this.search("replace"),this},searchReplaceAll:function(){return this.search("replaceAll"),this}},t.fn.init.prototype=t.fn,t.dialogLockScreen=function(){var t=this.settings||{dialogLockScreen:!0};t.dialogLockScreen&&(e("html,body").css("overflow","hidden"),this.resize())},t.dialogShowMask=function(t){var i=this.editor,o=this.settings||{dialogShowMask:!0};t.css({top:(e(window).height()-t.height())/2+"px",left:(e(window).width()-t.width())/2+"px"}),o.dialogShowMask&&i.children("."+this.classPrefix+"mask").css("z-index",parseInt(t.css("z-index"))-1).show()},t.toolbarHandlers={undo:function(){this.cm.undo()},redo:function(){this.cm.redo()},bold:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("**"+i+"**"),""===i&&e.setCursor(t.line,t.ch+2)},del:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("~~"+i+"~~"),""===i&&e.setCursor(t.line,t.ch+2)},italic:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("*"+i+"*"),""===i&&e.setCursor(t.line,t.ch+1)},quote:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("> "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("> "+i)},ucfirst:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.firstUpperCase(i)),e.setSelections(o)},ucwords:function(){var e=this.cm,i=e.getSelection(),o=e.listSelections();e.replaceSelection(t.wordsFirstUpperCase(i)),e.setSelections(o)},uppercase:function(){var e=this.cm,t=e.getSelection(),i=e.listSelections();e.replaceSelection(t.toUpperCase()),e.setSelections(i)},lowercase:function(){var e=this.cm,t=(e.getCursor(),e.getSelection()),i=e.listSelections();e.replaceSelection(t.toLowerCase()),e.setSelections(i)},h1:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("# "+i),e.setCursor(t.line,t.ch+2)):e.replaceSelection("# "+i)},h2:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),
|
||
e.replaceSelection("## "+i),e.setCursor(t.line,t.ch+3)):e.replaceSelection("## "+i)},h3:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("### "+i),e.setCursor(t.line,t.ch+4)):e.replaceSelection("### "+i)},h4:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("#### "+i),e.setCursor(t.line,t.ch+5)):e.replaceSelection("#### "+i)},h5:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("##### "+i),e.setCursor(t.line,t.ch+6)):e.replaceSelection("##### "+i)},h6:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();0!==t.ch?(e.setCursor(t.line,0),e.replaceSelection("###### "+i),e.setCursor(t.line,t.ch+7)):e.replaceSelection("###### "+i)},"list-ul":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("- "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":"- "+i[o];e.replaceSelection(i.join("\n"))}},"list-ol":function(){var e=this.cm,t=(e.getCursor(),e.getSelection());if(""===t)e.replaceSelection("1. "+t);else{for(var i=t.split("\n"),o=0,r=i.length;r>o;o++)i[o]=""===i[o]?"":o+1+". "+i[o];e.replaceSelection(i.join("\n"))}},hr:function(){{var e=this.cm,t=e.getCursor();e.getSelection()}e.replaceSelection((0!==t.ch?"\n\n":"\n")+"------------\n\n")},tex:function(){if(!this.settings.tex)return alert("settings.tex === false"),this;var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("$$"+i+"$$"),""===i&&e.setCursor(t.line,t.ch+2)},link:function(){this.executePlugin("linkDialog","link-dialog/link-dialog")},"reference-link":function(){this.executePlugin("referenceLinkDialog","reference-link-dialog/reference-link-dialog")},pagebreak:function(){if(!this.settings.pageBreak)return alert("settings.pageBreak === false"),this;{var e=this.cm;e.getSelection()}e.replaceSelection("\r\n[========]\r\n")},image:function(){this.executePlugin("imageDialog","image-dialog/image-dialog")},code:function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection("`"+i+"`"),""===i&&e.setCursor(t.line,t.ch+1)},"code-block":function(){this.executePlugin("codeBlockDialog","code-block-dialog/code-block-dialog")},"preformatted-text":function(){this.executePlugin("preformattedTextDialog","preformatted-text-dialog/preformatted-text-dialog")},table:function(){this.executePlugin("tableDialog","table-dialog/table-dialog")},datetime:function(){var e=this.cm,i=(e.getSelection(),new Date,this.settings.lang.name),o=t.dateFormat()+" "+t.dateFormat("zh-cn"===i||"zh-tw"===i?"cn-week-day":"week-day");e.replaceSelection(o)},emoji:function(){this.executePlugin("emojiDialog","emoji-dialog/emoji-dialog")},"html-entities":function(){this.executePlugin("htmlEntitiesDialog","html-entities-dialog/html-entities-dialog")},"goto-line":function(){this.executePlugin("gotoLineDialog","goto-line-dialog/goto-line-dialog")},watch:function(){this[this.settings.watch?"unwatch":"watch"]()},preview:function(){this.previewing()},fullscreen:function(){this.fullscreen()},clear:function(){this.clear()},search:function(){this.search()},help:function(){this.executePlugin("helpDialog","help-dialog/help-dialog")},info:function(){this.showInfoDialog()}},t.keyMaps={"Ctrl-1":"h1","Ctrl-2":"h2","Ctrl-3":"h3","Ctrl-4":"h4","Ctrl-5":"h5","Ctrl-6":"h6","Ctrl-B":"bold","Ctrl-D":"datetime","Ctrl-E":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.emoji?(e.replaceSelection(":"+i+":"),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.emoji == false")},"Ctrl-Alt-G":"goto-line","Ctrl-H":"hr","Ctrl-I":"italic","Ctrl-K":"code","Ctrl-L":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection("["+i+"]("+o+")"),""===i&&e.setCursor(t.line,t.ch+1)},"Ctrl-U":"list-ul","Shift-Ctrl-A":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();return this.settings.atLink?(e.replaceSelection("@"+i),void(""===i&&e.setCursor(t.line,t.ch+1))):void alert("Error: settings.atLink == false")},"Shift-Ctrl-C":"code","Shift-Ctrl-Q":"quote","Shift-Ctrl-S":"del","Shift-Ctrl-K":"tex","Shift-Alt-C":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection();e.replaceSelection(["```",i,"```"].join("\n")),""===i&&e.setCursor(t.line,t.ch+3)},"Shift-Ctrl-Alt-C":"code-block","Shift-Ctrl-H":"html-entities","Shift-Alt-H":"help","Shift-Ctrl-E":"emoji","Shift-Ctrl-U":"uppercase","Shift-Alt-U":"ucwords","Shift-Ctrl-Alt-U":"ucfirst","Shift-Alt-L":"lowercase","Shift-Ctrl-I":function(){var e=this.cm,t=e.getCursor(),i=e.getSelection(),o=""===i?"":' "'+i+'"';e.replaceSelection(""),""===i&&e.setCursor(t.line,t.ch+4)},"Shift-Ctrl-Alt-I":"image","Shift-Ctrl-L":"link","Shift-Ctrl-O":"list-ol","Shift-Ctrl-P":"preformatted-text","Shift-Ctrl-T":"table","Shift-Alt-P":"pagebreak",F9:"watch",F10:"preview",F11:"fullscreen"};var r=function(e){return String.prototype.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};t.trim=r;var n=function(e){return e.toLowerCase().replace(/\b(\w)|\s(\w)/g,function(e){return e.toUpperCase()})};t.ucwords=t.wordsFirstUpperCase=n;var a=function(e){return e.toLowerCase().replace(/\b(\w)/,function(e){return e.toUpperCase()})};return t.firstUpperCase=t.ucfirst=a,t.urls={atLinkBase:"https://github.com/"},t.regexs={atLink:/@(\w+)/g,email:/(\w+)@(\w+)\.(\w+)\.?(\w+)?/g,emailLink:/(mailto:)?([\w\.\_]+)@(\w+)\.(\w+)\.?(\w+)?/g,emoji:/:([\w\+-]+):/g,emojiDatetime:/(\d{2}:\d{2}:\d{2})/g,twemoji:/:(tw-([\w]+)-?(\w+)?):/g,fontAwesome:/:(fa-([\w]+)(-(\w+)){0,}):/g,editormdLogo:/:(editormd-logo-?(\w+)?):/g,pageBreak:/^\[[=]{8,}\]$/},t.emoji={path:"http://www.emoji-cheat-sheet.com/graphics/emojis/",ext:".png"},t.twemoji={path:"http://twemoji.maxcdn.com/36x36/",ext:".png"},t.markedRenderer=function(i,o){var n={toc:!0,tocm:!1,tocStartLevel:1,pageBreak:!0,atLink:!0,emailLink:!0,taskList:!1,emoji:!1,tex:!1,flowChart:!1,sequenceDiagram:!1},a=e.extend(n,o||{}),s=t.$marked,l=new s.Renderer;i=i||[];var c=t.regexs,h=c.atLink,d=c.emoji,u=c.email,f=c.emailLink,g=c.twemoji,p=c.fontAwesome,m=c.editormdLogo,w=c.pageBreak;return l.emoji=function(e){e=e.replace(t.regexs.emojiDatetime,function(e){return e.replace(/:/g,":")});var i=e.match(d);if(!i||!a.emoji)return e;for(var o=0,r=i.length;r>o;o++)":+1:"===i[o]&&(i[o]=":\\+1:"),e=e.replace(new RegExp(i[o]),function(e,i){var o=e.match(p),r=e.replace(/:/g,"");if(o)for(var n=0,a=o.length;a>n;n++){var s=o[n].replace(/:/g,"");return'<i class="fa '+s+' fa-emoji" title="'+s.replace("fa-","")+'"></i>'}else{var l=e.match(m),c=e.match(g);if(l)for(var h=0,d=l.length;d>h;h++){var u=l[h].replace(/:/g,"");return'<i class="'+u+'" title="Editor.md logo ('+u+')"></i>'}else{if(!c){var f="+1"===r?"plus1":r;return f="black_large_square"===f?"black_square":f,f="moon"===f?"waxing_gibbous_moon":f,'<img src="'+t.emoji.path+f+t.emoji.ext+'" class="emoji" title=":'+r+':" alt=":'+r+':" />'}for(var w=0,v=c.length;v>w;w++){var k=c[w].replace(/:/g,"").replace("tw-","");return'<img src="'+t.twemoji.path+k+t.twemoji.ext+'" title="twemoji-'+k+'" alt="twemoji-'+k+'" class="emoji twemoji" />'}}}});return e},l.atLink=function(i){return h.test(i)?(a.atLink&&(i=i.replace(u,function(e,t,i,o){return e.replace(/@/g,"_#_@_#_")}),i=i.replace(h,function(e,i){return'<a href="'+t.urls.atLinkBase+i+'" title="@'+i+'" class="at-link">'+e+"</a>"}).replace(/_#_@_#_/g,"@")),a.emailLink&&(i=i.replace(f,function(t,i,o,r,n){return!i&&e.inArray(n,"jpg|jpeg|png|gif|webp|ico|icon|pdf".split("|"))<0?'<a href="mailto:'+t+'">'+t+"</a>":t})),i):i},l.link=function(e,t,i){if(this.options.sanitize){try{var o=decodeURIComponent(unescape(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(r){return""}if(0===o.indexOf("javascript:"))return""}var n='<a href="'+e+'"';return h.test(t)||h.test(i)?(t&&(n+=' title="'+t.replace(/@/g,"@")),n+'">'+i.replace(/@/g,"@")+"</a>"):(t&&(n+=' title="'+t+'"'),n+=">"+i+"</a>")},l.heading=function(e,t,o){var n=e,a=/\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;if(a.test(e)){var s=[];e=e.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);for(var l=0,c=e.length;c>l;l++)s.push(e[l].replace(/\s*href\=\"(.*)\"\s*/g,""));e=s.join(" ")}e=r(e);var h=e.toLowerCase().replace(/[^\w]+/g,"-"),d={text:e,level:t,slug:h},u=/^[\u4e00-\u9fa5]+$/.test(e),f=u?escape(e).replace(/\%/g,""):e.toLowerCase().replace(/[^\w]+/g,"-");i.push(d);var g="<h"+t+' id="h'+t+"-"+this.options.headerPrefix+f+'">';return g+='<a name="'+e+'" class="reference-link"></a>',g+='<span class="header-link octicon octicon-link"></span>',g+=this.atLink(a?this.emoji(n):this.emoji(e)),g+="</h"+t+">"},l.pageBreak=function(e){return w.test(e)&&a.pageBreak&&(e='<hr style="page-break-after:always;" class="page-break editormd-page-break" />'),e},l.paragraph=function(e){var i=/\$\$(.*)\$\$/g.test(e),o=/^\$\$(.*)\$\$$/.test(e),r=o?' class="'+t.classNames.tex+'"':"",n=a.tocm?/^(\[TOC\]|\[TOCM\])$/.test(e):/^\[TOC\]$/.test(e),s=/^\[TOCM\]$/.test(e);e=!o&&i?e.replace(/(\$\$([^\$]*)\$\$)+/g,function(e,i){return'<span class="'+t.classNames.tex+'">'+i.replace(/\$/g,"")+"</span>"}):o?e.replace(/\$/g,""):e;var l='<div class="markdown-toc editormd-markdown-toc">'+e+"</div>";return n?s?'<div class="editormd-toc-menu">'+l+"</div><br/>":l:w.test(e)?this.pageBreak(e):"<p"+r+">"+this.atLink(this.emoji(e))+"</p>\n"},l.code=function(e,i,o){return"seq"===i||"sequence"===i?'<div class="sequence-diagram">'+e+"</div>":"flow"===i?'<div class="flowchart">'+e+"</div>":"math"===i||"latex"===i||"katex"===i?'<p class="'+t.classNames.tex+'">'+e+"</p>":s.Renderer.prototype.code.apply(this,arguments)},l.tablecell=function(e,t){var i=t.header?"th":"td",o=t.align?"<"+i+' style="text-align:'+t.align+'">':"<"+i+">";return o+this.atLink(this.emoji(e))+"</"+i+">\n"},l.listitem=function(e){return a.taskList&&/^\s*\[[x\s]\]\s*/.test(e)?(e=e.replace(/^\s*\[\s\]\s*/,'<input type="checkbox" class="task-list-item-checkbox" /> ').replace(/^\s*\[x\]\s*/,'<input type="checkbox" class="task-list-item-checkbox" checked disabled /> '),'<li style="list-style: none;">'+this.atLink(this.emoji(e))+"</li>"):"<li>"+this.atLink(this.emoji(e))+"</li>"},l},t.markdownToCRenderer=function(e,t,i,o){var r="",n=0,a=this.classPrefix;o=o||1;for(var s=0,l=e.length;l>s;s++){var c=e[s].text,h=e[s].level;o>h||(r+=h>n?"":n>h?new Array(n-h+2).join("</ul></li>"):"</ul></li>",r+='<li><a class="toc-level-'+h+'" href="#'+c+'" level="'+h+'">'+c+"</a><ul>",n=h)}var d=t.find(".markdown-toc");if(d.length<1&&"false"===t.attr("previewContainer")){var u='<div class="markdown-toc '+a+'markdown-toc"></div>';u=i?'<div class="'+a+'toc-menu">'+u+"</div>":u,t.html(u),d=t.find(".markdown-toc")}return i&&d.wrap('<div class="'+a+'toc-menu"></div><br/>'),d.html('<ul class="markdown-toc-list"></ul>').children(".markdown-toc-list").html(r.replace(/\r?\n?\<ul\>\<\/ul\>/g,"")),d},t.tocDropdownMenu=function(t,i){i=i||"Table of Contents";var o=400,r=t.find("."+this.classPrefix+"toc-menu");return r.each(function(){var t=e(this),r=t.children(".markdown-toc"),n='<i class="fa fa-angle-down"></i>',a='<a href="javascript:;" class="toc-menu-btn">'+n+i+"</a>",s=r.children("ul"),l=s.find("li");r.append(a),l.first().before("<li><h1>"+i+" "+n+"</h1></li>"),t.mouseover(function(){s.show(),l.each(function(){var t=e(this),i=t.children("ul");if(""===i.html()&&i.remove(),i.length>0&&""!==i.html()){var r=t.children("a").first();r.children(".fa").length<1&&r.append(e(n).css({"float":"right",paddingTop:"4px"}))}t.mouseover(function(){i.css("z-index",o).show(),o+=1}).mouseleave(function(){i.hide()})})}).mouseleave(function(){s.hide()})}),r},t.filterHTMLTags=function(t,i){if("string"!=typeof t&&(t=new String(t)),"string"!=typeof i)return t;for(var o=i.split("|"),r=o[0].split(","),n=o[1],a=0,s=r.length;s>a;a++){var l=r[a];t=t.replace(new RegExp("<s*"+l+"s*([^>]*)>([^>]*)<s*/"+l+"s*>","igm"),"")}if("undefined"!=typeof n){var c=/\<(\w+)\s*([^\>]*)\>([^\>]*)\<\/(\w+)\>/gi;t="*"===n?t.replace(c,function(e,t,i,o,r){return"<"+t+">"+o+"</"+r+">"}):"on*"===n?t.replace(c,function(t,i,o,r,n){var a=e("<"+i+">"+r+"</"+n+">"),s=e(t)[0].attributes,l={};e.each(s,function(e,t){'"'!==t.nodeName&&(l[t.nodeName]=t.nodeValue)}),e.each(l,function(e){0===e.indexOf("on")&&delete l[e]}),a.attr(l);var c="undefined"!=typeof a[1]?e(a[1]).text():"";return a[0].outerHTML+c}):t.replace(c,function(t,i,o,r){var a=n.split(","),s=e(t);return s.html(r),e.each(a,function(e){s.attr(a[e],null)}),s[0].outerHTML})}return t},t.markdownToHTML=function(i,o){var r={gfm:!0,toc:!0,tocm:!1,tocStartLevel:1,tocTitle:"目录",tocDropdown:!1,tocContainer:"",markdown:"",markdownSourceCode:!1,htmlDecode:!1,autoLoadKaTeX:!0,pageBreak:!0,atLink:!0,emailLink:!0,tex:!1,taskList:!1,emoji:!1,flowChart:!1,sequenceDiagram:!1,previewCodeHighlight:!0};t.$marked=marked;var n=e("#"+i),a=n.settings=e.extend(!0,r,o||{}),s=n.find("textarea");s.length<1&&(n.append("<textarea></textarea>"),s=n.find("textarea"));var l=""===a.markdown?s.val():a.markdown,c=[],h={toc:a.toc,tocm:a.tocm,tocStartLevel:a.tocStartLevel,taskList:a.taskList,emoji:a.emoji,tex:a.tex,pageBreak:a.pageBreak,atLink:a.atLink,emailLink:a.emailLink,flowChart:a.flowChart,sequenceDiagram:a.sequenceDiagram,previewCodeHighlight:a.previewCodeHighlight},d={renderer:t.markedRenderer(c,h),gfm:a.gfm,tables:!0,breaks:!0,pedantic:!1,sanitize:a.htmlDecode?!1:!0,smartLists:!0,smartypants:!0};l=new String(l);var u=marked(l,d);u=t.filterHTMLTags(u,a.htmlDecode),a.markdownSourceCode?s.text(l):s.remove(),n.addClass("markdown-body "+this.classPrefix+"html-preview").append(u);var f=""!==a.tocContainer?e(a.tocContainer):n;if(""!==a.tocContainer&&f.attr("previewContainer",!1),a.toc&&(n.tocContainer=this.markdownToCRenderer(c,f,a.tocDropdown,a.tocStartLevel),(a.tocDropdown||n.find("."+this.classPrefix+"toc-menu").length>0)&&this.tocDropdownMenu(n,a.tocTitle),""!==a.tocContainer&&n.find(".editormd-toc-menu, .editormd-markdown-toc").remove()),a.previewCodeHighlight&&(n.find("pre").addClass("prettyprint linenums"),prettyPrint()),t.isIE8||(a.flowChart&&n.find(".flowchart").flowChart(),a.sequenceDiagram&&n.find(".sequence-diagram").sequenceDiagram({theme:"simple"})),a.tex){var g=function(){n.find("."+t.classNames.tex).each(function(){var t=e(this);katex.render(t.html().replace(/</g,"<").replace(/>/g,">"),t[0]),t.find(".katex").css("font-size","1.6em")})};!a.autoLoadKaTeX||t.$katex||t.kaTeXLoaded?g():this.loadKaTeX(function(){t.$katex=katex,t.kaTeXLoaded=!0,g()})}return n.getMarkdown=function(){return s.val()},n},t.themes=["default","dark"],t.previewThemes=["default","dark"],t.editorThemes=["default","3024-day","3024-night","ambiance","ambiance-mobile","base16-dark","base16-light","blackboard","cobalt","eclipse","elegant","erlang-dark","lesser-dark","mbo","mdn-like","midnight","monokai","neat","neo","night","paraiso-dark","paraiso-light","pastel-on-dark","rubyblue","solarized","the-matrix","tomorrow-night-eighties","twilight","vibrant-ink","xq-dark","xq-light"],t.loadPlugins={},t.loadFiles={js:[],css:[],plugin:[]},t.loadPlugin=function(e,i,o){i=i||function(){},this.loadScript(e,function(){t.loadFiles.plugin.push(e),i()},o)},t.loadCSS=function(e,i,o){o=o||"head",i=i||function(){};var r=document.createElement("link");r.type="text/css",r.rel="stylesheet",r.onload=r.onreadystatechange=function(){t.loadFiles.css.push(e),i()},r.href=e+".css","head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.isIE="Microsoft Internet Explorer"==navigator.appName,t.isIE8=t.isIE&&"8."==navigator.appVersion.match(/8./i),t.loadScript=function(e,i,o){o=o||"head",i=i||function(){};var r=null;r=document.createElement("script"),r.id=e.replace(/[\./]+/g,"-"),r.type="text/javascript",r.src=e+".js",t.isIE8?r.onreadystatechange=function(){r.readyState&&("loaded"===r.readyState||"complete"===r.readyState)&&(r.onreadystatechange=null,t.loadFiles.js.push(e),i())}:r.onload=function(){t.loadFiles.js.push(e),i()},"head"===o?document.getElementsByTagName("head")[0].appendChild(r):document.body.appendChild(r)},t.katexURL={css:"//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min",js:"//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min"},t.kaTeXLoaded=!1,t.loadKaTeX=function(e){t.loadCSS(t.katexURL.css,function(){t.loadScript(t.katexURL.js,e||function(){})})},t.lockScreen=function(t){e("html,body").css("overflow",t?"hidden":"")},t.createDialog=function(i){var o={name:"",width:420,height:240,title:"",drag:!0,closed:!0,content:"",mask:!0,maskStyle:{backgroundColor:"#fff",opacity:.1},lockScreen:!0,footer:!0,buttons:!1};i=e.extend(!0,o,i);var r=this,n=this.editor,a=t.classPrefix,s=(new Date).getTime(),l=""===i.name?a+"dialog-"+s:i.name,c=t.mouseOrTouch,h='<div class="'+a+"dialog "+l+'">';""!==i.title&&(h+='<div class="'+a+'dialog-header"'+(i.drag?' style="cursor: move;"':"")+">",h+='<strong class="'+a+'dialog-title">'+i.title+"</strong>",h+="</div>"),i.closed&&(h+='<a href="javascript:;" class="fa fa-close '+a+'dialog-close"></a>'),h+='<div class="'+a+'dialog-container">'+i.content,(i.footer||"string"==typeof i.footer)&&(h+='<div class="'+a+'dialog-footer">'+("boolean"==typeof i.footer?"":i.footer)+"</div>"),h+="</div>",h+='<div class="'+a+"dialog-mask "+a+'dialog-mask-bg"></div>',h+='<div class="'+a+"dialog-mask "+a+'dialog-mask-con"></div>',h+="</div>",n.append(h);var d=n.find("."+l);d.lockScreen=function(t){return i.lockScreen&&(e("html,body").css("overflow",t?"hidden":""),r.resize()),d},d.showMask=function(){return i.mask&&n.find("."+a+"mask").css(i.maskStyle).css("z-index",t.dialogZindex-1).show(),d},d.hideMask=function(){return i.mask&&n.find("."+a+"mask").hide(),d},d.loading=function(e){var t=d.find("."+a+"dialog-mask");return t[e?"show":"hide"](),d},d.lockScreen(!0).showMask(),d.show().css({zIndex:t.dialogZindex,border:t.isIE8?"1px solid #ddd":"",width:"number"==typeof i.width?i.width+"px":i.width,height:"number"==typeof i.height?i.height+"px":i.height});var u=function(){d.css({top:(e(window).height()-d.height())/2+"px",left:(e(window).width()-d.width())/2+"px"})};if(u(),e(window).resize(u),d.children("."+a+"dialog-close").bind(c("click","touchend"),function(){d.hide().lockScreen(!1).hideMask()}),"object"==typeof i.buttons){var f=d.footer=d.find("."+a+"dialog-footer");for(var g in i.buttons){var p=i.buttons[g],m=a+g+"-btn";f.append('<button class="'+a+"btn "+m+'">'+p[0]+"</button>"),p[1]=e.proxy(p[1],d),f.children("."+m).bind(c("click","touchend"),p[1])}}if(""!==i.title&&i.drag){var w,v,k=d.children("."+a+"dialog-header");i.mask||k.bind(c("click","touchend"),function(){t.dialogZindex+=2,d.css("z-index",t.dialogZindex)}),k.mousedown(function(e){e=e||window.event,w=e.clientX-parseInt(d[0].style.left),v=e.clientY-parseInt(d[0].style.top),document.onmousemove=y});var b=function(e){e.removeClass(a+"user-unselect").off("selectstart")},x=function(e){e.addClass(a+"user-unselect").on("selectstart",function(e){return!1})},y=function(t){t=t||window.event;var i,o,r=parseInt(d[0].style.left),n=parseInt(d[0].style.top);r>=0?r+d.width()<=e(window).width()?i=t.clientX-w:(i=e(window).width()-d.width(),document.onmousemove=null):(i=0,document.onmousemove=null),n>=0?o=t.clientY-v:(o=0,document.onmousemove=null),document.onselectstart=function(){return!1},x(e("body")),x(d),d[0].style.left=i+"px",d[0].style.top=o+"px"};document.onmouseup=function(){b(e("body")),b(d),document.onselectstart=null,document.onmousemove=null},k.touchDraggable=function(){var t=null,i=function(i){var o=i.originalEvent,r=e(this).parent().position();t={x:o.changedTouches[0].pageX-r.left,y:o.changedTouches[0].pageY-r.top}},o=function(i){i.preventDefault();var o=i.originalEvent;e(this).parent().css({top:o.changedTouches[0].pageY-t.y,left:o.changedTouches[0].pageX-t.x})};this.bind("touchstart",i).bind("touchmove",o)},k.touchDraggable()}return t.dialogZindex+=2,d},t.mouseOrTouch=function(e,t){e=e||"click",t=t||"touchend";var i=e;try{document.createEvent("TouchEvent"),i=t}catch(o){}return i},t.dateFormat=function(e){e=e||"";var t=function(e){return 10>e?"0"+e:e},i=new Date,o=i.getFullYear(),r=o.toString().slice(2,4),n=t(i.getMonth()+1),a=t(i.getDate()),s=i.getDay(),l=t(i.getHours()),c=t(i.getMinutes()),h=t(i.getSeconds()),d=t(i.getMilliseconds()),u="",f=r+"-"+n+"-"+a,g=o+"-"+n+"-"+a,p=l+":"+c+":"+h;switch(e){case"UNIX Time":u=i.getTime();break;case"UTC":u=i.toUTCString();break;case"yy":u=r;break;case"year":case"yyyy":u=o;break;case"month":case"mm":u=n;break;case"cn-week-day":case"cn-wd":var m=["日","一","二","三","四","五","六"];u="星期"+m[s];break;case"week-day":case"wd":var w=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];u=w[s];break;case"day":case"dd":u=a;break;case"hour":case"hh":u=l;break;case"min":case"ii":u=c;break;case"second":case"ss":u=h;break;case"ms":u=d;break;case"yy-mm-dd":u=f;break;case"yyyy-mm-dd":u=g;break;case"yyyy-mm-dd h:i:s ms":case"full + ms":u=g+" "+p+" "+d;break;case"full":case"yyyy-mm-dd h:i:s":default:u=g+" "+p}return u},t}});
|
||
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
|
||
* Licensed under the MIT License (LICENSE.txt).
|
||
*
|
||
* Version: 3.1.9
|
||
*
|
||
* Requires: jQuery 1.2.2+
|
||
*/
|
||
|
||
(function (factory) {
|
||
if ( typeof define === 'function' && define.amd ) {
|
||
// AMD. Register as an anonymous module.
|
||
define(['jquery'], factory);
|
||
} else if (typeof exports === 'object') {
|
||
// Node/CommonJS style for Browserify
|
||
module.exports = factory;
|
||
} else {
|
||
// Browser globals
|
||
factory(jQuery);
|
||
}
|
||
}(function ($) {
|
||
|
||
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
|
||
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
|
||
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
|
||
slice = Array.prototype.slice,
|
||
nullLowestDeltaTimeout, lowestDelta;
|
||
|
||
if ( $.event.fixHooks ) {
|
||
for ( var i = toFix.length; i; ) {
|
||
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
|
||
}
|
||
}
|
||
|
||
var special = $.event.special.mousewheel = {
|
||
version: '3.1.9',
|
||
|
||
setup: function() {
|
||
if ( this.addEventListener ) {
|
||
for ( var i = toBind.length; i; ) {
|
||
this.addEventListener( toBind[--i], handler, false );
|
||
}
|
||
} else {
|
||
this.onmousewheel = handler;
|
||
}
|
||
// Store the line height and page height for this particular element
|
||
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
|
||
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
|
||
},
|
||
|
||
teardown: function() {
|
||
if ( this.removeEventListener ) {
|
||
for ( var i = toBind.length; i; ) {
|
||
this.removeEventListener( toBind[--i], handler, false );
|
||
}
|
||
} else {
|
||
this.onmousewheel = null;
|
||
}
|
||
},
|
||
|
||
getLineHeight: function(elem) {
|
||
return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);
|
||
},
|
||
|
||
getPageHeight: function(elem) {
|
||
return $(elem).height();
|
||
},
|
||
|
||
settings: {
|
||
adjustOldDeltas: true
|
||
}
|
||
};
|
||
|
||
$.fn.extend({
|
||
mousewheel: function(fn) {
|
||
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
|
||
},
|
||
|
||
unmousewheel: function(fn) {
|
||
return this.unbind('mousewheel', fn);
|
||
}
|
||
});
|
||
|
||
|
||
function handler(event) {
|
||
var orgEvent = event || window.event,
|
||
args = slice.call(arguments, 1),
|
||
delta = 0,
|
||
deltaX = 0,
|
||
deltaY = 0,
|
||
absDelta = 0;
|
||
event = $.event.fix(orgEvent);
|
||
event.type = 'mousewheel';
|
||
|
||
// Old school scrollwheel delta
|
||
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
|
||
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
|
||
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
|
||
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
|
||
|
||
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
|
||
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||
deltaX = deltaY * -1;
|
||
deltaY = 0;
|
||
}
|
||
|
||
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
|
||
delta = deltaY === 0 ? deltaX : deltaY;
|
||
|
||
// New school wheel delta (wheel event)
|
||
if ( 'deltaY' in orgEvent ) {
|
||
deltaY = orgEvent.deltaY * -1;
|
||
delta = deltaY;
|
||
}
|
||
if ( 'deltaX' in orgEvent ) {
|
||
deltaX = orgEvent.deltaX;
|
||
if ( deltaY === 0 ) { delta = deltaX * -1; }
|
||
}
|
||
|
||
// No change actually happened, no reason to go any further
|
||
if ( deltaY === 0 && deltaX === 0 ) { return; }
|
||
|
||
// Need to convert lines and pages to pixels if we aren't already in pixels
|
||
// There are three delta modes:
|
||
// * deltaMode 0 is by pixels, nothing to do
|
||
// * deltaMode 1 is by lines
|
||
// * deltaMode 2 is by pages
|
||
if ( orgEvent.deltaMode === 1 ) {
|
||
var lineHeight = $.data(this, 'mousewheel-line-height');
|
||
delta *= lineHeight;
|
||
deltaY *= lineHeight;
|
||
deltaX *= lineHeight;
|
||
} else if ( orgEvent.deltaMode === 2 ) {
|
||
var pageHeight = $.data(this, 'mousewheel-page-height');
|
||
delta *= pageHeight;
|
||
deltaY *= pageHeight;
|
||
deltaX *= pageHeight;
|
||
}
|
||
|
||
// Store lowest absolute delta to normalize the delta values
|
||
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
|
||
|
||
if ( !lowestDelta || absDelta < lowestDelta ) {
|
||
lowestDelta = absDelta;
|
||
|
||
// Adjust older deltas if necessary
|
||
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
||
lowestDelta /= 40;
|
||
}
|
||
}
|
||
|
||
// Adjust older deltas if necessary
|
||
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
||
// Divide all the things by 40!
|
||
delta /= 40;
|
||
deltaX /= 40;
|
||
deltaY /= 40;
|
||
}
|
||
|
||
// Get a whole, normalized value for the deltas
|
||
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
|
||
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
|
||
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
|
||
|
||
// Add information to the event object
|
||
event.deltaX = deltaX;
|
||
event.deltaY = deltaY;
|
||
event.deltaFactor = lowestDelta;
|
||
// Go ahead and set deltaMode to 0 since we converted to pixels
|
||
// Although this is a little odd since we overwrite the deltaX/Y
|
||
// properties with normalized deltas.
|
||
event.deltaMode = 0;
|
||
|
||
// Add event and delta to the front of the arguments
|
||
args.unshift(event, delta, deltaX, deltaY);
|
||
|
||
// Clearout lowestDelta after sometime to better
|
||
// handle multiple device types that give different
|
||
// a different lowestDelta
|
||
// Ex: trackpad = 3 and mouse wheel = 120
|
||
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
|
||
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
|
||
|
||
return ($.event.dispatch || $.event.handle).apply(this, args);
|
||
}
|
||
|
||
function nullLowestDelta() {
|
||
lowestDelta = null;
|
||
}
|
||
|
||
function shouldAdjustOldDeltas(orgEvent, absDelta) {
|
||
// If this is an older event and the delta is divisable by 120,
|
||
// then we are assuming that the browser is treating this as an
|
||
// older mouse wheel event and that we should divide the deltas
|
||
// by 40 to try and get a more usable deltaFactor.
|
||
// Side note, this actually impacts the reported scroll distance
|
||
// in older browsers and can cause scrolling to be slower than native.
|
||
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
|
||
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
|
||
}
|
||
|
||
}));
|
||
/*!
|
||
* M['weburl'] 网站网址
|
||
* M['lang'] 网站语言
|
||
* M['tem'] 模板目录路径
|
||
* M['classnow'] 当前栏目ID
|
||
* M['id'] 当前页面ID
|
||
* M['module'] 当前页面所属模块
|
||
* default_placeholder 开发者自定义默认图片延迟加载方式,'base64':灰色背景;自定义背景图片路径;'blur':图片高斯模糊;默认为'blur'
|
||
* met_prevarrow,met_nextarrow slick插件翻页按钮自定义html
|
||
* device_type 客户端判断(d:PC端,t:平板端,m:手机端)
|
||
*/
|
||
METUI_FUN['head_nav_met_16_1'] = {
|
||
name:'head_nav_met_16_1',
|
||
init: function() {
|
||
var wh=$(window).height(),
|
||
$metnav_fixed=$(".met-head.navbar-fixed-top head_nav_met_16_1"),
|
||
$metnav_lang=METUI['head_nav_met_16_1'].find('.met-langlist'),
|
||
$metnav_member=METUI['head_nav_met_16_1'].find('.navbar-toggler'),
|
||
$met_navlist=METUI['head_nav_met_16_1'].find('.navlist');
|
||
// 头部固定模式
|
||
if($metnav_fixed.length){
|
||
// 头部阴影
|
||
var metnavShadow=function(){
|
||
if($metnav_fixed.offset().top>1){
|
||
$metnav_fixed.addClass("navbar-shadow");
|
||
}else{
|
||
$metnav_fixed.removeClass("navbar-shadow");
|
||
}
|
||
};
|
||
metnavShadow();
|
||
$(window).scroll(function(){
|
||
metnavShadow();
|
||
});
|
||
// 导航下拉菜单手机端最大高度
|
||
$metnav_fixed.find('.navbar-collapse').css({'max-height':wh-$metnav_fixed.height()});
|
||
if(device_type!='m'){
|
||
// 下拉菜单二级栏目过多时三级栏目展示在二级栏目下面
|
||
var $met_navlist_dropdown=$met_navlist.find('.dropdown'),
|
||
dropdownMaxh=function(dom){
|
||
if(!dom.hasClass('oya')){
|
||
setTimeout(function(){
|
||
var mh=wh-dom.position().top;
|
||
if(dom.outerHeight()>mh) dom.outerHeight(mh).addClass('oya scrollbar-beautify').find('.dropdown-menu').addClass('block box-shadow-none').prev('.dropdown-item').addClass('dropdown-a');
|
||
},0)
|
||
}
|
||
};
|
||
//鼠标经过展开下拉菜单
|
||
$met_navlist_dropdown.find('>.dropdown-toggle[data-hover]').parent('.dropdown').mouseover(function() {
|
||
dropdownMaxh($('>.dropdown-menu',this));
|
||
});
|
||
// 鼠标点击展开下拉菜单
|
||
$met_navlist_dropdown.find('>.dropdown-toggle:not([data-hover])').one('click',function() {
|
||
dropdownMaxh($(this).next('.dropdown-menu'));
|
||
});
|
||
}
|
||
// 下拉菜单背景遮罩
|
||
$metnav_fixed.find('.navbar-toggler').click(function() {
|
||
if(!$('.met-mask').length) $('body').append('<div class="met-mask"></div>');
|
||
if($($(this).data('target')).is(':visible')){
|
||
$('body').removeClass('cover');
|
||
$('.met-mask').fadeOut();
|
||
}else if(!$('body').hasClass('cover')){
|
||
$('body').addClass('cover');
|
||
$('.met-mask').fadeIn();
|
||
}
|
||
});
|
||
$(document).on('click','.met-mask',function() {
|
||
$('body').removeClass('cover');
|
||
$('.met-mask').fadeOut();
|
||
$metnav_fixed.find('.navbar-collapse').collapse('hide');
|
||
});
|
||
}
|
||
|
||
if($met_navlist.length){
|
||
// 导航点击跳转处理
|
||
$met_navlist.find('.nav-link').click(function(){
|
||
if(device_type=='d' && !Breakpoints.is('xs') && $(this).data("hover")){
|
||
if($(this).attr('target')=='_blank'){
|
||
window.open($(this).attr('href'));
|
||
}else{
|
||
location=$(this).attr('href');
|
||
}
|
||
}
|
||
});
|
||
// 导航下拉菜单三级栏目展开处理
|
||
if(device_type=='d'){
|
||
if($met_navlist.find('.dropdown-submenu').length){
|
||
$met_navlist.find('.dropdown-submenu').hover(function(){
|
||
$(this).parent('.dropdown-menu').addClass('overflow-visible');
|
||
},function(){
|
||
$(this).parent('.dropdown-menu').removeClass('overflow-visible');
|
||
});
|
||
}
|
||
}else{
|
||
if($met_navlist.find('.dropdown-submenu').length){
|
||
setTimeout(function(){
|
||
$met_navlist.find('.dropdown-submenu .dropdown-menu').addClass('block box-shadow-none').prev('.dropdown-item').addClass('dropdown-a');
|
||
},0)
|
||
}
|
||
}
|
||
// 导航顶级栏目过多时换行处理
|
||
var met_navlist_position=function(){
|
||
if(!Breakpoints.is('xs') && $met_navlist.position().top>20){
|
||
$met_navlist.addClass('flex').parent().addClass('flex-navlist');
|
||
if($('body').hasClass('met-navfixed')) $('body').addClass('met-navfixed-navclamp');
|
||
}else{
|
||
$met_navlist.removeClass('flex').parent().removeClass('flex-navlist');
|
||
if($('body').hasClass('met-navfixed')) $('body').removeClass('met-navfixed-navclamp');
|
||
}
|
||
};
|
||
met_navlist_position();
|
||
$(window).resize(function(){
|
||
met_navlist_position();
|
||
});
|
||
}
|
||
// 手机端头部会员中心与导航下拉菜单切换
|
||
$metnav_member.click(function() {
|
||
$(this).toggleClass('active');
|
||
$(this).siblings('.navbar-toggler').removeClass('active');
|
||
var $other_collapse=$($(this).siblings('.navbar-toggler').data('target'));
|
||
if($other_collapse.hasClass('in')) $other_collapse.collapse('hide');
|
||
});
|
||
// 头部语言栏
|
||
if($metnav_lang.length){
|
||
// 语言栏弹窗模式处理
|
||
$(document).on('show.bs.modal', '#met-langlist-modal', function(event) {
|
||
$('.met-nav').addClass('header-zindex');
|
||
});
|
||
$(document).on('hidden.bs.modal', '#met-langlist-modal', function(event) {
|
||
$('.met-nav').removeClass('header-zindex');
|
||
});
|
||
}
|
||
// 处理导航过长
|
||
if($('.two-menu').length){
|
||
$('.two-menu').mousewheel(function(event,delta,deltaX,deltaY){
|
||
var dY=Math.ceil( $(this).position().top-deltaY*-120 );
|
||
if(dY>0) dY=0;
|
||
console.log(dY);
|
||
$(this).css({'transform':'translateY('+dY+'px)','transition':'0s'});
|
||
event.stopPropagation();
|
||
event.preventDefault();
|
||
}).mouseleave(function(){
|
||
$(this).removeAttr('style');
|
||
});
|
||
}
|
||
},
|
||
cntotc:function(){
|
||
//简体繁体互换
|
||
var b=$('.btn-cntotc');
|
||
b.on('click', function(event) {
|
||
var lang=$(this).attr('data-tolang');
|
||
|
||
if (lang=='tc') {
|
||
$('body').s2t();
|
||
$(this).attr('data-tolang', 'cn');
|
||
$(this).text('简体');
|
||
} else if(lang=='cn') {
|
||
$('body').t2s();
|
||
$(this).attr('data-tolang', 'tc');
|
||
$(this).text('繁體');
|
||
}
|
||
});
|
||
}
|
||
};
|
||
var x = new metui(METUI_FUN['head_nav_met_16_1']);
|
||
|
||
/*!
|
||
* M['weburl'] 网站网址
|
||
* M['lang'] 网站语言
|
||
* M['tem'] 模板目录路径
|
||
* M['classnow'] 当前栏目ID
|
||
* M['id'] 当前页面ID
|
||
* M['module'] 当前页面所属模块
|
||
* default_placeholder 开发者自定义默认图片延迟加载方式,'base64':灰色背景;自定义背景图片路径;'blur':图片高斯模糊;默认为'blur'
|
||
* met_prevarrow,met_nextarrow slick插件翻页按钮自定义html
|
||
* device_type 客户端判断(d:PC端,t:平板端,m:手机端)
|
||
*/
|
||
METUI_FUN['banner_met_16_2'] = {
|
||
name:'banner_met_16_2',
|
||
init: function() {
|
||
var $metbanner=METUI['banner_met_16_2'],
|
||
metbanner_slide='.banner_met_16_2 .slick-slide';
|
||
if($metbanner.length){
|
||
var img = METUI['banner_met_16_2'].find('.cover-image').eq(0);
|
||
img.imageloadFun(function(){
|
||
var slide = METUI['banner_met_16_2'].find('.slick-slide'),
|
||
bh = img.data('height').split('|');
|
||
for (var i = 0; i<bh.length;i++) {
|
||
if(bh[i]==0){
|
||
bh[i]='auto';
|
||
}
|
||
}
|
||
Breakpoints.on('md lg', {
|
||
enter: function() {
|
||
METUI['banner_met_16_2'].find('.cover-image').height(bh[0]);
|
||
}
|
||
})
|
||
Breakpoints.on('sm', {
|
||
enter: function() {
|
||
METUI['banner_met_16_2'].find('.cover-image').height(bh[1]);
|
||
}
|
||
})
|
||
Breakpoints.on('xs', {
|
||
enter: function() {
|
||
METUI['banner_met_16_2'].find('.cover-image').height(bh[2]);
|
||
}
|
||
})
|
||
// 开始轮播
|
||
var metbanner_swipe=slick_arrows=true;
|
||
if(device_type=='d' && !Breakpoints.is('xs')) metbanner_swipe=false;
|
||
if(Breakpoints.is('xs')) slick_arrows=false;
|
||
if($(metbanner_slide).length>1){
|
||
$metbanner.slick({
|
||
autoplay:true,
|
||
dots:true,
|
||
arrows:slick_arrows,
|
||
autoplaySpeed:4000,
|
||
pauseOnHover:false,
|
||
swipe:metbanner_swipe,
|
||
prevArrow:'<button type="button" class="slick-prev"><i class="icon fa-angle-left"></i></button>',
|
||
nextArrow:'<button type="button" class="slick-next"><i class="icon fa-angle-right"></i></button>',
|
||
lazyloadPrevNext:true,
|
||
adaptiveHeight: true
|
||
}).on('setPosition',function(event,slick){
|
||
$(metbanner_slide+' .banner-text').hide();
|
||
$(metbanner_slide+'.slick-active .banner-text').show();
|
||
});
|
||
}
|
||
})
|
||
}
|
||
}
|
||
};
|
||
var banner=metui(METUI_FUN['banner_met_16_2']);
|
||
|
||
|
||
|
||
/*own.js*/
|
||
/*!
|
||
* M['weburl'] 网站网址
|
||
* M['lang'] 网站语言
|
||
* M['tem'] 模板目录路径
|
||
* M['classnow'] 当前栏目ID
|
||
* M['id'] 当前页面ID
|
||
* M['module'] 当前页面所属模块
|
||
* default_placeholder 开发者自定义默认图片延迟加载方式,'base64':灰色背景;自定义背景图片路径;'blur':图片高斯模糊;默认为'blur'
|
||
* met_prevarrow,met_nextarrow slick插件翻页按钮自定义html
|
||
* device_type 客户端判断(d:PC端,t:平板端,m:手机端)
|
||
*/
|
||
METUI_FUN['foot_info_met_16_2'] = {
|
||
name:'foot_info_met_16_2',
|
||
cntotc:function(){
|
||
//简体繁体互换
|
||
var b=$('#btn-cntotc');
|
||
b.on('click', function(event) {
|
||
var lang=$(this).attr('data-tolang');
|
||
|
||
if (lang=='tc') {
|
||
$('body').s2t();
|
||
$(this).attr('data-tolang', 'cn');
|
||
$(this).text('简体');
|
||
} else if(lang=='cn') {
|
||
$('body').t2s();
|
||
$(this).attr('data-tolang', 'tc');
|
||
$(this).text('繁體');
|
||
}
|
||
});
|
||
}
|
||
};
|
||
var x = new metui(METUI_FUN['foot_info_met_16_2']);
|
||
|
||
/*own.js*/
|
||
/*!
|
||
* M['weburl'] 网站网址
|
||
* M['lang'] 网站语言
|
||
* M['tem'] 模板目录路径
|
||
* M['classnow'] 当前栏目ID
|
||
* M['id'] 当前页面ID
|
||
* M['module'] 当前页面所属模块
|
||
* default_placeholder 开发者自定义默认图片延迟加载方式,'base64':灰色背景;自定义背景图片路径;'blur':图片高斯模糊;默认为'blur'
|
||
* met_prevarrow,met_nextarrow slick插件翻页按钮自定义html
|
||
* device_type 客户端判断(d:PC端,t:平板端,m:手机端)
|
||
*/
|
||
METUI_FUN['show_met_16_2'] = {
|
||
name:'show_met_16_2',
|
||
init:function (){
|
||
var $met_editor=METUI['show_met_16_2'].find('.met-editor'),
|
||
$met_sidebar=METUI['show_met_16_2'].find('.met-sidebar'),
|
||
editormdView=new Array(),
|
||
body_pt=parseInt($('body').css('padding-top')),
|
||
wh=$(window).height(),
|
||
scrollok=true;
|
||
// 点击锚点滚动优化
|
||
$.fn.hashScroll=function(){
|
||
var selector=$(this).selector;
|
||
$(this).click(function(event) {
|
||
if($(this).attr('href').substr(0,1)=='#' && scrollok){
|
||
var id=$(this).attr('href').substr(1);
|
||
if(typeof id !=='undefind' && id!=''){
|
||
event.preventDefault();
|
||
// 修改、添加地址栏hash
|
||
window.history.pushState('','','#'+id);
|
||
// 滚动至对应锚点位置
|
||
var index=$(this).parents('.met-sidebar').length?$(this).index(selector+'[href="#'+id+'"]'):0,
|
||
goto_scroll=$('[name="'+id+'"]').eq(index).offset().top-body_pt;
|
||
$('html,body').stop().animate({scrollTop:goto_scroll}, 300);
|
||
scrollok=false;
|
||
var pagescroll=setInterval(function(){
|
||
setTimeout(function(){
|
||
var goto_scroll=$('[name="'+id+'"]').eq(index).offset().top-body_pt;
|
||
if(Math.abs($(window).scrollTop()-goto_scroll)<2 || $(window).scrollTop() == $(document).height()-wh){
|
||
scrollok=true;
|
||
clearInterval(pagescroll);
|
||
}else{
|
||
$('html,body').stop().animate({scrollTop:goto_scroll}, 300);
|
||
}
|
||
},50)
|
||
},350);
|
||
}
|
||
}
|
||
});
|
||
};
|
||
var markdownFun=function(){
|
||
setTimeout(function(){
|
||
if($met_editor.find('[data-original]').length && !$met_editor.find('[data-original][data-lazyload]').length) $met_editor.find('[data-original]').lazyload();
|
||
var $markdown_toc=$met_editor.find('.markdown-toc'),
|
||
markdown_toc=$markdown_toc.clone(true);
|
||
if($met_sidebar.length && $markdown_toc.length){
|
||
// 编辑器的栏目目录移动到侧栏
|
||
$markdown_toc.remove();
|
||
$met_sidebar.append(markdown_toc);
|
||
$markdown_toc=$met_sidebar.find('.markdown-toc');
|
||
// 点击侧栏栏目,滚动到对应栏目区块
|
||
$markdown_toc.addClass('markdown-body editormd-html-preview').find('a').hashScroll();
|
||
// 侧栏当前栏目高亮
|
||
Breakpoints.on('md lg',{
|
||
enter:function(){
|
||
var scrollActive=function(argument) {
|
||
var st=$(window).scrollTop();
|
||
$met_editor.find('a[name]').each(function(index, el) {
|
||
var name=$(this).attr('name')||'';
|
||
if(st<$(this).offset().top && st+wh>$(this).offset().top && name!=''){
|
||
var index1=$(this).index($met_editor.find('a[name="'+name+'"]').selector);
|
||
$markdown_toc.find('a').removeClass('active');
|
||
$markdown_toc.find('a[href="#'+name+'"]').eq(index1).addClass('active');
|
||
return false;
|
||
}
|
||
});
|
||
}
|
||
scrollActive();
|
||
$(window).scroll(function(event) {
|
||
scrollActive();
|
||
});
|
||
}
|
||
})
|
||
}
|
||
// 刷新页面时滚动到锚点
|
||
if(location.hash.length>1){
|
||
var hash=decodeURI(location.hash),
|
||
hash_name=hash.substr(1),
|
||
hash_a='a[href="'+hash+'"]',
|
||
$hash=$markdown_toc.find(hash_a).length?$markdown_toc.find(hash_a):$met_editor.find(hash_a);
|
||
if(!$hash.length){
|
||
$hash=$met_editor.find('a[name="'+hash_name+'"]');
|
||
if($hash.length && !$hash.attr('href')) $hash.attr({href:hash});
|
||
if(!$hash.length) $hash='';
|
||
}
|
||
}
|
||
// 编辑器内链接在新标签打开
|
||
$met_editor.find('a[href!=""]').each(function(index, el) {
|
||
var href=$(this).attr('href')||'';
|
||
if(href!='' && href.substr(0,1)!='#') $(this).attr({target:'_blank'});
|
||
});
|
||
$met_editor.find('a[href!=""]').hashScroll();// 点击详情内容内锚点,滚动到对应区块
|
||
if($hash) $hash.click();
|
||
},0)
|
||
};
|
||
// 编辑器内markdown语句渲染
|
||
$met_editor.each(function(index, el) {
|
||
var $self=$(this),
|
||
id=$(this).attr('id') || 'met-editor-md'+index,
|
||
html=$.trim($('textarea[hidden]',this).val()),
|
||
num=0,
|
||
editormdViewFun=function(){
|
||
if(html.lastIndexOf('<m met-id=')>=0) html=html.substr(0,html.lastIndexOf('<m met-id='));
|
||
if(html!=''){
|
||
if(!$self.attr('id')) $self.attr({id:id});
|
||
editormdView[index] = editormd.markdownToHTML(id, {
|
||
markdown:html
|
||
})
|
||
}
|
||
num++;
|
||
if(num==$met_editor.length) markdownFun();
|
||
};
|
||
if(html.indexOf('*textarea_content*')>=0){
|
||
$.ajax({
|
||
url: location.href,
|
||
type: 'POST',
|
||
data:{ajax:1},
|
||
success:function(data){
|
||
html=data.split('<textarea_content>')[1];
|
||
editormdViewFun();
|
||
}
|
||
});
|
||
}else{
|
||
editormdViewFun();
|
||
}
|
||
});
|
||
if($met_sidebar.length){
|
||
Breakpoints.on('md lg',{
|
||
enter:function(){
|
||
// 限制侧栏高度
|
||
$met_sidebar.css({'max-height':wh-body_pt});
|
||
var mh=Math.max($met_sidebar.outerHeight(),$met_editor.outerHeight());
|
||
$met_sidebar.parent().css({'min-height':mh});
|
||
// 侧栏固定定位
|
||
$(window).scroll(function(event) {
|
||
var st=$(this).scrollTop();
|
||
if(st>$met_sidebar.parent().offset().top-body_pt){
|
||
var mh=Math.max($met_sidebar.outerHeight(),$met_editor.outerHeight());
|
||
if(mh>$met_sidebar.outerHeight()){
|
||
$met_sidebar.parent().css({'min-height':mh});
|
||
if(st+wh>$('.met-foot').offset().top && $met_sidebar.outerHeight()+$met_sidebar.position().top>wh-$('.met-foot').outerHeight()){
|
||
$met_sidebar.removeClass('fixed').addClass('absolute');
|
||
}else{
|
||
$met_sidebar.addClass('fixed').removeClass('absolute');
|
||
}
|
||
}
|
||
}else{
|
||
$met_sidebar.removeClass('fixed');
|
||
}
|
||
});
|
||
}
|
||
})
|
||
}
|
||
}
|
||
};
|
||
var x = new metui(METUI_FUN['show_met_16_2']);
|