| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /**
- * xuequ.js
- * @authors qing.zhou (qing.zhou@moji.com)
- * @date 2014-12-17
- * @version 0.1
- */
- ! function(root, $, undefined) {
- var doc = root.document,
- $pages = $('.slide-page'),
- $arrow = $('.arrow-up'),
- $audioBtn = $('.btn-audio'),
- count = $pages.length,
- timeoutID = {};
- var now = function() {
- return +new Date;
- }
- var initPages = function() {
- $pages.pageSlider();
- $arrow.show();
- $pages.eq(0).show().next('.page').show();
- setTimeout(function() {
- $pages.eq(0).addClass('active');
- }, 0);
- $(doc).on('enter leave', function(e, data) {
- var $target = $(e.target);
- if (e.type === 'enter') {
- // 最后一页不现实上滑按钮
- if (data.index && data.index + 1 == count) {
- setTimeout(function() {
- $arrow.hide();
- }, 0);
- } else {
- $arrow.show()
- }
- $target.show().next('.page').show();
- setTimeout(function() {
- $target.addClass('active');
- }, 0)
- } else {
- $target.removeClass('active');
- }
- });
- var bgMusic = doc.getElementById('bg_music');
- $(doc).one('touchstart', function(){
- bgMusic.play();
- });
- $audioBtn.on("click", function() {
- console.log(bgMusic.paused)
- if (bgMusic.currentTime == 0 || bgMusic.ended || bgMusic.paused) {
- bgMusic.play();
- $audioBtn.removeClass("disabled");
- } else {
- bgMusic.pause();
- $audioBtn.addClass("disabled");
- }
- return false;
- })
- };
- var initShare = function() {
- var $shareBtn = $('#do_share'),
- $shareLayer = $('.share-dialog-bg'),
- $shareInfo = $('.share-info');
- $shareBtn.on('touchstart', function() {
- $shareBtn.addClass('active');
- }).on('touchend', function() {
- $shareBtn.removeClass('active');
- }).on('tap', function() {
- $shareLayer.show();
- $(doc).on('share:touchmove', function(e) {
- e.preventDefault();
- })
- });
- $shareLayer.on('tap', function() {
- $shareLayer.hide();
- $(doc).off('share:touchmove');
- });
- }
- var handleDownload = function() {
- var ua = navigator.userAgent.toLowerCase(),
- iOS = /(ipad|iphone|ipod|Macintosh)/g.test(ua),
- vUrl = "http://mp.weixin.qq.com/mp/redirect?url=",
- iosUrl = "https://itunes.apple.com/cn/app/mo-ji-tian-qi-pm2.5-shi-jing/id434209233?mt=8",
- androidUrl = "http://a.app.qq.com/o/simple.jsp?pkgname=com.moji.mjweather&ckey=CK1288790370865";
- var $download = $('#download'),
- url;
- // 判断是否在moji端内
- var regExpi = /mojii/,
- regExpa = /mojia/;
- // 端内隐藏
- if (regExpi.test(ua) || regExpa.test(ua)) {
- $download.hide();
- return;
- }
- if (/MicroMessenger/i.test(ua)) {
- url = vUrl + (iOS ? iosUrl : androidUrl);
- } else {
- url = iOS ? iosUrl : androidUrl;
- }
- var _oHtml = $download.html();
- var _html = '<a href="' + url + '">' + _oHtml + '</a>';
- $download.html(_html);
- }
- $(root).one('load', initPages);
- //滑倒最后一夜触发
- $pages.last().one('enter', function() {
- initShare();
- handleDownload();
- });
- }(window, Zepto)
|