text: ﻿var ScoreController=function(){function n(){}return n.prototype.index=function(n,t,i){createTypeahead("#Title",n);createTypeahead("#Issn",t);createTypeahead("#Publisher",i)},n.prototype.baseScoreCardDetails=function(){$('.scoreCardAspects a[data-select-tab="true"]').on("click",function(){return $('#scoreTabs a[href="'+$(this).attr("href")+'"]').tab("show"),!1})},n.prototype.valuationScoreCardDetails=function(){$('.scoreCardAspects a[data-select-tab="true"]').on("click",function(){return $('#scoreTabs a[href="'+$(this).attr("href")+'"]').tab("show"),!1})},n.prototype.baseScoreCard=function(n,t,i){var f=function(){var n=document.getElementById("spinner"),t=new Spinner({lines:11,length:4,width:3,radius:6,corners:1,rotate:0,direction:1,color:"#000",speed:1,trail:60,shadow:!1,hwaccel:!1,className:"spinner",zIndex:2e9,top:"auto",left:"auto"}).spin(n)},r,u;f();r=null;u=4;$('.scoreCardAspects a[data-select-tab="true"], #OverviewTab a[data-select-tab="true"]').on("click",function(){return $('#scoreTabs a[href="'+$(this).attr("href")+'"]').tab("show"),!1});var e=function(n,t){var r=this,i=ko.utils.arrayFilter(t,function(t){return t.QuestionCategory()==n});r.completed=ko.computed(function(){return ko.utils.arrayFirst(i,function(n){return n.Score()==0})==null});r.partOfBaseScore=function(){return n!=u};r.score=ko.computed(function(){if(i.length==0)return 0;var n=0;return ko.utils.arrayForEach(i,function(t){n+=t.Score()}),Math.round(n/i.length*10)/10})},o=function(n,t){var r=this,i=ko.utils.arrayFirst(t,function(t){return t.QuestionKey()==n});r.score=ko.computed({read:function(){return i.Score()},write:function(n){i.Score(+n)}})},s=function(u){var f=this,h,s;f.IsOutDatedPublicationArticle=ko.observable(n?f.IsOutDatedPublicationArticle:!1);f.IsOutDatedPublicationPage=ko.observable(n?f.IsOutDatedPublicationPage:!1);ko.mapping.fromJS(u,{},f);h=ko.utils.arrayGetDistinctValues(ko.utils.arrayMap(f.QuestionScores(),function(n){return n.QuestionCategory()}));f.publishing=ko.observable(!1);f.storingScoreCard=ko.observable(!1);f.getRequestVerificationToken=function(){return $('#journalScoreForm input[name="__RequestVerificationToken"]').val()};f.storeScoreCard=function(){return r!=null&&r.abort(),f.storingScoreCard(!0),r=$.ajax({type:"POST",url:t,contentType:"application/json",data:ko.utils.stringifyJson(ko.mapping.toJS(f)),dataType:"json",headers:{__RequestVerificationToken:f.getRequestVerificationToken()}}).always(function(){f.storingScoreCard(!1)})};f.publishScoreCard=function(){f.publishing(!0);f.Publish(!0);f.storeScoreCard().done(function(){$("#publishedModal").modal().on("hide.bs.modal",function(){window.location.href=i})}).fail(function(){alert("Something failed!");f.publishing(!1)})};f.categoryScores=ko.observableArray();f.questionScores=ko.observableArray();f.baseScore=ko.computed(function(){return ko.utils.arrayMap(ko.utils.arrayFilter(f.categoryScores(),function(n){return n.partOfBaseScore()&&n.completed()}),function(n){return n.score()}).sort()[0]||0});f.priceQuesionAnswered=ko.computed(function(){return typeof f.Price.FeeType=="function"&&f.Price.FeeType()==null?0:1});f.progress=ko.computed(function(){var n=ko.utils.arrayFilter(f.QuestionScores(),function(n){return n.Score()>0}).length,t=f.QuestionScores().length+1,i=f.priceQuesionAnswered();return Math.round((n+f.priceQuesionAnswered())/t*100)});f.progressPercentage=ko.computed(function(){return f.progress()+"%"});f.progressClass=ko.computed(function(){var n=f.progress();return n<50?"progress-bar-danger":n<100?"progress-bar-warning":"progress-bar-success"});ko.utils.arrayForEach(h,function(n){f.categoryScores.push(new e(n,f.QuestionScores()))});ko.utils.arrayForEach(f.QuestionScores(),function(n){f.questionScores.push(new o(n.QuestionKey(),f.QuestionScores()))});f.canPublish=ko.computed(function(){return f.progress()>=100&&!f.publishing()});$("input[type=radio][name=outdatedPublication]").bind("click",function(){var n=$(this).val();f.Price.FeeType=n;switch(n){case"Article":f.IsOutDatedPublicationArticle(!0);f.IsOutDatedPublicationPage(!1);break;case"Page":f.IsOutDatedPublicationArticle(!1);f.IsOutDatedPublicationPage(!0);break;default:f.IsOutDatedPublicationArticle(!1);f.IsOutDatedPublicationPage(!1)}});(n.Price.Amount!=null||f.progress()>=100)&&$("input[type=radio][name=outdatedPublication]").each(function(t){n.Price.FeeType==t&&($(this).prop("checked",!0),$(this).trigger("click"))});n.State==0&&(s=$("#saved"),f.questionScoresDirtyFlag=new ko.dirtyFlag(f.questionScores,!1),f.remarksDirtyFlag=new ko.dirtyFlag(f.Remarks,!1),f.editorDirtyFlag=new ko.dirtyFlag(f.Editor,!1),f.priceDirtyFlag=new ko.dirtyFlag(f.Price,!1),f.isDirty=ko.computed(function(){return f.questionScoresDirtyFlag.isDirty()||f.remarksDirtyFlag.isDirty()||f.editorDirtyFlag.isDirty()||f.priceDirtyFlag.isDirty()},f).extend({throttle:2e3}),f.isDirty.subscribe(function(n){n&&!f.publishing()&&(f.Publish(!1),s.hide(),f.storeScoreCard().done(function(){s.show().delay(200).fadeOut(2e3);f.questionScoresDirtyFlag.reset(f.questionScores);f.remarksDirtyFlag.reset(f.Remarks);f.editorDirtyFlag.reset(f.Editor);f.priceDirtyFlag.reset(f.Price)}))}))},h=new s(n);ko.applyBindings(h)},n.prototype.valuationScoreCard=function(n,t,i){var f=function(){var n=document.getElementById("spinner"),t=new Spinner({lines:11,length:4,width:3,radius:6,corners:1,rotate:0,direction:1,color:"#000",speed:1,trail:60,shadow:!1,hwaccel:!1,className:"spinner",zIndex:2e9,top:"auto",left:"auto"}).spin(n)},r,u;f();r=null;u=4;$('.scoreCardAspects a[data-select-tab="true"], #OverviewTab a[data-select-tab="true"]').on("click",function(){return $('#scoreTabs a[href="'+$(this).attr("href")+'"]').tab("show"),!1});var e=function(n,t){var r=this,i=ko.utils.arrayFilter(t,function(t){return t.QuestionCategory()==n});r.completed=ko.computed(function(){return ko.utils.arrayFirst(i,function(n){return n.Score()==0})==null});r.partOfBaseScore=function(){return n!=u};r.score=ko.computed(function(){if(i.length==0)return 0;var n=0;return ko.utils.arrayForEach(i,function(t){n+=t.Score()}),Math.round(n/i.length*10)/10})},o=function(n,t){var r=this,i=ko.utils.arrayFirst(t,function(t){return t.QuestionKey()==n});r.score=ko.computed({read:function(){return i.Score()},write:function(n){i.Score(+n)}})},s=function(u){var f=this,s,c,h;ko.mapping.fromJS(u,{},f);s=$("#isEditorComment").val();c=ko.utils.arrayGetDistinctValues(ko.utils.arrayMap(f.QuestionScores(),function(n){return n.QuestionCategory()}));f.publishing=ko.observable(!1);f.storingScoreCard=ko.observable(!1);f.getRequestVerificationToken=function(){return $('#journalScoreForm input[name="__RequestVerificationToken"]').val()};f.storeScoreCard=function(){return r!=null&&r.abort(),f.storingScoreCard(!0),r=$.ajax({type:"POST",url:t,contentType:"application/json",data:ko.utils.stringifyJson(ko.mapping.toJS(f)),dataType:"json",headers:{__RequestVerificationToken:f.getRequestVerificationToken()}}).always(function(){f.storingScoreCard(!1)})};f.publishScoreCard=function(){f.publishing(!0);f.Publish(!0);f.storeScoreCard().done(function(){$("#publishedModal").modal().on("hide.bs.modal",function(){window.location.href=i})}).fail(function(){alert("Something failed!");f.publishing(!1)})};f.categoryScores=ko.observableArray();f.questionScores=ko.observableArray();f.valuationScore=ko.computed(function(){return ko.utils.arrayMap(ko.utils.arrayFilter(f.categoryScores(),function(n){return!n.partOfBaseScore()&&n.completed()}),function(n){return n.score()}).sort()[0]||0});f.progress=ko.computed(function(){var n=ko.utils.arrayFilter(f.QuestionScores(),function(n){return n.Score()>0}).length,t=f.QuestionScores().length;return Math.round(n/t*100)});f.progressPercentage=ko.computed(function(){return f.progress()+"%"});f.progressClass=ko.computed(function(){var n=f.progress();return n<50?"progress-bar-danger":n<100?"progress-bar-warning":"progress-bar-success"});ko.utils.arrayForEach(c,function(n){f.categoryScores.push(new e(n,f.QuestionScores()))});ko.utils.arrayForEach(f.QuestionScores(),function(n){f.questionScores.push(new o(n.QuestionKey(),f.QuestionScores()))});f.canPublish=ko.computed(function(){return f.progress()>=100&&!f.publishing()});f.onRemarksFocus=function(){$(this).val()==s&&$(this).val("")};f.onRemarksBlur=function(){$(this).val()==""&&$(this).val(s)};f.Editor.subscribe(function(n){var t=$("#remarks");if(n){t.val(s);t.on("focus",f.onRemarksFocus).on("blur",f.onRemarksBlur)}else t.val(""),t.off("focus",f.onRemarksFocus).off("blur",f.onRemarksBlur)});$("input[type=radio][name=IsPublishedWithinYearRadio]").bind("click",function(){var n=$(this).val()=="true";f.Submitted(n)});(n.Price.Amount!=null||f.progress()>=100)&&$("input[type=radio][name=IsPublishedWithinYearRadio]").each(function(){$(this).val()==n.Submitted.toString()&&$(this).prop("checked",!0)});n.State==0&&(h=$("#saved"),f.questionScoresDirtyFlag=new ko.dirtyFlag(f.questionScores,!1),f.remarksDirtyFlag=new ko.dirtyFlag(f.Remarks,!1),f.editorDirtyFlag=new ko.dirtyFlag(f.Editor,!1),f.submittedDirtyFlag=new ko.dirtyFlag(f.Submitted,!1),f.priceDirtyFlag=new ko.dirtyFlag(f.Price,!1),f.isDirty=ko.computed(function(){return f.questionScoresDirtyFlag.isDirty()||f.remarksDirtyFlag.isDirty()||f.editorDirtyFlag.isDirty()||f.submittedDirtyFlag.isDirty()||f.priceDirtyFlag.isDirty()},f).extend({throttle:2e3}),f.isDirty.subscribe(function(n){n&&!f.publishing()&&(f.Publish(!1),h.hide(),f.storeScoreCard().done(function(){h.show().delay(200).fadeOut(2e3);f.questionScoresDirtyFlag.reset(f.questionScores);f.remarksDirtyFlag.reset(f.Remarks);f.editorDirtyFlag.reset(f.Editor);f.submittedDirtyFlag.reset(f.Submitted);f.priceDirtyFlag.reset(f.Price)}))}))},h=new s(n);ko.applyBindings(h)},n}();
  /*
  //# sourceMappingURL=ScoreController.min.js.map
  */