Created
February 24, 2015 17:31
-
-
Save miketaylr/b8e37e44ff545c2dbec0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PageSlider = function () { | |
function e(e) { | |
C.height($(S.selector + '[data-id=' + Y + ']').height()), | |
e && n(_.offset().top - 40) | |
} | |
function t(t, n) { | |
I = window.innerWidth || C.width(), | |
$('body').removeAttr('style'), | |
S.width(I - 2 * (X + B)), | |
e(t), | |
E.width(I * O), | |
z = I - (X + 2 * B), | |
'undefined' != typeof n && n() | |
} | |
function n(e) { | |
window.setTimeout(function () { | |
$('body').scrollTop(e) | |
}, 100) | |
} | |
function o() { | |
var e = document.createElement('script'); | |
e.src = 'http://bit.ehow.com/tags/bit.js'; | |
var t = document.getElementsByTagName('head') [0]; | |
t.appendChild(e), | |
window.COMSCORE && COMSCORE.beacon(dmjs.global.comscore), | |
Y == O - 1 && new OmnitureLinkSet($('.PaginatedArticle .PageBox .suggestions'), 'TLS102', 'mobile-postplate-rc') | |
} | |
function a(e) { | |
W.started = !0, | |
W.At = r(), | |
W.startX = e.touches ? e.touches[0].pageX : e.pageX, | |
W.startY = e.touches ? e.touches[0].pageY : e.pageY, | |
W.endX = W.startX | |
} | |
function i(e) { | |
if (W.started || e.preventDefault(), W.started = !1, !U) { | |
var t = W.endX - W.startX; | |
t > 0 && t > z / 3 ? Y > 0 && (N = Y - 1) : 0 > t && - z / 3 > t ? O - 1 > Y && (N = Y + 1) : N = Y, | |
c(N, !0, 0.15) | |
} | |
} | |
function s(e) { | |
if (W.started) { | |
var t = e.touches ? e.touches[0].pageX : e.pageX, | |
n = e.touches ? e.touches[0].pageY : e.pageY, | |
o = t - W.startX, | |
a = n - W.startY; | |
if (W.endX = t, Math.abs(o) < Math.abs(a)) return !0; | |
e.preventDefault(), | |
d(W.At + o, 'none') | |
} | |
} | |
function r() { | |
var e = document.defaultView.getComputedStyle(E[0], null), | |
t = new WebKitCSSMatrix(e.webkitTransform); | |
return t.m41 | |
} | |
function d(e, t) { | |
var n = 'none' != t ? 'all ' + t + 's ease-out' : 'none'; | |
E[0].style.webkitTransition = n, | |
E[0].style.webkitTransform = 'translate3d(' + e + 'px,0,0)' | |
} | |
function c(t, n, a) { | |
if (0 == t || t + 1 == O ? $('.ShareTools').show() : $('.ShareTools').hide(), t >= 0 && O > t) { | |
var i = a || D; | |
d( - t * z, i), | |
t != Y && (v(t), u(), V++, m(Y), 0 == Y ? ($('.infoBox').removeClass('showProgress'), k.css({ | |
'margin-left': H + 'px' | |
}), $('.Bottom320').removeClass('showBottomAd')) : ($('.infoBox').addClass('showProgress'), k.css({ | |
'margin-left': H - 30 + 'px' | |
}), $(S.selector + '[data-id=' + Y + ']').hasClass('interstitial') ? $('.Bottom320').removeClass('showBottomAd') : $('.Bottom320').addClass('showBottomAd')), o(), dmjs.gtm_slideshowControlEvent(dmjs.global.articleID.toString()), $('.outlet[data-class=current]').text(Y + 1), l(), Q = Y, window.clearTimeout(L), L = window.setTimeout(function () { | |
e(n), | |
Y == Q && $(S.selector + '[data-id=' + Y + ']').hasClass('interstitial') ? (G = !0, dmjs.gptQueue.onLoad(function () { | |
g(GPT['300x250_end']) | |
})) : Y == Q && Y > 0 && V > 1 && (V = 0, dmjs.gptQueue.onLoad(function () { | |
g(GPT['320x50_btf']) | |
})) | |
}, 400), k.css(0 == t ? { | |
'margin-left': H + 'px' | |
} | |
: { | |
'margin-left': H - 30 + 'px' | |
}), window.location.hash = j + '=' + (Y + R)) | |
} | |
} | |
function l() { | |
Y > 0 && O - 1 > Y ? $('.control', x).show() : 0 >= Y ? ($('.control.prev').hide(), $('.control.next').show()) : Y >= O - 1 && ($('.control.next').hide(), $('.control.prev').show()) | |
} | |
function u() { | |
S.removeClass('current'), | |
$(S.selector + '[data-id=' + Y + ']').addClass('current') | |
} | |
function g(e) { | |
G && googletag.cmd.push(function () { | |
googletag.pubads().refresh([e]) | |
}) | |
} | |
function h() { | |
var e = document.location.hash.split('='); | |
if ('' == e) var t = 0; | |
else var t = ~~e[1] - R; | |
t !== Y && (G = !1, c(t, !0), G = !0) | |
} | |
function m(e) { | |
for (var t = [ | |
e + 1, | |
e, | |
e - 1 | |
], n = 0; n < t.length; n++) $(S.selector + '[data-id=' + t[n] + '] img[data-img]').each(function () { | |
var e = $(this); | |
e.hasClass('loaded') || (e.attr('src', e.attr('data-img')), e.addClass('loaded')) | |
}) | |
} | |
function f() { | |
return Y | |
} | |
function v(e) { | |
Y !== e && (M = Y, Y = e, $(PageSlider).triggerHandler(P)) | |
} | |
function p() { | |
return M | |
} | |
function w() { | |
return O | |
} | |
function b(e) { | |
O !== e && (O = e, $(PageSlider).triggerHandler(y)) | |
} | |
var x, | |
C, | |
E, | |
S, | |
_, | |
j, | |
k, | |
L, | |
P = 'currentSlideIndex', | |
T = 'previousSlideIndex', | |
y = 'numSlides', | |
X = 0, | |
B = 0, | |
I = 0, | |
A = 0, | |
U = !1, | |
D = 0.2, | |
O = 0, | |
N = 0, | |
M = - 1, | |
Y = 0, | |
z = 0, | |
R = 0, | |
G = !0, | |
H = '-150', | |
Q = 1, | |
V = 2, | |
W = { | |
started: !1, | |
startX: 0, | |
endX: 0, | |
At: 0 | |
}; | |
return { | |
CURRENT_SLIDE_INDEX: P, | |
PREVIOUS_SLIDE_INDEX: T, | |
NUM_SLIDES: y, | |
initialize: function (e) { | |
var n = dmjs.cookies.readCookie('dm_thanksgivingapp_cookie'); | |
n || $.get('https://ehowthanksgiving.firebaseio.com/settings.json', function (e) { | |
var t = 'Plan your Thanksgiving feast with eHow!', | |
n = '/services/modules/webapp/thanksgiving/index.html'; | |
1 == e.show_banner && (e.banner_message && (t = e.banner_message_2), e.banner_link && (n = e.banner_link), $('.SliderBar').prepend('<a style="display:block;color:#fff;background:#f9b463;padding:10px 0px; box-sizing:border-box;width:100%;font-weight:900;font-size:20px;text-align:center;" href="' + n + '">' + t + '</a>')) | |
}, 'JSON'), | |
$('.survey-banner').click(function () { | |
}), | |
x = '.PageSlider', | |
C = $(x), | |
E = $('.wrapper', x), | |
_ = $('.infoBox'), | |
S = $('.PageBox'), | |
X = 10, | |
B = 20, | |
j = e || 'page', | |
'page' != j && (R = 1), | |
S.css({ | |
'margin-right': X + 'px' | |
}), | |
E.css({ | |
'-webkit-transition': 'all ' + D + 's ease-out', | |
'padding-left': B + X + 'px', | |
left: 0 | |
}), | |
S.each(function (e) { | |
var t = $(this); | |
t.attr('data-id', e), | |
b(O + 1) | |
}), | |
$('.outlet[data-class=total]').text(O), | |
k = $('.Bottom250'), | |
H = parseInt(k.css('margin-left')), | |
t(!1), | |
$('.control.prev').hide(), | |
$('.control', x).on('touchstart', function () { | |
if (!U) { | |
var e = $(this); | |
e.hasClass('next') && O - 1 > Y ? N = Y + 1 : e.hasClass('prev') && Y > 0 && (N = Y - 1), | |
c(N, !0) | |
} | |
}), | |
h(), | |
u(), | |
m(Y), | |
E[0].addEventListener('touchstart', function (e) { | |
a(e) | |
}, !1), | |
E[0].addEventListener('touchmove', function (e) { | |
s(e) | |
}, !1), | |
E[0].addEventListener('touchend', function (e) { | |
i(e) | |
}, !1), | |
E[0].addEventListener('mousedown', function (e) { | |
a(e) | |
}, !1), | |
E[0].addEventListener('mousemove', function (e) { | |
1 == e.which && s(e) | |
}, !1), | |
E[0].addEventListener('mouseup', function (e) { | |
i(e) | |
}, !1); | |
var o = navigator.userAgent.toLowerCase(), | |
r = o.indexOf('android') > - 1, | |
d = 'onorientationchange' in window, | |
l = d && !r ? 'orientationchange' : 'resize'; | |
window.addEventListener(l, function () { | |
A != window.orientation && (A = window.orientation, t(!0, function () { | |
c(Y, !0) | |
})) | |
}, !1), | |
window.addEventListener('hashchange', function () { | |
h() | |
}) | |
}, | |
jumpToSlide: function (e, t, n) { | |
c(e, t, n) | |
}, | |
setCurrentSlideIndex: v, | |
getCurrentSlideIndex: f, | |
getPreviousSlideIndex: p, | |
getNumSlides: w | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment