// Copyright (c) 2016 NetEase Youdao, All rights reserved.

$(function() {

$("body").swipe( {
  tap: function (event, target) {
    if ($(target).hasClass('js-stop-captionMouseDown') ||
        $(target).hasClass('js-vista-ctlog')) { console.log(target)
      event.preventDefault();
      event.stopPropagation();
      $(target).click();
      return false;
    }

  },
  
  fingers: 'all',
  threshold: 50,
  maxTimeThreshold: 2000,
  allowPageScroll: 'vertical',
  excludedElements: "a:not(.js-stop-captionMouseDown)"
});

var capthe, ts;

$('header.title').swipe({
  longTap:function(event, target) {
    external.cppCall('popSysMenu');
  },
  threshold: 50,
}).on('touchmove', function(e) {console.log(this, 'move');
  if (e.target.tagName == 'A')
    return;
  capthe = setTimeout(function () {
    external.cppCall('captionMouseDown');
  }, 0);
  e.stopPropagation();
}).on('touchend', function (e) {console.log(this, 'end');
  if (e.target.tagName == 'A')
    return;
  clearTimeout(capthe);
  e.stopPropagation();
}).on('touchstart', function (e) {
  if (e.target.tagName == 'A')
    return;
  ts++;
  setTimeout(function () {
    ts = 0;
  }, 500);
  if (ts > 1) {
    $('#cpp_max').click();
    ts = 0;
  }
  e.stopPropagation();
});


});
