You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
3.2 KiB

  1. frontend.download = {
  2. defaultValue: {
  3. },
  4. init: function () {
  5. if (jQuery('.mobile-download').length) {
  6. frontend.download.showDownloadPopup();
  7. }
  8. },
  9. showDownloadPopup: function () {
  10. if (!Cookies.get('download_pt_popup')) {
  11. if (window.jQBrowser.android || window.jQBrowser.kindle || window.jQBrowser.ipad || window.jQBrowser.iphone || window.jQBrowser.ipod || window.jQBrowser.mac || window.jQBrowser.win) {
  12. frontend.defaultValue = {
  13. bodyPaddingTop: parseInt(jQuery('body').css('padding-top')),
  14. bannerHeight: jQuery('.mobile-download').outerHeight()
  15. };
  16. var platform = '';
  17. if (window.jQBrowser.android) {
  18. platform = 'android';
  19. } else if (window.jQBrowser.kindle) {
  20. platform = 'amazon';
  21. } else if (window.jQBrowser.ipad || window.jQBrowser.iphone || window.jQBrowser.ipod) {
  22. platform = 'ios';
  23. }
  24. if (platform != '') {
  25. jQuery('.mobile-download .logo img').attr('src', jQuery('.mobile-download .data-mobile').data(platform + '-icon'));
  26. jQuery('.mobile-download .logo img').attr('alt', jQuery('.mobile-download .data-mobile').data(platform + '-icon-alt'));
  27. jQuery('.mobile-download .title a').attr('href', jQuery('.mobile-download .data-mobile').data(platform + '-url'));
  28. jQuery('.mobile-download .title a').html(jQuery('.mobile-download .data-mobile').data(platform + '-title'));
  29. jQuery('.mobile-download .description a').attr('href', jQuery('.mobile-download .data-mobile').data(platform + '-url'));
  30. jQuery('.mobile-download .description a').html(jQuery('.mobile-download .data-mobile').data(platform + '-subtitle'));
  31. jQuery('.mobile-download a.btn').attr('href', jQuery('.mobile-download .data-mobile').data(platform + '-url'));
  32. jQuery('.mobile-download a.btn').html(jQuery('.mobile-download .data-mobile').data(platform + '-label'));
  33. jQuery('.mobile-download').animate({
  34. marginTop: '0px',
  35. }, 1500);
  36. jQuery('body').animate({
  37. paddingTop: parseInt(frontend.defaultValue.bodyPaddingTop + frontend.defaultValue.bannerHeight) + 'px'
  38. }, 1500);
  39. jQuery('body > header').animate({
  40. top: parseInt(frontend.defaultValue.bannerHeight) + 'px'
  41. }, 1500);
  42. }
  43. }
  44. }
  45. },
  46. closeBanner: function () {
  47. jQuery('.mobile-download').animate({
  48. marginTop: parseInt(frontend.defaultValue.bannerHeight * -1) + 'px'
  49. }, 1500);
  50. jQuery('body').animate({
  51. paddingTop: parseInt(frontend.defaultValue.bodyPaddingTop) + 'px'
  52. }, 1500);
  53. jQuery('body > header').animate({
  54. top: '0px'
  55. }, 1500);
  56. Cookies.set('download_pt_popup', true, { expires: 14, path: '' });
  57. }
  58. }
  59. jQuery(document).ready(function () {
  60. frontend.download.init();
  61. });