(function(n){n.feedback=function(t){function f(){canDraw=!1;n(document).off("mouseenter mouseleave",".feedback-helper");n(document).off("mouseup keyup");n(document).off("mousedown",".feedback-setblackout");n(document).off("mousedown",".feedback-sethighlight");n(document).off("mousedown click","#feedback-close");n(document).off("mousedown","#feedback-canvas");n(document).off("click","#feedback-highlighter-next");n(document).off("click","#feedback-highlighter-back");n(document).off("click","#feedback-welcome-next");n(document).off("click","#feedback-overview-back");n(document).off("mouseleave","body");n(document).off("mouseenter",".feedback-helper");n(document).off("selectstart dragstart",document);n("#feedback-module").off("click",".feedback-wizard-close,.feedback-close-btn");n(document).off("click","#feedback-submit");i.highlightElement&&(n(document).off("click","#feedback-canvas"),n(document).off("mousemove","#feedback-canvas"));n('[data-highlighted="true"]').removeAttr("data-highlight-id").removeAttr("data-highlighted");n("#feedback-module").remove();n(".feedback-btn").show();i.onClose.call(this)}function r(t,i){i=typeof i!="undefined"?i:!0;t.clearRect(0,0,n("#feedback-canvas").width(),n("#feedback-canvas").height());t.fillStyle="rgba(102,102,102,0.5)";t.fillRect(0,0,n("#feedback-canvas").width(),n("#feedback-canvas").height());n(".feedback-helper").each(function(){n(this).attr("data-type")=="highlight"&&i&&u(t,parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height())});n(".feedback-helper").each(function(){n(this).attr("data-type")=="highlight"&&t.clearRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height())});n(".feedback-helper").each(function(){n(this).attr("data-type")=="blackout"&&(t.fillStyle="rgba(0,0,0,1)",t.fillRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height()))})}function u(n,t,r,u,f){n.strokeStyle=i.strokeStyle;n.shadowColor=i.shadowColor;n.shadowOffsetX=i.shadowOffsetX;n.shadowOffsetY=i.shadowOffsetY;n.shadowBlur=i.shadowBlur;n.lineJoin=i.lineJoin;n.lineWidth=i.lineWidth;n.strokeRect(t,r,u,f);n.shadowOffsetX=0;n.shadowOffsetY=0;n.shadowBlur=0;n.lineWidth=1}var i=n.extend({ajaxURL:"",postBrowserInfo:!0,postHTML:!0,postURL:!0,proxy:undefined,letterRendering:!1,initButtonText:"Feedback",strokeStyle:"black",shadowColor:"black",shadowOffsetX:1,shadowOffsetY:1,shadowBlur:10,lineJoin:"bevel",lineWidth:3,html2canvasURL:"/Content/Scripts/Feedback/html2canvas.js",feedbackButton:".feedback-btn",showDescriptionModal:!0,isDraggable:!0,onScreenshotTaken:function(){},tpl:{description:'<div id="feedback-welcome"><div class="feedback-logo">Feedback<\/div><p>You can click on the page to mark the area you want to give feedback about.<\/p><p>Choose the method you want to mark:<\/p><textarea id="feedback-note-tmp"><\/textarea><p>Next we\'ll let you identify areas of the page related to your description.<\/p><button id="feedback-welcome-next" class="feedback-next-btn feedback-btn-gray">Next<\/button><div id="feedback-welcome-error">Please check the description or the email field.<\/div><div class="feedback-wizard-close"><\/div><\/div>',highlighter:'<div id="feedback-highlighter"><div class="feedback-logo">Feedback<\/div><p>You can select an area or send the whole page.<\/p><button class="feedback-sethighlight feedback-active"><div class="ico"><\/div><span>Mark<\/span><\/button><label>Mark the area with the problem.<\/label><button class="feedback-setblackout"><div class="ico"><\/div><span>Black Box<\/span><\/button><label class="lower">You can hide any area you like.<\/label><div class="feedback-buttons"><button id="feedback-highlighter-next" class="feedback-next-btn feedback-btn-gray">Next<\/button><button id="feedback-highlighter-back" class="feedback-back-btn feedback-btn-gray">Back<\/button><\/div><div class="feedback-wizard-close"><\/div><\/div>',overview:'<div id="feedback-overview"><div class="feedback-logo">Feedback<\/div><div id="feedback-overview-description"><div id="feedback-overview-description-text"><h3 id="e-mail-header">E-Mail Address<\/h3><h3>Description<\/h3><h3 class="feedback-additional">Extras<\/h3><div id="feedback-additional-none"><span>None<\/span><\/div><div id="feedback-browser-info"><span>Browser Info<\/span><\/div><div id="feedback-page-info"><span>Page Info<\/span><\/div><div id="feedback-page-structure"><span>Page Structure<\/span><\/div><\/div><\/div><div id="feedback-overview-screenshot"><h3>Ön izleme<\/h3><\/div><div class="feedback-buttons"><button id="feedback-submit" class="feedback-submit-btn feedback-btn-blue">Gönder<\/button><button id="feedback-overview-back" class="feedback-back-btn feedback-btn-gray">Geri<\/button><\/div><div id="feedback-overview-error">Please check the description and the email fields.<\/div><div class="feedback-wizard-close"><\/div><\/div>',submitSuccess:'<div id="feedback-submit-success"><div class="feedback-logo">Feedback<\/div><p>Thank you. You submisson has been sent.<\/p><button class="feedback-close-btn feedback-btn-blue">SAVE<\/button><div class="feedback-wizard-close"><\/div><\/div>',submitError:'<div id="feedback-submit-error"><div class="feedback-logo">Feedback<\/div><p>There was a problem saving your submission. Please try again.<\/p><button class="feedback-close-btn feedback-btn-blue">SAVE<\/button><div class="feedback-wizard-close"><\/div><\/div>'},onClose:function(){},screenshotStroke:!0,highlightElement:!0,initialBox:!1},t),s=!!window.HTMLCanvasElement,e=i.feedbackButton==".feedback-btn",o=!1;if(s){e&&n("body").append('<button class="feedback-btn feedback-btn-gray">'+i.initButtonText+"<\/button>");n(document).on("click",i.feedbackButton,function(){var t;e&&n(this).hide();o||n.getScript(i.html2canvasURL,function(){o=!0});var s=!1,l="",y=n(document).height(),h=n(document).width(),a='<div id="feedback-module">';if(i.initialBox&&(a+=i.tpl.description),a+=i.tpl.highlighter+i.tpl.overview+'<canvas id="feedback-canvas"><\/canvas><div id="feedback-helpers"><\/div><input id="feedback-note" name="feedback-note" type="hidden"><\/div>',n("body").append(a),moduleStyle={position:"absolute",left:"0px",top:"0px"},canvasAttr={width:h,height:y},n("#feedback-module").css(moduleStyle),n("#feedback-canvas").attr(canvasAttr).css("z-index","30000"),i.initialBox||(n("#feedback-highlighter-back").remove(),s=!0,n("#feedback-canvas").css("cursor","crosshair"),n("#feedback-helpers").show(),n("#feedback-welcome").hide(),n("#feedback-highlighter").show()),i.isDraggable)n("#feedback-highlighter").on("mousedown",function(t){var u=n(this).addClass("feedback-draggable"),i=u.outerHeight(),r=u.outerWidth(),f=u.offset().top+i-t.pageY,e=u.offset().left+r-t.pageX;u.css("z-index",4e4).parents().on("mousemove",function(t){_top=t.pageY+f-i;_left=t.pageX+e-r;_bottom=i-t.pageY;_right=r-t.pageX;_left<0&&(_left=0);_top<0&&(_top=0);_right>n(window).width()&&(_left=n(window).width()-r);_left>n(window).width()-r&&(_left=n(window).width()-r);_bottom>n(document).height()&&(_top=n(document).height()-i);_top>n(document).height()-i&&(_top=n(document).height()-i);n(".feedback-draggable").offset({top:_top,left:_left}).on("mouseup",function(){n(this).removeClass("feedback-draggable")})});t.preventDefault()}).on("mouseup",function(){n(this).removeClass("feedback-draggable");n(this).parents().off("mousemove mousedown")});t=n("#feedback-canvas")[0].getContext("2d");t.fillStyle="rgba(102,102,102,0.5)";t.fillRect(0,0,n("#feedback-canvas").width(),n("#feedback-canvas").height());rect={};drag=!1;highlight=1;post={};i.postBrowserInfo&&(post.browser={},post.browser.appCodeName=navigator.appCodeName,post.browser.appName=navigator.appName,post.browser.appVersion=navigator.appVersion,post.browser.cookieEnabled=navigator.cookieEnabled,post.browser.onLine=navigator.onLine,post.browser.platform=navigator.platform,post.browser.userAgent=navigator.userAgent,post.browser.plugins=[],n.each(navigator.plugins,function(n){post.browser.plugins.push(navigator.plugins[n].name)}),n("#feedback-browser-info").show());i.postURL&&(post.url=document.URL,n("#feedback-page-info").show());i.postHTML&&(post.html=n("html").html(),n("#feedback-page-structure").show());i.postBrowserInfo||i.postURL||i.postHTML||n("#feedback-additional-none").show();n(document).on("mousedown","#feedback-canvas",function(t){s&&(rect.startX=t.pageX-n(this).offset().left,rect.startY=t.pageY-n(this).offset().top,rect.w=0,rect.h=0,drag=!0)});n(document).on("mouseup",function(){if(s){drag=!1;var f=rect.startY,e=rect.startX,i=rect.w,u=rect.h;if(dtype="highlight",i==0||u==0)return;i<0&&(e+=i,i*=-1);u<0&&(f+=u,u*=-1);f+u>n(document).height()&&(u=n(document).height()-f);e+i>n(document).width()&&(i=n(document).width()-e);highlight==0&&(dtype="blackout");n("#feedback-helpers").append('<div class="feedback-helper" data-type="'+dtype+'" data-time="'+Date.now()+'" style="position:absolute;top:'+f+"px;left:"+e+"px;width:"+i+"px;height:"+u+'px;z-index:30000;"><\/div>');r(t);rect.w=0}});n(document).on("mousemove",function(i){s&&drag&&(n("#feedback-highlighter").css("cursor","default"),rect.w=i.pageX-n("#feedback-canvas").offset().left-rect.startX,rect.h=i.pageY-n("#feedback-canvas").offset().top-rect.startY,t.clearRect(0,0,n("#feedback-canvas").width(),n("#feedback-canvas").height()),t.fillStyle="rgba(102,102,102,0.5)",t.fillRect(0,0,n("#feedback-canvas").width(),n("#feedback-canvas").height()),n(".feedback-helper").each(function(){n(this).attr("data-type")=="highlight"&&u(t,parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height())}),highlight==1&&(u(t,rect.startX,rect.startY,rect.w,rect.h),t.clearRect(rect.startX,rect.startY,rect.w,rect.h)),n(".feedback-helper").each(function(){n(this).attr("data-type")=="highlight"&&t.clearRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height())}),n(".feedback-helper").each(function(){n(this).attr("data-type")=="blackout"&&(t.fillStyle="rgba(0,0,0,1)",t.fillRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height()))}),highlight==0&&(t.fillStyle="rgba(0,0,0,0.5)",t.fillRect(rect.startX,rect.startY,rect.w,rect.h)))});if(i.highlightElement){var p=[],c=[],v=0;n(document).on("mousemove click","#feedback-canvas",function(i){var f;if(s&&(r(t),c=[],n("#feedback-canvas").css("cursor","crosshair"),n("* :not(body,script,iframe,div,section,.feedback-btn,#feedback-module *)").each(function(){n(this).attr("data-highlighted")!=="true"&&i.pageX>n(this).offset().left&&i.pageX<n(this).offset().left+n(this).width()&&i.pageY>n(this).offset().top+parseInt(n(this).css("padding-top"),10)&&i.pageY<n(this).offset().top+n(this).height()+parseInt(n(this).css("padding-top"),10)&&c.push(n(this))}),f=c[c.length-1],f&&!drag)){n("#feedback-canvas").css("cursor","pointer");var e=f.offset().left-2,o=f.offset().top-2,h=f.width()+parseInt(f.css("padding-left"),10)+parseInt(f.css("padding-right"),10)+6,l=f.height()+parseInt(f.css("padding-top"),10)+parseInt(f.css("padding-bottom"),10)+6;highlight==1&&(u(t,e,o,h,l),t.clearRect(e,o,h,l),dtype="highlight");n(".feedback-helper").each(function(){n(this).attr("data-type")=="highlight"&&t.clearRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height())});highlight==0&&(dtype="blackout",t.fillStyle="rgba(0,0,0,0.5)",t.fillRect(e,o,h,l));n(".feedback-helper").each(function(){n(this).attr("data-type")=="blackout"&&(t.fillStyle="rgba(0,0,0,1)",t.fillRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height()))});i.type=="click"&&i.pageX==rect.startX&&i.pageY==rect.startY&&(n("#feedback-helpers").append('<div class="feedback-helper" data-highlight-id="'+v+'" data-type="'+dtype+'" data-time="'+Date.now()+'" style="position:absolute;top:'+o+"px;left:"+e+"px;width:"+h+"px;height:"+l+'px;z-index:30000;"><\/div>'),p.push(v),++v,r(t))}})}n(document).on("mouseleave","body,#feedback-canvas",function(){r(t)});n(document).on("mouseenter",".feedback-helper",function(){r(t)});n(document).on("click","#feedback-welcome-next",function(){n("#feedback-note").val().length>0?(s=!0,n("#feedback-canvas").css("cursor","crosshair"),n("#feedback-helpers").show(),n("#feedback-welcome").hide(),n("#feedback-highlighter").show()):n("#feedback-welcome-error").show()});n(document).on("mouseenter mouseleave",".feedback-helper",function(i){drag||(rect.w=0,rect.h=0,i.type==="mouseenter"?(n(this).css("z-index","30001"),n(this).append('<div class="feedback-helper-inner" style="width:'+(n(this).width()-2)+"px;height:"+(n(this).height()-2)+'px;position:absolute;margin:1px;"><\/div>'),n(this).append('<div id="feedback-close"><\/div>'),n(this).find("#feedback-close").css({top:n(this).find("#feedback-close").height()/-2+"px",left:n(this).width()-n(this).find("#feedback-close").width()/2+"px"}),n(this).attr("data-type")=="blackout"&&(t.clearRect(0,0,n("#feedback-canvas").width(),n("#feedback-canvas").height()),t.fillStyle="rgba(102,102,102,0.5)",t.fillRect(0,0,n("#feedback-canvas").width(),n("#feedback-canvas").height()),n(".feedback-helper").each(function(){n(this).attr("data-type")=="highlight"&&u(t,parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height())}),n(".feedback-helper").each(function(){n(this).attr("data-type")=="highlight"&&t.clearRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height())}),t.clearRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height()),t.fillStyle="rgba(0,0,0,0.75)",t.fillRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height()),ignore=n(this).attr("data-time"),n(".feedback-helper").each(function(){if(n(this).attr("data-time")==ignore)return!0;n(this).attr("data-type")=="blackout"&&(t.fillStyle="rgba(0,0,0,1)",t.fillRect(parseInt(n(this).css("left"),10),parseInt(n(this).css("top"),10),n(this).width(),n(this).height()))}))):(n(this).css("z-index","30000"),n(this).children().remove(),n(this).attr("data-type")=="blackout"&&r(t)))});n(document).on("click","#feedback-close",function(){if(i.highlightElement&&n(this).parent().attr("data-highlight-id"))var u=n(this).parent().attr("data-highlight-id");n(this).parent().remove();i.highlightElement&&u&&n('[data-highlight-id="'+u+'"]').removeAttr("data-highlighted").removeAttr("data-highlight-id");r(t)});n("#feedback-module").on("click",".feedback-wizard-close,.feedback-close-btn",function(){f()});n(document).on("keyup",function(n){n.keyCode==27&&f()});n(document).on("selectstart dragstart",document,function(n){n.preventDefault()});n(document).on("click","#feedback-highlighter-back",function(){s=!1;n("#feedback-canvas").css("cursor","default");n("#feedback-helpers").hide();n("#feedback-highlighter").hide();n("#feedback-welcome-error").hide();n("#feedback-welcome").show()});n(document).on("mousedown",".feedback-sethighlight",function(){highlight=1;n(this).addClass("feedback-active");n(".feedback-setblackout").removeClass("feedback-active")});n(document).on("mousedown",".feedback-setblackout",function(){highlight=0;n(this).addClass("feedback-active");n(".feedback-sethighlight").removeClass("feedback-active")});n(document).on("click","#feedback-highlighter-next",function(){s=!1;n("#feedback-canvas").css("cursor","default");var e=n(document).scrollTop(),u=n(window).height();n("#feedback-helpers").hide();n("#feedback-highlighter").hide();i.screenshotStroke||r(t,!1);html2canvas(n("body"),{onrendered:function(o){i.screenshotStroke||r(t);_canvas=n('<canvas id="feedback-canvas-tmp" width="'+h+'" height="'+u+'"/>').hide().appendTo("body");_ctx=_canvas.get(0).getContext("2d");_ctx.drawImage(o,0,e,h,u,0,0,h,u);l=_canvas.get(0).toDataURL();n(document).scrollTop(e);post.img=l;i.onScreenshotTaken(post.img);var s=n.session.get("feedBackEmail");i.showDescriptionModal?(n("#feedback-canvas-tmp").remove(),n("#feedback-overview").show(),n("#feedback-overview-description-text>textarea").remove(),n("#feedback-overview-description-text>input").remove(),n("#feedback-overview-screenshot>img").remove(),n('<input id="feedback-email" value="'+(s?s:"")+'"><\/input>').insertAfter("#e-mail-header"),n('<textarea id="feedback-overview-note">'+n("#feedback-note").val()+"<\/textarea>").insertAfter("#feedback-overview-description-text h3:eq(1)"),n("#feedback-overview-screenshot").append('<img class="feedback-screenshot" src="'+l+'" />')):(n("#feedback-module").remove(),f(),_canvas.remove())},proxy:i.proxy,letterRendering:i.letterRendering})});n(document).on("click","#feedback-overview-back",function(){s=!0;n("#feedback-canvas").css("cursor","crosshair");n("#feedback-overview").hide();n("#feedback-helpers").show();n("#feedback-highlighter").show();n("#feedback-overview-error").hide()});n(document).on("keyup","#feedback-note-tmp,#feedback-overview-note",function(t){var i;t.target.id==="feedback-note-tmp"?i=n("#feedback-note-tmp").val():(i=n("#feedback-overview-note").val(),n("#feedback-note-tmp").val(i));n("#feedback-note").val(i)});n(document).on("click","#feedback-submit",function(){s=!1;n("#feedback-note").val().length>0&&n("#feedback-email").val().length>0?(n("#feedback-submit-success,#feedback-submit-error").remove(),n("#feedback-overview").hide(),post.note=n("#feedback-note").val(),post.mail=n("#feedback-email").val(),n.session.set("feedBackEmail",post.mail),post.html=null,_appController.busy(!0),_appController.postData(post,i.ajaxURL).done(function(t){if(console.log("done",t),_appController.busy(!1),t.code!=200){n("#feedback-module").append(i.tpl.submitError);return}n("#feedback-module").append(i.tpl.submitSuccess);return}).fail(function(t){_appController.busy(!1);console.log("fail err:",t);n("#feedback-module").append(i.tpl.submitError)})):n("#feedback-overview-error").show()})})}}})(jQuery)