templates/layout/js/bug_report.js.twig line 1

Open in your IDE?
  1. (function ($) {
  2.     $.fn.feedback = function (success, fail) {
  3.         self = $(this);
  4.         self.find('.dropdown-menu-form').on('click', function (e) {
  5.             e.stopPropagation();
  6.         });
  7.         self.find('.screenshot').on('click', function () {
  8.             self.find('.cam').removeClass('fa-camera fa-check').addClass('fa-refresh fa-spin');
  9.             html2canvas($(document.body)[0]).then(function (canvas) {
  10.                 self.find('.screen-uri').val(canvas.toDataURL("image/png"));
  11.                 self.find('.cam').removeClass('fa-refresh fa-spin').addClass('fa-check');
  12.             });
  13.         });
  14.         self.find('.do-close').on('click', function () {
  15.             self.find('.dropdown-toggle').dropdown('toggle');
  16.             self.find('.reported, .failed').hide();
  17.             self.find('.report').show();
  18.             self.find('.cam').removeClass('fa-check').addClass('fa-camera');
  19.             self.find('.screen-uri').val('');
  20.             self.find('textarea').val('');
  21.         });
  22.         failed = function () {
  23.             self.find('.loading').hide();
  24.             self.find('.failed').show();
  25.             if (fail) fail();
  26.         }
  27.         self.find('form').on('submit', function () {
  28.             self.find('.report').hide();
  29.             self.find('.loading').show();
  30.             self.find('input[name="viewport"]').val($(window).width()+"x"+$(window).height());
  31.             $.post($(this).attr('action'), $(this).serialize(), null, 'json').done(function (res) {
  32.                 if (res == 'success') {
  33.                     self.find('.loading').hide();
  34.                     self.find('.reported').show();
  35.                     if (success) success();
  36.                 } else failed();
  37.             }).fail(function () {
  38.                 failed();
  39.             });
  40.             return false;
  41.         });
  42.     };
  43. }(jQuery));
  44. $(document).ready(function () {
  45.     $('.feedback').feedback();
  46. });