(function(e) { function u(u) { function c() { function h(e) { e.show(); n.removeclass("loading") } var t = e(this), r = parseint(n.css("borderleftwidth")), i = s - r * 2, u = o - r * 2, a = t.width(), f = t.height(); if (a == n.width() && a <= i && f == n.height() && f <= u) { h(t); return } if (a > i || f > u) { var l = u < f ? u: f, c = i < a ? i: a; if (l / f <= c / a) { t.width(a * l / f); t.height(l) } else { t.width(c); t.height(f * c / a) } } n.animate({ width: t.width(), height: t.height(), margintop: -(t.height() / 2) - r, marginleft: -(t.width() / 2) - r }, 200, function() { h(t) }) } if (u) u.preventdefault(); var a = e(this), f = a.attr("href"); if (!f) return; var l = e(new image).hide(); e("#zoom .previous, #zoom .next").show(); if (a.hasclass("zoom")) e("#zoom .previous, #zoom .next").hide(); if (!r) { r = true; t.show(); e("body").addclass("zoomed") } n.html(l).delay(500).addclass("loading"); l.load(c).attr("src", f); i = a } function a() { var t = i.parent("li").prev(); if (t.length == 0) t = e(".gallery li:last-child"); t.find("a").trigger("click") } function f() { var t = i.parent("li").next(); if (t.length == 0) t = e(".gallery li:first-child"); t.children("a").trigger("click") } function l(s) { if (s) s.preventdefault(); r = false; i = null; t.hide(); e("body").removeclass("zoomed"); n.empty() } function c() { s = e(window).width(); o = e(window).height() } e("body").append('
'); var t = e("#zoom").hide(), n = e("#zoom .content"), r = false, i = null, s = e(window).width(), o = e(window).height(); (function() { t.live("click", function(t) { t.preventdefault(); if (e(t.target).attr("id") == "zoom") l() }); e("#zoom .close").live("click", l); e("#zoom .previous").live("click", a); e("#zoom .next").live("click", f); $('body').on('touchstart', '#zoom', function(e) { var touch = e.originalevent, startx = touch.changedtouches[0].pagex; $(this).on('touchmove', function(e) { e.preventdefault(); touch = e.originalevent.touches[0] || e.originalevent.changedtouches[0]; if (touch.pagex - startx > 20) { //向左 console.log('moveleft'); a(); $(this).off('touchmove'); }else if (touch.pagex - startx < -20) { //向右 console.log('moveright'); f(); $(this).off('touchmove'); }; }); }).on('touchend', function() { $(this).off('touchmove'); }); e(document).keydown(function(e) { if (!i) return; if (e.which == 38 || e.which == 40) e.preventdefault(); if (e.which == 27) l(); if (e.which == 37 && !i.hasclass("zoom")) a(); if (e.which == 39 && !i.hasclass("zoom")) f() }); //if (e(".gallery li a").length == 1) e(".gallery li a")[0].addclass("zoom"); e(".zoom, .gallery li a").live("click", u) })(); (function() { e(window).live("resize", c) })(); (function() { e(window).live("mousewheel dommousescroll", function(e) { if (!i) return; e.stoppropagation(); e.preventdefault(); e.cancelbubble = false }) })() })(jquery);