14aa.716912755037dcf5abf6.js 14.7 KB
(window.webpackJsonp=window.webpackJsonp||[]).push([["14aa"],{"G5a/":function(e,t,n){"use strict";n("QTG7"),n("B1Un"),n("mxFJ"),n("9RjJ");var o=n("hh57"),i=function(e,t,n){console.log(e,t,n),n=void 0===n?"0":n,$.ajax({url:"/comments/"+e+"/vote",type:"POST",data:{vote:t,postID:n}}).done(function(){var n=parseInt($("#comment"+e+" .comment-score").html(),10)+t;$("#comment"+e+" .comment-score").html(n+" "),0!==n?$("#comment"+e+" .comment-score").show():$("#comment"+e+" .comment-score").hide()}).fail(function(t){t.responseJSON.errors&&Object(o.a)(t.responseJSON.errors,".comment-action-errors","#comment"+e)})};!function(e){var t,n,o,m,c,a,s,r=window.location.toString().indexOf("/forum")>-1?"forum":"comments",l={};function u(){if(null!=e("#comments-json-data").html()){var t=e.parseJSON(e("#comments-json-data").html());t&&(l=t.cursor,c=t.discussionId,a=t.filter||"all",s=t.without),e("#comments-json-data").remove()}}function d(){l.next?(m.click(p),m.addClass("enabled"),m.show()):m.hide()}function p(){var t;m.unbind("click"),m.removeClass("enabled"),t=function(e){o.append(e),u(),d(),I()},e.ajax({url:"/comments-pagelet",data:{discussionId:c,cursor:l.next,since:l.since,filter:a,without:s},success:t})}function f(n,i,m){if(m>0){var c=e("#comment"+m,t).nextUntil(":not(.reply-comment)").last();c.length<1&&(c=e("#comment"+m,t)),c.after(n)}else o.prepend(n);e("body").scrollTo("#comment"+i,300,{offset:{top:-150}}),e("#comment"+i).animate({opacity:.25},500).animate({opacity:1},500).animate({opacity:.25},500).animate({opacity:1},500)}function g(n,o){"forum"!=r?(e(".comment-history[data-commentId="+n+"]").remove(),e("#comment"+n,t).replaceWith(o)):window.location.reload()}function h(t){e.post("/comments/"+t+"/approval",{approved:!0}),e("#comment"+t).css("background","#fff")}function v(t,n){e.post("/comments/"+t+"/approval",{approved:!1,reason:n}),e("#comment"+t).css("background","#F33")}function I(){var t=new RegExp('(")?\\b('+["fuck","fucker","fucking","nigger","niger","niggers","nigers","cunt","pussy","bitch","whore","motherfucker","shit"].join("|")+")\\b","gi");n.find(".comment-text *").each(function(){var n=e(this);n.children().length||n.html(n.html().replace(t,function(e,t){return t?e:'<span title="'+e+'">'+Array(e.length+1).join("*")+"</span>"}))})}e(document).ready(function(){var c;t=e("#"+r),n=t.find(".comment-list"),o=t.find(".all-comments"),m=t.find(".load-more-comments"),u(),e(".timeago",t).timeago(),n.on("click",".js-show-comment-dropdown",function(t){var n=e(this).closest(".comment").find(".comment-dropdown");n.toggle(),t.stopPropagation(),e(document).one("click",function(){n.hide()})}),n.on("click",".js-vote-up",function(){i(e(this).closest(".comment").attr("commentID"),1,e(this).closest(".comment").attr("postID"))}),n.on("click",".js-vote-down",function(){i(e(this).closest(".comment").attr("commentID"),-1,e(this).closest(".comment").attr("postID"))}),n.on("click",".js-comment-reply",function(){var t=e(this).closest(".comment").attr("commentID");e.publish("fr.comments.reply",[t])}),n.on("click",".cm-approve",function(){var t,n,o=e(this).closest(".comment");void 0!==o.attr("postID")?(t=o.attr("postID"),n=o.attr("commentID"),e.post("/forum/discussions/"+t+"/status",{status:"publish"}).success(function(e){h(n)}),e('.comment[postid="'+t+'"]').css("background","#fff")):h(o.attr("commentID")),e(".comment-dropdown").hide()}),n.on("click",".cm-remove",function(){var t=e(this).closest(".comment"),n=e("#comment-remove-wizard-template");if(!t.find(".comment-remove-wizard").length){if(!n.length)return v(t.attr("commentID"),"");var o=e(n.html());t.append(o),o.find(".js-cancel").click(function(){o.remove()}),o.find(".js-ok").click(function(){var n,i,m;void 0!==t.attr("postID")?(n=t.attr("postID"),i=t.attr("commentID"),m=o.find(".reason").val(),e.post("/forum/discussions/"+n+"/status",{status:"draft"}).success(function(e){v(i,m)}),e('.comment[postid="'+n+'"]').css("background","#F33")):v(t.attr("commentID"),o.find(".reason").val()),o.remove()}),e(".comment-dropdown").hide()}}),n.on("click",".cm-revise",function(){var t=e(this).closest(".comment").attr("commentID"),n=e(this).closest(".comment").attr("discussionId");n.indexOf("forumPost")>=0||(e.publish("fr.comments.edit",[t]),e(".comment-dropdown").hide())}),n.one("click",".cm-settings",function(){!function t(n){var o=e("#comment"+n),i=_.template(e("#post-settings-template").html());e(o).after(i({commentID:n}));var m=e(o).attr("postID");e("#post-settings .settings-confirm").click(function(){var t=e("#post-settings form").serialize();e.post("/forum/discussions/"+m+"/settings",t).success(function(e){window.location.reload()}).error(function(){alert("Something went wrong. Try again.")})}),e("#post-settings .settings-cancel").click(function(){e("#post-settings").remove(),e(".cm-settings").click(function(){t(e(this).closest(".comment").attr("commentID")),e(this).unbind("click")})})}(e(this).closest(".comment").attr("commentID")),e(this).unbind("click"),e(".comment-dropdown").hide()}),n.on("click",".cm-edited",function(){var t=e(this).closest(".comment").attr("commentID");e(".comment-history[data-commentId="+t+"]").toggle(),e(".comment-dropdown").hide()}),n.on("click",".cm-flag",function(){var t,n=e(this).closest(".comment").attr("commentID");t=n,angular.injector(["ng","footyroom"]).get("$uibModal").open({template:'<fr-comment-flagger comment-id="'+t+'" dismiss="$dismiss()"></fr-comment-flagger>'})}),c=!1,n.on("click",".bad-comment-notice a",function(){e(this).parent().parent().find(".comment-content").toggle(),(c=!c)?e(this).html("(hide)"):e(this).html("(show)")}),n.on("click",".cm-ban",function(){e("html").scope().openBanModal(this.dataset.userId),e(".comment-dropdown").hide()}),n.on("click",".cm-voters",function(){var t=e(this).closest(".comment"),n=t.attr("commentID");e.get("/vote/votes.json",{pollRef:"comment-karma-".concat(n)},function(e){var n=e.data.map(function(e){return"<span ".concat(1===e.value?'class="comment-voter"':'class="comment-voter comment-voter--downvote"',">").concat(e.username,"</span>")});t.find(".comment-voters").html(n.join(""))})}),e(".comment-list > .reply-comment").each(function(){var t=e(this).attr("commentId");e('<div class="show-parent-comment">Click here to see parent comment</div>').insertBefore(this).click(function(){e(this).remove(),e.get("/comments/"+t+"/parent-pagelet").then(function(n){e(n).insertBefore("#comment"+t)})})}),n.on("click",".comment-text img:not(.poll-image)",function(){window.open(e(this).attr("src"),"_blank")}),d(),I(),e.subscribe("fr.commenter.edited",g),"comments"==r&&e.subscribe("fr.commenter.posted",f);var a=e.QueryString.commentId;a&&setTimeout(function(){e("body").scrollTo("#comment"+a)},0)})}(jQuery)},NPPL:function(e,t){angular.module("footyroom").directive("imageUploader",["$http","upload",function(e,t){return{templateUrl:"/views/ng/modal/insert-image.html?2",link:function(e,n){e.fileChooser=function(){setTimeout(function(){n.find('input[type="file"]').trigger("click")},0)},e.addImage=function(){e.image?(n.litelay({spinner:!0}),t("/comments/upload-image",{max_file_size:512e3,image:e.image}).then(function(e){return e.data.url}).catch(function(e){throw e.data.errors?e.data.errors:413===e.status?"Image size exceeds maximum allowable size.":"Something went wrong. Please try again."}).then(function(t){e.$close(t)}).catch(function(t){e.errors=t}).finally(function(){n.litelay()})):e.imageUrl&&e.$close(e.imageUrl)},e.reset=function(){e.image=null,e.imageDataUrl=null,e.imageUrl=null,e.errors=null}}}}]).service("upload",["$http",function(e){return function(t,n){var o=new FormData;return _.each(n,function(e,t){o.append(t,e)}),e.post(t,o,{transformRequest:angular.identity,headers:{"Content-Type":void 0}})}}]).directive("fileReader",[function(){return{scope:{file:"=",fileDataUrl:"="},link:function(e,t){t.bind("change",function(t){e.file=t.target.files[0];var n=new FileReader;n.onload=function(t){e.$apply(function(){e.fileDataUrl=t.target.result})},n.readAsDataURL(e.file),this.value=null})}}}])},QTG7:function(e,t){angular.module("footyroom").component("frCommentFlagger",{templateUrl:"/views/ng/comments/commentFlagger.html",bindings:{commentId:"@",dismiss:"&"},controller:["$http",function(e){var t=this;t.submit=function(){t.voting=!0,e.post("/comments/"+t.commentId+"/flag",{flagName:t.selectedChoice}).then(function(){t.success=!0}).catch(function(e){t.errors=e.data.errors}).finally(function(){t.voting=!1})}}]})},la2R:function(module,__webpack_exports__,__webpack_require__){"use strict";var _vendor_jquery_cookie__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__("oqG6"),_vendor_jquery_cookie__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_vendor_jquery_cookie__WEBPACK_IMPORTED_MODULE_0__),_comments__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__("G5a/"),_common_directives_imageUploader__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__("NPPL"),_common_directives_imageUploader__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_common_directives_imageUploader__WEBPACK_IMPORTED_MODULE_2__),_vendor_tiny_pubsub__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__("9RjJ"),_vendor_tiny_pubsub__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(_vendor_tiny_pubsub__WEBPACK_IMPORTED_MODULE_3__),_common_showErrors__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__("hh57");!function($){var el,statusText=null,actionMenu,settings,currentMode="normal",commenterHash=Math.random().toString(36).substr(2,5),elCommentInput,elCommentParent,elAddImage,elErrors,elImages,elImagesList,defaults={submit:"default",charsLimit:800,elErrors:".commenter-errors"},images=[];function replyMode(e){currentMode="reply",buildActionMenu(),$(el).insertAfter($("#comment"+e)),$(el).addClass("reply"),$('input[name="parent"]',el).val(e),elCommentInput.focus()}function editMode(e,t){var n=$("#comment"+e+" .comment-text").first();resetCommenter("edit"),$(el).insertAfter($("#comment"+e)),$(el).addClass("reply"),$('input[name="comment_id"]',el).val(e),elCommentInput.focus(),n.find("img").each(function(){addImage($(this).attr("src"))}),elCommentInput.val(n.html().replace(/<br ?\/?>/gi,"").replace(/<img.*?\/?>/gi,""))}function getRange(){return window.getSelection?window.getSelection().getRangeAt(0):"None"==document.selection.type?"":document.selection.createRange()}function buildActionMenu(){$(actionMenu).html("").append(function(){return $('<li class="submit">SAY IT</li>').one("click",function(){submit()})}),["reply","edit"].indexOf(currentMode)>-1&&$(actionMenu).append(function(){return $('<li class="cancel">CANCEL</li>').click(function(){resetCommenter()})})}function submit(){if($(".box",el).litelay(),$(".guest-fields input",el).prop("disabled",!0),elCommentInput.val().length>settings.charsLimit)return Object(_common_showErrors__WEBPACK_IMPORTED_MODULE_4__.a)(["Your post is too long. Maximum of "+settings.charsLimit+" characters is allowed."],settings.elErrors),$(".box",el).litelay(),$(".guest-fields input",el).prop("disabled",!1),buildActionMenu(),!1;"edit"==currentMode?submitEdit():"default"==settings.submit?onSubmit():eval(settings.submit)(function(){$(".box",el).litelay(),$(".guest-fields input",el).prop("disabled",!1),buildActionMenu()})}function modal(){return angular.injector(["ng","footyroom"]).get("$uibModal")}function addImageWizard(){modal().open({template:"<image-uploader></image-uploader>"}).result.then(function(e){addImage(e)})}function insertVideoWizard(){modal().open({templateUrl:"/views/ng/modal/insert-video.html"}).result.then(function(e){insertVideo(e)})}function addImage(e){e=e||$(".image-link-input",el).val(),images.push(e),elImagesList.append('<div class="image" style="background-image: url('+e+');"><span class="remove-image icn-close pointer"></span></div>'),elImages.show(),images.length>=2&&elAddImage.hide()}function removeImage(){var e=$(this).closest(".image");images.splice(elImagesList.find(".image").index(e),1),e.remove(),0===images.length&&elImages.hide(),images.length<2&&elAddImage.show()}function onSubmit(){var e=elCommentInput.val(),t=$('input[name="post_id"]',el).val(),n=$('input[name="parent"]',el).val(),o=$('input[name="author"]',el).val(),i=$('input[name="email"]',el).val(),m=$('input[name="teamname"]',el).val(),c={comment:e,commentableId:t,parent:n,authorName:o,email:i,teamname:m,images:images};return o&&($.cookie("author",o,{expires:3650,path:"/"}),$.cookie("email",i,{expires:3650,path:"/"}),$.cookie("teamname",m,{expires:3650,path:"/"})),$.ajax({url:settings.action,type:"POST",data:c,dataType:"json"}).done(function(e){resetCommenter(),$.publish("fr.commenter.posted",[e.view,e.commentId,n]),window.localStorage.removeItem("commentContent"),e.url&&(window.location=e.url)}).fail(function(e){e.responseJSON.errors&&Object(_common_showErrors__WEBPACK_IMPORTED_MODULE_4__.a)(e.responseJSON.errors,settings.elErrors)}).always(function(){$(".box",el).litelay(),$(".guest-fields input",el).prop("disabled",!1),buildActionMenu()}),!1}function submitEdit(){var e=elCommentInput.val(),t=$('input[name="comment_id"]',el).val(),n={comment:e,images:images,method:"PUT"};$.ajax({url:settings.action+"/"+t,type:"PUT",data:n,dataType:"json"}).done(function(e){resetCommenter(),$.publish("fr.commenter.edited",[t,e.view])}).fail(function(e){e.responseJSON.errors&&Object(_common_showErrors__WEBPACK_IMPORTED_MODULE_4__.a)(e.responseJSON.errors,settings.elErrors)}).always(function(){$(".box",el).litelay(),buildActionMenu()})}function resetCommenter(e){currentMode=e||"normal",elCommentInput.val(""),elCommentParent.val(0),elErrors.html("").hide(),elImagesList.find(".image").remove(),elAddImage.show(),elImages.hide(),images=[],"normal"===currentMode&&($(el).removeClass("reply"),elCommentParent.val(0),$("#commenter-"+commenterHash).after(el)),buildActionMenu()}function charsLeftUpdate(){var e=settings.charsLimit-elCommentInput.val().length;e<0&&(e=0),$(".comment-remaining-count",el).text(e+" characters remaining"),e<100?$(".comment-remaining-count",el).show():$(".comment-remaining-count",el).hide()}$.fn.commenter=function(e){el=this,settings=$.extend({},defaults,e),elCommentInput=$(".comment-input",el),elCommentParent=$('input[name="parent"]',el),elErrors=$(settings.elErrors),elImages=$(".images"),elImagesList=$(".images-list"),elAddImage=$(".insert-image, .add-image",el),elCommentInput.val(window.localStorage.getItem("commentContent")),actionMenu=$(".right-menu",this),elAddImage.click(addImageWizard),$(".insert-video",this).click(insertVideoWizard),elAddImage.hover(function(){$(".status",el).html("Add Image")},function(){$(".status",el).html(statusText)}),$(".insert-video",this).hover(function(){$(".status",el).html("Insert Video")},function(){$(".status",el).html(statusText)}),el.on("click",".remove-image",removeImage),elCommentInput.on("propertychange input keyup",function(){charsLeftUpdate(),window.localStorage.setItem("commentContent",elCommentInput.val())}),$('<div id="commenter-'+commenterHash+'"></div>').insertBefore(el),$.subscribe("fr.comments.reply",replyMode),$.subscribe("fr.comments.edit",editMode),buildActionMenu()}}(jQuery)}}]);