diff --git a/app/views/external.php b/app/views/external.php index bd4c3f8..7a24d4c 100644 --- a/app/views/external.php +++ b/app/views/external.php @@ -255,7 +255,7 @@ public function results( $el->type('checkbox'); $el->inline(true); $el->label($project['project']); - $el->name('projects[]'); + $el->name("projects[{$project['id']}]"); $el->value($project['id']); $project_checks .= $el->render(); @@ -337,7 +337,7 @@ public function results( $el->id("tag-checkbox-$i-$j"); $el->type('checkbox'); - $el->name("tags[]"); + $el->name("tags[{$j}]"); $el->value($tag_id); $el->label($tag); $el->inline(true); diff --git a/app/views/import.php b/app/views/import.php index c4e5bb4..ff17344 100644 --- a/app/views/import.php +++ b/app/views/import.php @@ -305,7 +305,7 @@ public function uid(array $projects, array $tags) { $el->type('checkbox'); $el->inline(true); $el->label($project['project']); - $el->name('projects[]'); + $el->name("projects[{$project['id']}]"); $el->value($project['id']); $project_checks .= $el->render(); @@ -504,7 +504,7 @@ public function manual(array $projects, array $tags) { $el->id('new-author-last'); $el->addClass("input-typeahead"); $el->groupClass('col'); - $el->name('author_last_name[]'); + $el->name('author_last_name[0]'); $el->label($this->lang->t9n('Last name')); $el->source(IL_BASE_URL . "index.php/filter/author"); $new_last_name = $el->render(); @@ -516,7 +516,7 @@ public function manual(array $projects, array $tags) { $el->id('new-author-first'); $el->groupClass('col'); - $el->name('author_first_name[]'); + $el->name('author_first_name[0]'); $el->label($this->lang->t9n('First name')); $new_first_name = $el->render(); @@ -550,7 +550,7 @@ public function manual(array $projects, array $tags) { $el->id('new-editor-last'); $el->addClass("input-typeahead"); $el->groupClass('col'); - $el->name('editor_last_name[]'); + $el->name('editor_last_name[0]'); $el->label($this->lang->t9n('Last name')); $el->source(IL_BASE_URL . "index.php/filter/editor"); $new_last_name = $el->render(); @@ -562,7 +562,7 @@ public function manual(array $projects, array $tags) { $el->id('new-editor-first'); $el->groupClass('col'); - $el->name('editor_first_name[]'); + $el->name('editor_first_name[0]'); $el->label($this->lang->t9n('First name')); $new_first_name = $el->render(); @@ -594,7 +594,7 @@ public function manual(array $projects, array $tags) { $el = $this->di->get('Select'); $el->groupClass('col-sm-3'); - $el->name('uid_types[]'); + $el->name('uid_types[0]'); $el->id('new-uid-type'); $el->label($this->lang->t9n('UID type')); $el->option('', ''); @@ -611,7 +611,7 @@ public function manual(array $projects, array $tags) { $el->id('new-uid'); $el->groupClass('col-sm-9'); - $el->name('uids[]'); + $el->name('uids[0]'); $el->label('UID'); $uid_html .= $el->render(); @@ -863,7 +863,7 @@ public function manual(array $projects, array $tags) { $el->type('checkbox'); $el->inline(true); $el->label($project['project']); - $el->name('projects[]'); + $el->name("projects[{$project['id']}]"); $el->value($project['id']); $project_checks .= $el->render(); @@ -928,7 +928,7 @@ public function manual(array $projects, array $tags) { $el->id('tag-checkbox-' . $i); $el->type('checkbox'); - $el->name("tags[]"); + $el->name("tags[{$i}]"); $el->value($tag_id); $el->label($tag); $el->inline(true); @@ -1162,7 +1162,7 @@ public function file(array $projects, array $tags) { $el->type('checkbox'); $el->inline(true); $el->label($project['project']); - $el->name('projects[]'); + $el->name("projects[{$project['id']}]"); $el->value($project['id']); $project_checks .= $el->render(); @@ -1395,7 +1395,7 @@ public function text(array $projects, array $tags) { $el->type('checkbox'); $el->inline(true); $el->label($project['project']); - $el->name('projects[]'); + $el->name("projects[{$project['id']}]"); $el->value($project['id']); $project_checks .= $el->render(); diff --git a/public/index.php b/public/index.php index 0d9c2b6..c86278a 100644 --- a/public/index.php +++ b/public/index.php @@ -6,7 +6,7 @@ /* * I, Librarian version. */ -define('IL_VERSION', '5.9.2'); +define('IL_VERSION', '5.9.3'); /* * Define paths. diff --git a/public/js/script.js b/public/js/script.js index a4ea696..89c926f 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -2901,14 +2901,14 @@ class EditMainView extends View { }); } _selectAuthor(typeahead) { - if ($(typeahead).attr('name') === 'author_last_name[]') { - let $first = $(typeahead).closest('.form-row').find('input[name="author_first_name\\[\\]"]'); + if ($(typeahead).is("[name^='author_last_name']")) { + let $first = $(typeahead).closest('.form-row').find('input[name^="author_first_name"]'); let names = $(typeahead).val().split(','); $(typeahead).val($.trim(names[0] || '')); $first.val($.trim(names[1] || '')); } - if ($(typeahead).attr('name') === 'editor_last_name[]') { - let $first = $(typeahead).closest('.form-row').find('input[name="editor_first_name\\[\\]"]'); + if ($(typeahead).is("[name^='editor_last_name']")) { + let $first = $(typeahead).closest('.form-row').find('input[name^="editor_first_name"]'); let names = $(typeahead).val().split(','); $(typeahead).val($.trim(names[0] || '')); $first.val($.trim(names[1] || '')); diff --git a/public/js/script.min.js b/public/js/script.min.js index 6581522..b87c978 100644 --- a/public/js/script.min.js +++ b/public/js/script.min.js @@ -1 +1 @@ -"use strict";jQuery.fn.extend({insertAtCaret:function(e){return this.each(function(t){if(document.selection){this.focus(),document.selection.createRange().text=e,this.focus()}else if(this.selectionStart||0===this.selectionStart){let t=this.selectionStart,i=this.selectionEnd,a=this.scrollTop;this.value=this.value.substring(0,t)+e+this.value.substring(i,this.value.length),this.focus(),this.selectionStart=t+e.length,this.selectionEnd=t+e.length,this.scrollTop=a}else this.value+=e,this.focus()})}}),window.IL=[],window.charts=[],window.tables=[];let _=window._,B=window.Backbone;$.widget("il.typeahead",{searchId:"",ignoredKeys:[9,13,16,17,18,20,27,33,34,35,36,37,38,39,40,45],options:{delay:300,minLength:0,source:""},_getCreateOptions:function(){return{delay:this.element.attr("data-delay"),minLength:this.element.attr("data-minLength"),source:this.element.attr("data-source")}},_create:function(){this._on(this.element,{input:this._search,focus:this._search});let e=this.element.parent().next();this._on(e,{"click button":function(e){this.element.val($(e.target).text()).attr("data-id",$(e.target).attr("data-id")),this._clearMenus(),this._trigger("onSelect",null,{element:this.element})}}),this._on(e,{"keyup button":function(e){e.stopPropagation(),38===e.which&&$(e.target).prev().focus(),40===e.which&&$(e.target).next().focus(),27===e.which&&(this.element.focus(),this._clearMenus())}}),this._on("body",{click:this._clearMenus}),this._on(this.element.closest(".typeahead"),{click:function(e){e.stopPropagation()}}),this._on(this.window,{resize:this._resizeMenus})},_search:function(e){return 9===e.which||40===e.which?($(".typeahead").find("button:first").focus(),!1):(27===e.which&&this._clearMenus(),this.element.val().length=this.options.minLength?($(this.options.targets).addClass("d-none"),$(this.options.targets).filter(function(){let e=$(this),a=e.text(),o=t.test(a);return!0===o&&e.html(a.replace(i,'$1')),o}).removeClass("d-none")):$(this.options.targets).removeClass("d-none").each(function(){let e=$(this);e.html(e.text())}),this._trigger("complete",this.event)},_remoteSearch:function(){let e=this,t=this.options.source,i=this.options.container;$.when(model.load({url:t,data:{q:e.searchStr}})).done(function(t){$(i).replaceWith(t.html),e._trigger("complete",e.event)})},_escapeRegexp:function(e){let t=new RegExp("[\\"+["[","]","/","{","}","(",")","*","+","?",".","\\","^","$","|"].join("\\")+"]","gui");return e.replace(t,"\\$&")}}),$.widget("il.expandable",{table:'
',cell1:'
',cell2:'
',_create:function(){this._expandability(),this._on(this.window,{resize:this._expandability})},_expandability:function(){if(this.element.innerHeight()>40&&0===this.element.find(".il-expandable-left").length){this.element.wrapInner(this.cell2).wrapInner(this.table),this.element.children().prepend(this.cell1);let e="il-expandable-"+this.uuid;this.element.find(".il-expandable-left").find("button").attr("aria-controls",e),this.element.find(".il-expandable-right").attr("id",e).attr("aria-expanded","false").addClass("text-truncate"),this._on(this.element,{"click .il-expandable-left > button":this._toggle})}},_toggle:function(){this.element.find(".il-expandable-left").find(".mdi").toggleClass("mdi-chevron-right mdi-chevron-down"),this.element.find(".il-expandable-right").toggleClass("text-truncate").attr("aria-expanded",function(e,t){return"false"===t?"true":"false"})}}),$.widget("il.clonable",{options:{target:""},_create:function(){""!==this.options.target&&(this._addClass($(this.options.target),"clonable-target-"+this.uuid),this._on(this.element,{click:this._clone}),this._on(this.element.next(".remove-clone-button"),{click:this._removeClone}))},_clone:function(){let e=$(this.options.target),t="clonable-target-"+this.uuid,i=e.clone();e.removeAttr("id"),i.find("[id]").each(function(){let e=$(this).attr("id"),t=_.uniqueId();$(this).attr("id",e+"-"+t),i.find('[for="'+e+'"]').attr("for",e+"-"+t)}),i.find("[name]").each(function(){let e=$(this).attr("name").replace(/\[(\d+)]/,function(e,t){return"["+(parseInt(t)+1)+"]"});$(this).attr("name",e)}),i.find('[type="text"], [type="number"]').each(function(){this.value=""}),i.insertAfter($("."+t).last()),formStyle.init(),this._trigger("onClone",null,{clonedTarget:i[0]})},_removeClone:function(){let e="clonable-target-"+this.uuid,t=$("."+e),i=t.last(),a=i.attr("id");t.length<2||(i.remove(),$("."+e).last().attr("id",a))}}),$.widget("il.confirmable",{options:{target:"#modal-confirm",title:"Confirmation",body:"Confirm?",button:"Yes",submit:function(){}},_getCreateOptions:function(){return{target:this.element.data("target"),title:this.element.data("title"),body:this.element.data("body"),button:this.element.data("button")}},_create:function(){this._on(this.element,{click:this._modal})},_modal:function(){let e=this,t=$(this.options.target),i=t.find(".modal-footer > button").eq(0);t.find(".modal-title").html(this.options.title),t.find(".modal-body").html(this.options.body),t.find(".modal-footer > button").eq(0).html(this.options.button),formStyle.init(),t.modal("show"),$(i).off("click").on("click",function(i){e._trigger("submit",i),t.modal("hide")})}}),$.widget("il.saveable",{_create:function(){"form"===this.element.get(0).nodeName.toLowerCase()&&void 0!==this.element.attr("id")&&(this._on(this.element,{save:this.save}),this.load())},save:function(){let e=this.element,t=[],i=this.element.serializeArray();_.forEach(i,function(i,a){"hidden"!==e.find('input[name="'+i.name+'"]').attr("type")&&t.push({name:i.name,value:i.value})}),store.save("saveable."+this.element.attr("id"),t)},load:function(){let e=0,t=this,i=store.load("saveable."+this.element.attr("id"))||[];this.element.get(0).reset(),this.element.find(":checkbox").prop("checked",!1),_.forEach(i,function(i){let a=t.element.find("[name='"+i.name+"']");0===a.length&&e<3&&(t.element.find(".clone-button").trigger("click"),e++,a=t.element.find("[name='"+i.name+"']")),a.val([i.value])}),formStyle.updateForm(this.element)},saveParams:function(e){store.save("saveable."+this.element.attr("id"),e)}}),$.widget("il.uploadable",{options:{multiple:!1,maxFiles:1e3},maxFilesMessage:"Maximum number of files reached.",maxSizeMessage:"File {{filename}} exceeds the size limit of {{limit}} MB.",fileItem:'
\n
\n {{filename}}\n
\n
\n
\n
\n
',_getCreateOptions:function(){return{multiple:!0===this.element.find(":file").prop("multiple")}},_create:function(){void 0===IL.uploader&&(IL.uploader={}),this._on(this.element,{submit:this._submit}),this._on(this.element.find(".uploadable-url"),{keydown:this._urlSubmit}),this._on(this.element.find(".uploadable-clear"),{click:this._clearFiles}),this._on(this.element.find(":file"),{change:this._pdfTitle});let e=this,t=this.element.find(".uploadable-select"),i=this.element.find(".uploadable-clear"),a=this.element.find(".uploadable-list"),o=Math.min(window.MAX_UPLOAD,window.MAX_POST),n=0,s=0;IL.uploader[this.uuid]=new window.ss.SimpleUpload({button:t,url:e.element.attr("action"),name:e.element.find(":file").attr("name"),form:e.element,responseType:"json",overrideSubmit:!1,maxSize:o/1024,multiple:e.options.multiple,multipleSelect:e.options.multiple,autoSubmit:!1,onChange:function(t,o,s,r,l){if(!1===e.options.multiple&&this.clearQueue(),this.getQueueSize()>=e.options.maxFiles)return $.jGrowl(e.maxFilesMessage,{header:"Info",sticky:!1,theme:"bg-primary"}),!1;e._addFile(l),n+=r,a.children("div").eq(0).removeClass("d-none"),i.removeClass("d-none"),"application/pdf"===l.type&&e._pdfTitle(l)},onSubmit:function(t){this.setProgressContainer(e.element.find('div[data-file="'+_.escape(t)+'"]')),this.setProgressBar(e.element.find('div[data-file="'+_.escape(t)+'"] .progress-bar'))},onSizeError:function(t,i){let a=e.maxSizeMessage.replace(/{{filename}}/,_.escape(t)).replace(/{{limit}}/,o/1048576);$.jGrowl(a,{header:"Info",sticky:!1,theme:"bg-primary"}),n-=i,this.getQueueSize()>0&&this.submit()},onDone:function(t,i,a,o,r,l){let d=100*(s+=l)/n;e.element.find(".uploadable-progress .progress-bar").attr("aria-valuenow",d).css("width",d+"%"),this.getQueueSize()>0&&this.submit()},onAllDone:function(){this.destroy(),$.jGrowl("Upload has finished.",{header:"Info",theme:"bg-primary"}),B.history.loadUrl()},onError:function(e,t,i,a,o){let n={status:i,statusText:a,responseJSON:JSON.parse(o)};model._onFail(n),this.getQueueSize()>0&&this.submit()}})},_addFile:function(e){let t=this.fileItem.replace(/{{filename}}/g,_.escape(e.name)),i=this.element.find(".uploadable-list").find(".list-group-item").eq(1).children();!0===this.options.multiple?i.append(t):i.html(t),this.element.find(".uploadable-list").removeClass("d-none"),this._trigger("change",null,e)},_submit:function(e){e.preventDefault(),"object"==typeof IL.uploader[this.uuid]&&IL.uploader[this.uuid].getQueueSize()>0?IL.uploader[this.uuid].submit():$.when(model.save({url:this.element.attr("action"),data:this.element.serialize()})).done(function(){B.history.loadUrl()})},_urlSubmit:function(e){if(13===e.which)return this.element.trigger("submit"),!1},_clearFiles:function(){this.element.find(".uploadable-list").addClass("d-none"),this.element.find(".uploadable-list").find(".list-group-item").eq(1).children().empty(),this.element.find(".uploadable-clear").addClass("d-none"),IL.uploader[this.uuid].clearQueue(),this._trigger("clear")},_pdfTitle:function(e){if("function"!=typeof this.options.pdftitles)return!1;if(e.size>5242880)return this._trigger("pdftitles",null,{titles:[]}),!1;let t=this,i=new FileReader,a=function(){let e,o=i.result,n=new RegExp(//g),s=[],r=0;for(;e=n.exec(o);){let t=$(e[0]);s[r]=$.trim(t.text()),r++}let l=0===(s=s.filter(Boolean)).length?[]:s;t._trigger("pdftitles",null,{titles:l}),i.removeEventListener("load",a),i=null};i.addEventListener("load",a),i.readAsText(e)}}),$.jGrowl.defaults.pool=3,$.jGrowl.defaults.life=5e3,$.jGrowl.defaults.position="top-right",$.jGrowl.defaults.closeTemplate='',$.jGrowl.defaults.closerTemplate="";class Overlay{constructor(){this.delay=800,this.timeId=null,this.template=''}start(e){let t=this;return"number"==typeof this.timeId&&this.stop(),e="number"==typeof e?e:this.delay,this.timeId=setTimeout(function(){let e=$("#overlay");0===e.length&&($("body").append(t.template),e.fadeIn(250,function(){}))},e),!0}stop(){let e=$("#overlay");return clearTimeout(this.timeId),this.timeId=null,e.length>0&&e.fadeOut(150,function(){e.remove()}),!0}}let overlay=new Overlay;class LocalStore{save(e,t){if(null==t||"function"==typeof t)return!1;localStorage.setItem(e,this._serialize(t))}load(e){return this._unserialize(localStorage.getItem(e))}delete(e){localStorage.removeItem(e)}clear(){localStorage.clear()}_serialize(e){return JSON.stringify(e)}_unserialize(e){return JSON.parse(e)}}let store=new LocalStore;class SessionStore{save(e,t){if(null==t||"function"==typeof t)return!1;sessionStorage.setItem(e,this._serialize(t))}load(e){return this._unserialize(sessionStorage.getItem(e))}delete(e){sessionStorage.removeItem(e)}clear(){sessionStorage.clear()}_serialize(e){return JSON.stringify(e)}_unserialize(e){return JSON.parse(e)}}let sessionStore=new SessionStore;class FormStyle{init(){let e=this;$(":checkbox, :radio").each(function(){e.updateStyle($(this))}).off("change.formstyle").on("change.formstyle",function(){e.changeState($(this))}).off("focus.formstyle").on("focus.formstyle",function(){$(this).next().find(".label-text").css("text-decoration","underline dotted 1px")}).off("blur.formstyle").on("blur.formstyle",function(){$(this).next().find(".label-text").css("text-decoration","none")})}changeState(e){let t=this;$('input[name="'+e.attr("name")+'"]').each(function(){t.updateStyle($(this))})}updateStyle(e){let t=e.next().find(".mdi");"radio"===e.attr("type")?!0===e.prop("checked")?t.removeClass("mdi-radiobox-blank").removeClass("text-muted").addClass("mdi-radiobox-marked text-primary"):t.removeClass("mdi-radiobox-marked").removeClass("text-primary").addClass("mdi-radiobox-blank text-muted"):"checkbox"===e.attr("type")&&(!0===e.prop("checked")?t.removeClass("mdi-checkbox-blank-outline").removeClass("text-muted").addClass("mdi-checkbox-marked text-primary"):t.removeClass("mdi-checkbox-marked").removeClass("text-primary").addClass("mdi-checkbox-blank-outline text-muted"))}updateForm(e){let t=this;e.find(":checkbox, :radio").each(function(){t.updateStyle($(this))})}}let formStyle=new FormStyle;class Keyboard{init(){let e=$("#keyboard-window");!0!==e.hasClass("d-lg-block")?(e.addClass("d-lg-block"),0===e.length&&$.when(model.load({url:window.IL_BASE_URL+"index.php/keyboard"})).done(function(e){$("body").append(e.html);let t=$("#keyboard-window");t.position({my:"bottom",at:"bottom",of:"body"}),$(window).off("resize.keyboard").on("resize.keyboard",function(){t.position({my:"bottom",at:"bottom",of:"body"})}),t.draggable({handle:".card-header",containment:"body"}),t.find(".close").off("click.keyboard").on("click.keyboard",function(){t.removeClass("d-lg-block")}),t.find(".tab-content").on("mousedown",function(){return!1}),$("#keyboard").on("click",".btn",function(){let e=$(this).html();1===$("#notes-ta_ifr").length?tinymce.execCommand("mceInsertContent",!1,e):$(":focus").insertAtCaret(e).trigger("input")})})):e.removeClass("d-lg-block")}}let keyboard=new Keyboard;class ExportForm{init(){let e=decodeURIComponent($("#open-export").data("exportUrl")).indexOf("index.php/summary")>0?"summary":"items",t=$("#modal-export");""===$.trim(t.find(".modal-body").html())&&$.when(model.load({url:window.IL_BASE_URL+"index.php/"+e+"/exportform"})).done(function(e){t.find(".modal-body").append(e.html),formStyle.init(),$("#export-form").saveable(),t.find(".modal-footer button:first-child").off("click").on("click",function(){exportform.formSubmit()}),$("#export-styles").typeahead(),$("#export-styles").off("focus").on("focus",function(){t.find('[name="export"]').val(["citation"]),formStyle.updateForm($("#export-form"))})})}formSubmit(){let e=decodeURIComponent($("#open-export").data("exportUrl")),t=$("#export-form"),i=""===new URL(e).search?"?":"&";window.open(e+i+t.serialize()),t.saveable("save")}}let exportform=new ExportForm;class OmnitoolForm{init(){let e=$("#modal-omnitool");if(""===$.trim(e.find(".modal-body").html()))$.when(model.load({url:window.IL_BASE_URL+"index.php/items/omnitoolform"})).done(function(t){e.find(".modal-body").append(t.html),formStyle.init(),e.find(".modal-footer button:first-child").on("click",function(){omnitoolform.formSubmit()}),$("#tag-filter-omnitool").filterable({complete:function(){$("#omnitool-tags .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$("#omnitool-tags .tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})});else{let t=e.find("form");t[0].reset(),formStyle.updateForm(t)}}formSubmit(){let e=decodeURIComponent($("#open-omnitool").data("omnitoolUrl")),t=$("#modal-omnitool").find("form");$("#modal-omnitool").modal("hide"),$.when(model.save({url:e,data:t.serialize()})).done(function(){B.history.loadUrl()})}}let omnitoolform=new OmnitoolForm;class QuickSearch{init(){let e=this,t=$("#quick-search-form");t.off("submit").on("submit",function(t){t.preventDefault(),e.formSubmit()}),$("#modal-quick-search .modal-footer").find("button.search-submit").off("click").on("click",function(){e.formSubmit()}),t.saveable()}formSubmit(){let e=$("#modal-quick-search"),t=$("#quick-search-form"),i=""===new URL("http://foo.bar/"+t.attr("action").substr(1)).search?"?":"&";t.saveable("save"),router.navigate(t.attr("action")+i+t.serialize(),{trigger:!0}),e.modal("hide")}}let quicksearch=new QuickSearch;class AdvancedSearch{init(){let e=this,t=$("#advanced-search-form");t.off("submit").on("submit",function(t){t.preventDefault(),e.formSubmit()}),$("#modal-advanced-search .modal-footer").find("button.search-submit").off("click").on("click",function(){e.formSubmit()}),$("#advanced-search-form .clone-button").clonable({target:"#clone-target",onClone:function(e,t){$(t.clonedTarget).find("select.fields").trigger("change")}}),t.saveable(),t.on("change","select.fields",this.hideBooleans),this.hideBooleans(),$("#tag-filter-search").filterable({complete:function(){$("#search-tags .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$("#search-tags .tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}formSubmit(){let e=$("#modal-advanced-search"),t=$("#advanced-search-form"),i=""===new URL("http://foo.bar/"+t.attr("action").substr(1)).search?"?":"&";t.saveable("save"),router.navigate(t.attr("action")+i+t.serialize(),{trigger:!0}),e.modal("hide")}hideBooleans(e){let t,i=void 0===e?$("#advanced-search-form").find("select.fields"):$(this);$.each(i,function(e,i){switch($(i).val()){case"AU":case"T1":case"T2":case"T3":case"KW":case"YR":case"C1":case"C2":case"C3":case"C4":case"C5":case"C6":case"C7":case"C8":t=!0;break;default:t=!1}t?$(i).closest(".row").removeClass("text-search").addClass("string-search"):$(i).closest(".row").removeClass("string-search").addClass("text-search")})}}let advancedsearch=new AdvancedSearch;class SearchList{init(){$("#modal-searches").on("show.bs.modal",searchlist.load)}load(e){let t=$("#modal-searches");$.when(model.load({url:window.IL_BASE_URL+"index.php/search/list",async:!0})).done(function(e){t.find(".modal-body").html(e.html),t.find(".modal-body").on("click",".delete-search",searchlist.deleteSearch)})}deleteSearch(e){let t=$(this);$.when(model.save({url:t.data("url"),data:{id:t.data("id")}})).done(function(){searchlist.load()})}}let searchlist=new SearchList;class Sidebar{init(){let e=this,t=$("#side-menu"),i=$(".navbar-toggler");$(window).on("popstate",function(){let i=location.hash.split("?")[0],a=t.find('a[href^="'+i+'"]');if(0!==a.length){if(t.find("a").removeClass("clicked"),""===location.hash||"#"===location.hash)return!0;e.expandSidebar(a)}}),t.metisMenu();let a=location.hash.split("?")[0],o=t.find('a[href^="'+a+'"]');if(0===o.length){let e=_.dropRight(location.hash.split("/"));o=t.find('a[href="'+e+'"]')}this.expandSidebar(o),t.on("click","a",function(){location.hash===$(this).attr("href")&&B.history.loadUrl(),""!==$(this).attr("href")&&"#"!==$(this).attr("href")&&i.is(":visible")&&i.trigger("click")})}expandSidebar(e){e.parents("ul.collapse").not(".in").each(function(){$(this).addClass("in").prev().click()}),e.addClass("clicked")}}let sidebar=new Sidebar;class ILChart{constructor(){void 0!==window.Chart&&(window.Chart.defaults.global.defaultFontFamily="Noto Sans",window.Chart.defaults.global.defaultFontColor="#777777",window.Chart.plugins.register({beforeDatasetsDraw:function(e,t){let i=e.chart.ctx,a=e.chartArea;e.options.drawBorder&&(i.strokeStyle=e.options.borderColor,i.lineWidth=1,i.strokeRect(a.left+.5,a.top+.5,a.right-a.left-.5,a.bottom-a.top-.5))}}))}draw(e,t,i,a,o,n){let s=$("#"+e),r=null!=i,l=[];if(1===s.length){let d=s.get(0).getContext("2d");l.push(chart._dataset1(a,i)),null!=n&&l.push(chart._dataset2(n,o)),void 0!==window.charts[e]&&window.charts[e].destroy(),window.charts[e]=new window.Chart(d,{type:"line",data:{labels:t,datasets:l},options:chart._options(t,r,n)})}}_dataset1(e,t){return{label:t,data:e,yAxisID:"y-axis-1",fill:!1,borderWidth:2,backgroundColor:"#2f8ded",borderColor:"#2f8ded",lineTension:.2,pointBorderColor:"#2f8ded",pointBackgroundColor:"#2f8ded",pointHoverBackgroundColor:"#2f8ded",pointHoverBorderColor:"#2f8ded",pointHitRadius:8,pointRadius:2}}_dataset2(e,t){return{label:t,data:e,yAxisID:"y-axis-2",fill:!1,borderWidth:2,backgroundColor:"#ed9b25",borderColor:"#ed9b25",lineTension:.2,pointBorderColor:"#ed9b25",pointBackgroundColor:"#ed9b25",pointHoverBackgroundColor:"#ed9b25",pointHoverBorderColor:"#ed9b25",pointHitRadius:8,pointRadius:2}}_options(e,t,i){let a=[],o={type:"linear",display:!0,position:"right",id:"y-axis-2",gridLines:{drawOnChartArea:!1,color:"#999",tickMarkLength:0},ticks:{maxTicksLimit:5,beginAtZero:!0,precision:0,padding:8}};return a.push({type:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{color:"#999",tickMarkLength:0},ticks:{maxTicksLimit:5,beginAtZero:!0,precision:0,padding:8}}),null!=i&&a.push(o),{responsive:!0,maintainAspectRatio:!1,stacked:!1,legend:{display:t},drawBorder:!0,borderColor:"#999",scales:{xAxes:[{type:"time",time:{displayFormats:{hour:"M/D",day:"M/D",week:"M/D",month:"YYYY/M",quarter:"YYYY/M",year:"YYYY"},unit:e.length>13?"day":"month"},gridLines:{color:"#999",tickMarkLength:0},ticks:{padding:8}}],yAxes:a}}}}let chart=new ILChart;class ImageFilter{constructor(){this.touchDevice=window.matchMedia("(max-width: 1199px)").matches,this.default={contrast:"1",brightness:"1",saturation:"1",hue:"0deg",invert:"0",sharpen:!1,sharpness:"0"}}compileCss(e){let t=$(".pdfviewer-right > div:first").hasClass("img-night-mode"),i=$("#adjust-contrast").val()||this.default.contrast,a=$("#adjust-brightness").val()||this.default.brightness,o=$("#adjust-saturation").val()||this.default.saturation,n=$("#adjust-sharpness").val()||this.default.sharpness,s=`contrast(${i}) brightness(${a}) saturate(${o}) hue-rotate(${t?"180deg":"0deg"}) invert(${t?"1":"0"})`;return!0===e&&"0"!==n&&(s+=" url(#sharpen)"),s}adjustFilter(e){this.touchDevice||$(".pdfviewer-right img").slice(Math.max(e-3,0),e+3).css("filter",this.compileCss(!0))}adjustSharpness(e){if(this.touchDevice)return;let t=$("#sharpen feConvolveMatrix"),i=t.attr("kernelMatrix").split(" ");i[4]=-12*parseFloat($("#adjust-sharpness").val())+16,t.attr("kernelMatrix",i.join(" ")),this.adjustFilter(e)}disableSharpening(e){this.touchDevice||$(".pdfviewer-right img").slice(Math.max(e-3,0),e+3).css("filter",this.compileCss(!1))}reset(e){this.touchDevice||($("#adjust-contrast").val(this.default.contrast),$("#adjust-brightness").val(this.default.brightness),$("#adjust-saturation").val(this.default.saturation),$("#adjust-sharpness").val(this.default.sharpness),this.adjustSharpness(e))}lightMode(){$(".pdfviewer-left img").css("filter","hue-rotate(0deg) invert(0)"),$(".pdfviewer-right img").css("filter",this.compileCss(!0))}nightMode(){$(".pdfviewer-left img").css("filter","hue-rotate(180deg) invert(1)"),$(".pdfviewer-right img").css("filter",this.compileCss(!0))}}let imageFilter=new ImageFilter,arxiv={url:"https://export.arxiv.org/api/query?start=0&max_results=1&id_list=",metadata:function(e){let t={author_last_name:[],author_first_name:[],keywords:[],uid_types:[],uids:[],secondary_title:"eprint"},i=e.find("entry");t.reference_type="article",t.title=i.children("title").text().replace(/\r?\n|\r/g," ")||"",t.abstract=i.children("summary").text().replace(/\r?\n|\r/g," ")||"";let a=new Date(i.children("published").text().replace(/\r?\n|\r/g," "));t.publication_date=a.toISOString().substr(0,10);let o=i.children("arxiv\\:doi").text().replace(/\r?\n|\r/g," ")||"";if(""!==o&&(t.uid_types.push("DOI"),t.uids.push(o)),1===i.find("id").length){t.uid_types.push("ARXIV");let e=i.find("id").text().replace(/https?:\/\/arxiv\.org\/abs\//,"");t.uids.push(e),$(".uploadable-url").val("https://arxiv.org/pdf/"+e)}return _.forEach(i.find("name"),function(e,i){let a=$(e).text().split(" ");t.author_last_name[i]=a.pop(),t.author_first_name[i]=a.join(" ")}),_.forEach(i.children("category"),function(e,i){t.keywords[i]=$(e).attr("term")}),JSON.stringify(t)}},views={};B.emulateJSON=!0;let Router=B.Router.extend({routes:{":controller(/:action)(?:query)":"dispatch"},dispatch:function(e,t,i){let a="string"==typeof e?e:"main",o="string"==typeof t?t:"main",n="string"==typeof i?"?"+i:"";$.when(model.load({url:window.IL_BASE_URL+"index.php/"+a+"/"+o+n})).done(function(e){"object"==typeof views[a+o]?views[a+o].render(e):console.error('The view "'+(a+o)+'" does not exist.')})}}),router=new Router;class Model{constructor(){this.xhr="",this.options={url:null,data:void 0,async:!1,cors:!1,dataType:"json"}}load(e){return e=_.assign({},this.options,e),this._request("GET",e.url,e.data,e.async,e.cors,e.dataType)}save(e){return e=_.assign({},this.options,e),this._request("POST",e.url,e.data,e.async,e.cors,e.dataType)}_request(e,t,i,a,o,n){let s=this,r=$.Deferred(),l=!0!==a,d=n||"json";!0===l&&"object"==typeof this.xhr&&this.abort();let c={"X-Client-Width":screen.width};!0===o&&(c={});let h=$.ajax({url:t,data:i,type:e,dataType:d,headers:c}).done(function(e){s._onSuccess(e),r.resolve(e)}).fail(function(e){s._onFail(e,o),r.reject(e)});return!0===l&&(overlay.start(),model.xhr=h),r}abort(){"object"==typeof this.xhr&&(this.xhr.abort(),this.xhr="",overlay.stop())}_onSuccess(e){this.xhr="",overlay.stop(),"string"==typeof e.info&&$.jGrowl(e.info,{header:"Info",sticky:!1,theme:"bg-primary"})}_onFail(e,t){if(this.xhr="",overlay.stop(),!1===t||void 0===t)if("abort"===e.statusText);else if(401===e.status){let e=window.IL_BASE_URL+"?ref="+window.btoa(location.href);location.replace(e)}else if(404===e.status)location.replace(window.IL_BASE_URL+"index.php/notfound/main");else if(e.status>400&&e.status<500){let t=void 0!==e.responseJSON?e.responseJSON.error:"Unspecified error.";$.jGrowl(t,{header:"Info",sticky:!1,theme:"bg-primary"})}else{let t=void 0!==e.responseJSON?e.responseJSON.error:"Unspecified error.";$.jGrowl(t,{header:e.status+" "+e.statusText,sticky:!0,theme:"bg-danger"})}}}let model=new Model;class View{constuctor(){this.events={},this.parent=""}render(e){let t=$(this.parent);return 1!==t.length?(console.error('The view container "'+this.parent+'" not found!'),!1):("string"==typeof e.title&&(document.title=e.title),"string"==typeof e.html&&(t.html(e.html),this.delegateEvents(),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset(),this.afterRender(e)),$(".modal").modal("hide"),$(".modal-backdrop").remove(),$('[data-toggle="tooltip"], .tooltip').tooltip("hide"),this)}htmlRender(){for(let e in this.events){let t=this.events[e];_.isFunction(t)||(t=this[t]);let i=e.match(/^(\S+)\s*(.*)$/);$("body").on(i[1]+".view",i[2],{object:this},t)}formStyle.init(),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset(),this.afterRender()}afterRender(e){}delegateEvents(){if(void 0===this.events)return this;this.undelegateEvents();for(let e in this.events){let t=this.events[e];_.isFunction(t)||(t=this[t]);let i=e.match(/^(\S+)\s*(.*)$/);$(this.parent).on(i[1]+".view",i[2],{object:this},t)}return this}undelegateEvents(){return 1===$(this.parent).length&&$(this.parent).off(".view"),this}}class DashboardMainView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){formStyle.init(),quicksearch.init(),advancedsearch.init();let t=void 0===e.pages_read||0===e.pages_read.length?null:Object.values(Object.values(e.pages_read)[0]),i=null===t?null:Object.keys(e.pages_read);chart.draw("myChart",Object.keys(Object.values(e.activity)[0]),Object.keys(e.activity),Object.values(Object.values(e.activity)[0]),i,t),sessionStore.delete("il.idList")}}views.dashboardmain=new DashboardMainView;class SettingsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #user-settings-form":"saveForm"}}afterRender(e){formStyle.init(),$("#timezones").typeahead(),$("#modal-settings").find(".modal-body").html("")}saveForm(e){e.preventDefault();let t=$(this);t.find(":checkbox").each(function(){!1===$(this).prop("checked")&&t.append(``)}),$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){location.reload()})}}views.settingsmain=new SettingsMainView;class ProfileMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #user-profile-form":"saveProfile","submit #user-profile-change-password":"savePassword"}}afterRender(e){$('[data-toggle="tooltip"]').tooltip({container:"#content-col"})}saveProfile(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){let e=""===$("#first_name").val()?$("#username").val():$("#first_name").val();$("#menu-first-name").text(e)})}savePassword(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){t[0].reset()})}}views.profilemain=new ProfileMainView;class ItemsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":"filterLocal","click .open-filter-remote":"filterRemote","click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){formStyle.init();let t=this;this.itemsHeight(),$(window).off("resize.ItemsMainView").on("resize.ItemsMainView",function(){t.itemsHeight()}),quicksearch.init(),advancedsearch.init(),sessionStore.save("il.idList",e.id_list),this.highlightSearch()}itemsHeight(){let e=$("#bottom-row").outerHeight();$(".navbar-toggler").is(":visible")?$("#top-row").height($(window).height()-e-$(".navbar-toggler").outerHeight(!0)-(1===$("#filter-list").length?$("#filter-list").outerHeight(!0):0)):$("#top-row").height($(window).height()-e)}filterLocal(){let e=$(this).data("src"),t=$(this).data("title");$.when(model.load({url:e})).done(function(e){$("#modal-filters .modal-title").html(t),$("#modal-filters .modal-body .container-fluid").replaceWith(e.html),$("#modal-filters").modal(),$("#modal-filters .modal-body").on("click","a",function(){$("#modal-filters").modal("hide")}),$("#modal-filters .filterable").filterable("destroy"),$("#modal-filters :text").filterable({targets:"#modal-filters a"}).val("").focus()})}filterRemote(){let e=$(this).data("src"),t=$(this).data("title");$.when(model.load({url:e})).done(function(i){$("#modal-filters .modal-title").html(t),$("#modal-filters .modal-body .container-fluid").replaceWith(i.html),$("#modal-filters").modal(),$("#modal-filters .modal-body").on("click","a",function(){$("#modal-filters").modal("hide")}),$("#modal-filters .filterable").filterable("destroy"),$("#modal-filters :text").filterable({source:e,container:"#modal-filters .container-fluid"}).val("").focus()})}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}highlightSearch(){if(location.hash.indexOf("search_query")>-1&&$(".item-container").length>0){let t=new URL("http://foo.bar/"+location.hash.substr(1));document.designMode="on";var e=window.getSelection();for(let i of t.searchParams)if(0===i[0].indexOf("search_query")){let t=i[1].split(" ");for(let i of t)if(e.collapse(document.getElementsByClassName("item-container")[0],0),(i=i.replace("*","")).length>1)for(;window.find(i,!1);)document.execCommand("hiliteColor",!1,"#ffff9bbf"),document.execCommand("foreColor",!1,"#222426")}e.collapseToEnd(),document.designMode="off",e.removeAllRanges(),$("#top-row").scrollTop(0)}}}views.itemsmain=new ItemsMainView,views.itemsfilter=new ItemsMainView;class ItemsCatalogView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":views.itemsmain.filterLocal,"click .open-filter-remote":views.itemsmain.filterRemote,"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){views.itemsmain.afterRender(e)}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}}views.itemscatalog=new ItemsCatalogView;class ClipboardMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":views.itemsmain.filterLocal,"click .open-filter-remote":views.itemsmain.filterRemote,"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){views.itemsmain.afterRender(e)}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).done(function(){B.history.loadUrl()}).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}}views.clipboardmain=new ClipboardMainView,views.clipboardfilter=new ClipboardMainView;class ProjectsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #project-form":"submitForm","click .join":"joinProject","click .leave":"leaveProject","click .activate":"activateProject","click .inactivate":"inactivateProject"}}afterRender(e){formStyle.init(),$('[data-toggle="tooltip"]').tooltip(),$(".delete").confirmable({submit:function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/delete",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}}),$("#filter-active").filterable({targets:".active-project",complete:function(){$(".active-project-container").removeClass("d-none"),$(".active-project.d-none").closest(".active-project-container").addClass("d-none")}}),$("#filter-open").filterable({targets:".open-project",complete:function(){$(".open-project-container").removeClass("d-none"),$(".open-project.d-none").closest(".open-project-container").addClass("d-none")}}),$("#filter-inactive").filterable({targets:".inactive-project",complete:function(){$(".inactive-project-container").removeClass("d-none"),$(".inactive-project.d-none").closest(".inactive-project-container").addClass("d-none")}})}submitForm(e){let t=e.data.object;e.preventDefault(),$.when(model.save({url:$(this).attr("action"),data:$(this).serialize()})).done(function(e){$("#content-col").html(e.html),t.afterRender()})}joinProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/join",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}leaveProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/leave",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}activateProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/activate",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}inactivateProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/inactivate",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}}views.projectsmain=new ProjectsMainView;class ProjectBrowseView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":views.itemsmain.filterLocal,"click .open-filter-remote":views.itemsmain.filterRemote,"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){formStyle.init(),views.itemsmain.afterRender(e)}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e)),B.history.loadUrl()})}}views.projectbrowse=new ProjectBrowseView,views.projectfilter=new ProjectBrowseView;class ProjectEditView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #project-form":"submitForm"}}afterRender(e){formStyle.init(),$("#content-col").find('[data-toggle="tooltip"]').tooltip()}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.projectedit=new ProjectEditView;class ProjectDiscussionView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #message-form":"bindForm"}}afterRender(e){}bindForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.projectdiscussion=new ProjectDiscussionView;class ProjectNotesView extends View{constructor(){super(),this.parent="#content-col",this.events={}}afterRender(e){}}views.projectnotes=new ProjectNotesView,views.projectcompilenotes=new ProjectNotesView;class TagsManageView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .edit-tag-form":"editTag","submit #tag-form":"createTag"}}editTag(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}createTag(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.tagsmanage=new TagsManageView;class NormalizeMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"change #select-metadata":"changeSource","submit .edit-form":"submitForm"}}afterRender(e){let t=$("#search-metadata");t.filterable({source:t.attr("data-source"),container:t.attr("data-container")})}changeSource(e){e.data.object;let t=$("#search-metadata"),i=window.IL_BASE_URL+"index.php/normalize/search"+$(this).val();t.filterable("destroy"),$("#results").empty(),t.attr("data-source",i).val(""),t.filterable({source:t.attr("data-source"),container:t.attr("data-container")})}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()}))}}views.normalizemain=new NormalizeMainView;class NormalizeResultsView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .edit-form":"submitForm"}}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.normalizeauthors=new NormalizeResultsView,views.normalizeeditors=new NormalizeResultsView,views.normalizeprimary=new NormalizeResultsView,views.normalizesecondary=new NormalizeResultsView,views.normalizetertiary=new NormalizeResultsView;class DuplicatesMainView extends View{constructor(){super(),this.parent="#content-col"}}views.duplicatesmain=new DuplicatesMainView;class DuplicatesFindView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .merge-form":"merge"}}merge(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){t.closest(".card").remove()})}}views.duplicatesfind=new DuplicatesFindView;class ReindexMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click #reindex":"reindex","click #defragment":"defragment","click #check-fts":"integrityFts","click #check-db":"integrityDb","click #reextract":"reextract"}}integrityFts(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/checkfts"}))}integrityDb(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/checkdb"}))}defragment(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/defragment"})).done(function(){B.history.loadUrl()})}reindex(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/reindex"})).done(function(){B.history.loadUrl()})}reextract(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/reextract"})).done(function(){B.history.loadUrl()})}}views.reindexmain=new ReindexMainView;class SummaryMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"submit .form-uid":"submitForm","click .open-notes":"openNotes","click .rescan-pdf":"rescanPdf"}}afterRender(e){formStyle.init(),$(".truncate").expandable();let t=this;this.itemHeight(),$(window).off("resize.SummaryMainView").on("resize.SummaryMainView",function(){t.itemHeight()}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink()),$("#delete-item").confirmable({submit:function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/item/delete",data:{id:$("body").data("id")}})).done(function(){location.assign(window.IL_BASE_URL+"index.php#dashboard/main")})}});let i=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",i).data("id",i),$("a.add-id-link").each(function(){let e=$(this).attr("href").split("id=");$(this).attr("href",e[0]+"id="+i)});let a=sessionStore.load("il.idList");if(a){let e=a[a.indexOf(a.find(e=>e.id===i))-1],t=a[a.indexOf(a.find(e=>e.id===i))+1];void 0===e?$("#summary-previous").addClass("disabled").attr("tabindex","-1").attr("aria-disabled","true"):$("#summary-previous").attr("href","#summary?id="+e.id),void 0===t?$("#summary-next").addClass("disabled").attr("tabindex","-1").attr("aria-disabled","true"):$("#summary-next").attr("href","#summary?id="+t.id)}else $("#summary-next, #summary-previous").remove();$("#autoupload-doi-form").saveable()}itemHeight(){let e=$("#bottom-row").outerHeight();$(".navbar-toggler").is(":visible")?$("#top-row").height($(window).height()-e-$(".navbar-toggler").outerHeight(!0)):$("#top-row").height($(window).height()-e)}clipboard(){let e=$(this),t=$("body").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}project(){let e=$(this),t=$("body").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}submitForm(e){let t=$(this);e.preventDefault(),$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()}),$("#autoupload-doi-form").trigger("save")}openNotes(){null!==window.tinymce.activeEditor&&!0===window.tinymce.activeEditor.initialized?$("#notes-window").removeClass("d-none"):views.summarymain.loadNotes()}loadNotes(){let e=this,t=$("body").attr("data-id");$.when(model.load({url:window.IL_BASE_URL+"index.php/notes/user",data:{id:t}})).done(function(i){$("#notes-ta").val(i.user.note),$("#id-hidden").val(t),e.initNotes()})}initNotes(){null===window.tinymce.activeEditor||!0!==window.tinymce.activeEditor.initialized?window.tinymce.init({theme:"silver",selector:"#notes-ta",content_css:window.IL_BASE_URL+"css/style.css",resize:"both",min_height:300,menubar:!1,plugins:"importcss save lists advlist link image code fullscreen table searchreplace",toolbar1:"save undo redo fullscreen code | formatselect link unlink image table searchreplace",toolbar2:"bold italic underline strikethrough subscript superscript removeformat | forecolor backcolor | outdent indent bullist numlist",save_onsavecallback:function(e){let t=$("#note-form");$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){$("#user-note").html(e.getContent()),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset()})},image_description:!1,relative_urls:!1,remove_script_host:!1,image_dimensions:!1,image_class_list:[{title:"Auto width",value:"mce-img-fluid"}],image_list:window.IL_BASE_URL+"index.php/supplements/imagelist?as=json&id="+$("body").data("id")}).then(function(){let e=$("#notes-window");e.removeClass("d-none"),e.position({my:"left bottom",at:"left bottom",of:"#content-col"}),$(window).off("resize.notes").on("resize.notes",function(){e.position({my:"left bottom",at:"left bottom",of:"#content-col"})}),e.draggable({handle:".card-header",containment:"body"}),e.find(".close").off("click.notes").on("click.notes",function(){$("#notes-window").addClass("d-none")})}):window.tinymce.activeEditor.load()}rescanPdf(){let e=$(this).data("url");$.when(model.load({url:e})).done(function(){B.history.loadUrl()})}}views.summarymain=new SummaryMainView;class NotesMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-notes":views.summarymain.openNotes}}afterRender(){let e=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",e).data("id",e),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}}views.notesmain=new NotesMainView;class EditMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #edit-form":"bindForm","change #reference-type":"bindReferenceType"}}afterRender(e){this.uploadFormWidgets(),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}bindForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}bindReferenceType(){$("#edit-form").trigger("submit")}uploadFormWidgets(){let e=this;$("input.input-typeahead").each(function(){let t=$(this);t.typeahead({source:t.data("source"),onSelect:function(){e._selectAuthor(this)}})}),$("#clone-authors").clonable({target:"#new-author-container",onClone:function(t,i){let a=$(i.clonedTarget).find(".input-typeahead");a.typeahead({source:a.data("source"),onSelect:function(){e._selectAuthor(this)}})}}),$("#clone-editors").clonable({target:"#new-editor-container",onClone:function(t,i){let a=$(i.clonedTarget).find(".input-typeahead");a.typeahead({source:a.data("source"),onSelect:function(){e._selectAuthor(this)}})}}),$("#clone-uid").clonable({target:"#uid-row"})}_selectAuthor(e){if("author_last_name[]"===$(e).attr("name")){let t=$(e).closest(".form-row").find('input[name="author_first_name\\[\\]"]'),i=$(e).val().split(",");$(e).val($.trim(i[0]||"")),t.val($.trim(i[1]||""))}if("editor_last_name[]"===$(e).attr("name")){let t=$(e).closest(".form-row").find('input[name="editor_first_name\\[\\]"]'),i=$(e).val().split(",");$(e).val($.trim(i[0]||"")),t.val($.trim(i[1]||""))}}}views.editmain=new EditMainView;class ItemdiscussionMainView extends View{constructor(){super(),this.parent="#content-col",this.messagesId="",this.events={"submit #message-form":"bindForm"}}afterRender(e){this.messagesId=setInterval(this.refreshMessages,1e4),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}bindForm(e){e.preventDefault();let t=e.data.object,i=$(this);$.when(model.save({url:i.attr("action"),data:i.serialize()})).done(function(){t.refreshMessages(),i.get(0).reset()})}refreshMessages(){if(0===$("#message-list").length)return void clearInterval(this.messagesId);let e=$("body").data("id");$.when(model.load({url:window.IL_BASE_URL+"index.php/itemdiscussion/messages?id="+e})).done(function(e){$("#message-list").html(e.html),$("#message").val("")})}}views.itemdiscussionmain=new ItemdiscussionMainView;class TagsItemView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #tag-form":"createTags","change .tag-inputs":"changeTags"}}afterRender(e){formStyle.init(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}createTags(e){e.preventDefault();let t=e.data.object,i=$(this);""!==$("#new_tags").val()&&$.when(model.save({url:i.attr("action"),data:i.serialize()})).done(function(e){$("#content-col").html(e.html),t.afterRender()})}changeTags(){let e=$(this),t=$("body").data("id");e.is(":checked")?$.when(model.save({url:window.IL_BASE_URL+"index.php/tags/additem",data:{id:t,tag_id:e.val()}})).fail(function(){e.prop("checked",!1),formStyle.updateStyle(e)}):$.when(model.save({url:window.IL_BASE_URL+"index.php/tags/deleteitem",data:{id:t,tag_id:e.val()}})).fail(function(){e.prop("checked",!0),formStyle.updateStyle(e)})}}views.tagsitem=new TagsItemView;class SupplementsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .rename-file":"renameFile","keydown input.form-control":"submitInput"}}afterRender(e){formStyle.init(),$("#upload-form").uploadable({maxFiles:64}),$(".delete-file").confirmable({submit:function(){let e=$(this).closest("li").find(".filename-link").text().trim(),t=$("body").data("id");$.when(model.save({url:window.IL_BASE_URL+"index.php/supplements/delete",data:{id:t,filename:e}})).done(function(){B.history.loadUrl()})}}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}renameFile(){let e=$(this).closest("li").find(".filename-link"),t=$(this).closest("li").find("input");if(e.hasClass("d-none")){let i=$.trim(e.text()),a=$.trim(t.val());$.when(model.save({url:window.IL_BASE_URL+"index.php/supplements/rename",data:{id:$("body").data("id"),filename:i,newname:a}})).done(function(){B.history.loadUrl()})}else e.addClass("d-none"),t.removeClass("d-none").addClass("d-inline-block").val($.trim(e.text())).focus()}submitInput(e){13===e.which&&$(this).closest(".list-group-item").find(".rename-file").trigger("click")}}views.supplementsmain=new SupplementsMainView;class PdfMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"change #pdfviewer-zoom":"selectZoom","input #pdfviewer-page-input":"inputPageNum","click #pdfviewer-first":"buttonPageNum","click #pdfviewer-prev":"buttonPageNum","click #pdfviewer-next":"buttonPageNum","click #pdfviewer-last":"buttonPageNum","click .pdfviewer-thumb":"thumbPageNum","click #pdfviewer-image":"toggleCropper","click #copy-image-btn":"getCroppedImage","click #save-image-btn":"saveCroppedImage","click #pdfviewer-left-btn":"toggleLeft","click #pdfviewer-previews-btn":"showThumbs","click #pdfviewer-bookmarks-btn":"showBookmarks","click #pdfviewer-results-btn":"showResults","click #pdfviewer-bookmarks a":"clickBookmark","click #pdfviewer-night-btn":"nightMode","click #pdfviewer-text-btn":"toggleTextLayer","click .highlight-color":"addHighlights","click .highlight-eraser":"eraserInit","click #pdfviewer-annot-menu .annot-show":"showAnnotations","click #pdfviewer-annot-menu .annot-hide":"hideAnnotations","click .highlight-cancel":"clearHighlights","dblclick .pdfviewer-page":"dblZoom","keyup #pdfviewer-search-input":"search","click #pdfviewer-results > .pdfviewer-results-container > a":"scrollToResult","click #pdfviewer-result-up":"prevResult","click #pdfviewer-result-down":"nextResult","click #pdfviewer-notes-btn":"showNotes","click .note-edit-btn":"editNote","submit .note-form":"saveNote","submit #new-note-form":"saveNote","click #pdfviewer-new-note-btn":"createNewNote","click .pdflink":"openLink","change #pdfviewer-underlined":"highlightStyle"}}afterRender(e){this.selectable=void 0,this.page=void 0,this.sseSearch=void 0;let t=this;if(this.throttledZoom=_.throttle(function(e){t.pageZoom(e)},500,{leading:!0,trailing:!0}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink()),0===$("#pdfviewer-pages").length)return;"underlined"===store.load("il.highlightStyle")&&$("#pdfviewer-underlined").prop("checked",!0),formStyle.init(),$("#content-col").find('[data-toggle="tooltip"]').tooltip();let i=new URL(location.href).searchParams.get("id")||"";""!==i&&$("body").attr("data-id",i).data("id",i),$(window).off("resize.PdfMainView").on("resize.PdfMainView",function(){t.pagesHeight(),t.pageZoom(store.load("il.pageZoom")||"auto"),$(".pdfviewer-right").trigger("scroll")}),this.pagesHeight(),new LazyLoad({container:$("#pdfviewer-pages .pdfviewer-left").get(0),elements_selector:".lazy",load_delay:250,threshold:400}),this.lazyLoad=new LazyLoad({container:document.querySelector(".pdfviewer-right"),elements_selector:".lazy",load_delay:250,threshold:1e3}),!0===store.load("il.nightMode")&&$("#pdfviewer-night-btn").click(),!0===store.load("il.leftPanel")&&(this.showLeft(),this.showThumbs()),this.pageZoom(store.load("il.pageZoom")||"auto"),$("#adjust-sharpness").val(imageFilter.default.sharpness),$(".pdfviewer-right").off("scroll").on("scroll",_.throttle(function(){t.redrawNoteLine(),t.redrawSnippetLine(),imageFilter.disableSharpening(t.page),clearTimeout($.data(window,"scrollTimer")),$.data(window,"scrollTimer",setTimeout(function(){$(".pdfviewer-right > div").each(function(){return!t.detectVisiblePage(this,this.getBoundingClientRect(),$(".pdfviewer-right")[0].getBoundingClientRect())}),"object"==typeof t.selectable&&t.selectable.refresh(),imageFilter.adjustSharpness(t.page)},200))},20)),$(".pdfviewer-left").off("scroll").on("scroll",_.throttle(function(){t.redrawNoteLine(),t.redrawSnippetLine()},20)),"object"==typeof t.selectable&&(t.selectable.disable(),t.selectable.destroy()),"object"==typeof t.cropper&&t.destroyCropper();let a={},o=$.Event("keyup");null!==(a=location.hash.length>1?new URL("http://foo.bar/"+location.hash.substring(1)).searchParams:new URL(location.href).searchParams).get("search")&&(o.which=13,$("#pdfviewer-search-input").val(a.get("search")).trigger(o));let n=a.get("page")||$("#pdfviewer-page-input").val();this.setPageNumber(n),this.scrollToPage(n,0),this.getLinks()}selectZoom(e){e.data.object.throttledZoom($(this).val())}dblZoom(e){let t=store.load("il.pageZoom");if("auto"===t){let e=100*($(".pdfviewer-right").width()-30)/(.5*$(".pdfviewer-page > img").eq(0).attr("width"));[50,75,100,125,150,200,250,300].forEach(function(i){i<=e&&(t=i.toString())})}else t="auto";e.data.object.pageZoom(t)}pageZoom(e){"screen"===e&&(e="auto");let t,i=this.page;if($("#pdfviewer-zoom").val(e),store.save("il.pageZoom",e),"auto"===e){let t=$(".pdfviewer-right").width()-30,i=$(".pdfviewer-page > img").eq(0).attr("width"),a=Math.max(100*t/i,50);[50,75,100,125,150,200,250,300].forEach(function(t){t<=a&&(e=t.toString())})}switch(e){case"50":case"100":case"200":t="200";break;case"125":case"250":t="250";break;case"75":case"150":case"300":t="300";break;default:t="200"}$(".pdfviewer-page > img").each(function(){this.style.width=Math.ceil(.01*e*this.getAttribute("width"))+"px",this.style.height=Math.ceil(.01*e*this.getAttribute("height"))+"px",null!==this.getAttribute("data-src")&&(this.removeAttribute("data-was-processed"),this.classList.remove("loaded"),this.setAttribute("data-src",this.getAttribute("data-src").replace(/zoom=\d+/,"zoom="+t)))}),this.lazyLoad.update(),this.scrollToPage(i,0)}pagesHeight(){let e=$("#pdfviewer-menu").outerHeight();$(".navbar-toggler").is(":visible")?$("#pdfviewer-pages, .pdfviewer-left, .pdfviewer-right").height($(window).height()-e-$(".navbar-toggler").outerHeight(!0)):$("#pdfviewer-pages, .pdfviewer-left, .pdfviewer-right").height($(window).height()-e)}detectVisiblePage(e,t,i){return t.top-i.top>0&&t.top-i.top0&&i.bottom-t.bottom0&&t.bottom-i.bottom>0&&(this.setPageNumber($(e).data("page")),!0)}setPageNumber(e){let t=this;t.page!==parseInt(e)&&(t.page=parseInt(e),void 0!==this.pageTimer&&clearTimeout(this.pageTimer),this.pageTimer=_.delay(function(){$("#pdfviewer-page-input").val(e),$(".pdfviewer-thumb").children("div").removeClass("bg-primary").addClass("bg-secondary"),$(".pdfviewer-thumb").eq(e-1).children("div").removeClass("bg-secondary").addClass("bg-primary"),$("#pdfviewer-pages .pdfviewer-left").animate({scrollTop:$(".pdfviewer-thumb").eq(e-1).position().top+$("#pdfviewer-pages .pdfviewer-left").scrollTop()-$(".pdfviewer-thumb").eq(e-1).height()/2},100),$("#pdfviewer-pages").find(".pdfviewer-text").length>0&&t.getBoxes(e),$("#pdfviewer-pages").find(".pdfviewer-highlights").length>0&&t.getHighlights(),model.load({url:window.IL_BASE_URL+"index.php/pdf/logpage",data:{id:$("body").data("id"),page:e},async:!0})},400))}buttonPageNum(e){let t,i,a=600;switch($(this).data("value")){case"first":i=1;break;case"prev":for(t=i=parseInt($("#pdfviewer-page-input").val());t>i-10;t--){let e=$(".pdfviewer-page").eq(t-1)[0].getBoundingClientRect(),a=$(".pdfviewer-page").eq(t-2)[0].getBoundingClientRect();if(e.top>a.top){i=t-1;break}}a=200;break;case"next":for(t=i=parseInt($("#pdfviewer-page-input").val());te.top){i=t+1;break}}a=200;break;case"last":i=$(".pdfviewer-page").last().data("page")}e.data.object.scrollToPage(i,a)}inputPageNum(e){let t=e.data.object,i=$(this).val();void 0!==t.t&&clearTimeout(t.t),t.t=_.delay(function(){t.scrollToPage(i)},300)}thumbPageNum(e){e.data.object.scrollToPage($(this).data("page"))}scrollToPage(e,t){let i=void 0===t?400:t;1===$('.pdfviewer-page[data-page="'+e+'"]').length&&$(".pdfviewer-right").animate({scrollTop:$('.pdfviewer-page[data-page="'+e+'"]').position().top+$(".pdfviewer-right").scrollTop()-12},i)}scrollToElement(e,t){let i=void 0===t?400:t,a=$(".pdfviewer-right"),o=e.offset().top;(o<100||o>$(window).height()-100)&&a.animate({scrollTop:o+a.scrollTop()-$(window).height()/2},{duration:i,queue:!1});let n=e[0].getBoundingClientRect(),s=a[0].getBoundingClientRect();(n.lefts.right)&&a.animate({scrollLeft:a.scrollLeft()+n.left-s.left-.5*a.width()},{duration:i,queue:!1})}toggleCropper(e){if(void 0===e.data.object.cropper){e.data.object.clearHighlights(e),e.data.object.clearNotes(e),e.data.object.pageZoom("auto"),e.data.object.destroyTextLayer(),$(".dropdown.show .dropdown-toggle").dropdown("toggle"),$("#pdfviewer-menu").find("button, input, select").prop("disabled",!0),$(".btn-group-toggle").addClass("disabled").children().addClass("disabled"),$("#pdfviewer-image").prop("disabled",!1);let t=e.data.object.page-1;e.data.object.cropper=new Cropper($(".pdfviewer-page > img")[t],{background:!1,viewMode:1,dragMode:"move",initialAspectRatio:1,rotatable:!1,movable:!1,zoomable:!1,autoCropArea:.5,ready:function(){let e=$("#copy-image-btn-temp").clone(),t=$("#save-image-btn-temp").clone();$(".cropper-crop-box").append('
'),e.attr("id","copy-image-btn").removeClass("d-none").appendTo("#crop-buttons"),t.attr("id","save-image-btn").removeClass("d-none").appendTo("#crop-buttons")}}),$("#pdfviewer-pages > .pdfviewer-right > .pdfviewer-page:first").hasClass("img-night-mode")&&e.data.object.nightMode()}else e.data.object.destroyCropper()}destroyCropper(){$("#pdfviewer-menu").find("button, input, select").prop("disabled",!1),$(".btn-group-toggle").removeClass("disabled").children().removeClass("disabled"),"object"==typeof this.cropper&&(this.cropper.destroy(),this.cropper=void 0)}getCroppedImage(e){let t=e.data.object,i=t.cropper.getData(!0),a=new URL(t.cropper.url);_.assign(i,{id:$("body").data("id"),page:t.page,zoom:a.searchParams.get("zoom")}),location.assign(window.IL_BASE_URL+"index.php/page/loadcrop?"+$.param(i))}saveCroppedImage(e){let t=e.data.object,i=t.cropper.getData(!0),a=new URL(t.cropper.url);_.assign(i,{id:$("body").data("id"),page:t.page,zoom:a.searchParams.get("zoom")}),model.save({url:window.IL_BASE_URL+"index.php/page/savecrop",data:$.param(i)})}toggleLeft(e){let t="object"==typeof e?e.data.object:this;$(".pdfviewer-left").hasClass("d-none")?t.showLeft():t.hideLeft()}showLeft(){$(".pdfviewer-left").removeClass("d-none"),$(window).trigger("resize.PdfMainView"),store.save("il.leftPanel",$(".pdfviewer-left").is(":visible")),!0===$("#pdfviewer-thumbs").hasClass("d-none")&&!0===$("#pdfviewer-bookmarks").hasClass("d-none")&&!0===$("#pdfviewer-notes").hasClass("d-none")&&!0===$("#pdfviewer-results").hasClass("d-none")&&this.showThumbs()}hideLeft(){$(".pdfviewer-left").addClass("d-none"),$(window).trigger("resize.PdfMainView"),store.save("il.leftPanel",$(".pdfviewer-left").is(":visible"))}showThumbs(e){let t="object"==typeof e?e.data.object:this;$("#pdfviewer-thumbs").removeClass("d-none"),$("#pdfviewer-bookmarks").addClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").addClass("d-none"),t.redrawNoteLine(),t.redrawSnippetLine();$(".pdfviewer-thumb > img").each(function(){"200px"!==this.style.width&&(this.style.width="200px",this.style.height=200/this.getAttribute("width")*this.getAttribute("height")+"px")})}showBookmarks(e){let t="object"==typeof e?e.data.object:this;if(1===$("#pdfviewer-bookmarks :text").length)return $("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-bookmarks").removeClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").addClass("d-none"),t.redrawNoteLine(),t.redrawSnippetLine(),!1;$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/bookmarks?id="+$("body").data("id")})).done(function(e){$("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").addClass("d-none"),$("#pdfviewer-bookmarks").removeClass("d-none").html(e.html),$("#pdfviewer-bookmarks :text").filterable({targets:"#pdfviewer-bookmarks a"}).val(""),t.redrawNoteLine(),t.redrawSnippetLine()})}clickBookmark(e){e.preventDefault(),e.data.object.scrollToPage($(this).data("page"))}nightMode(){$("#pdfviewer-pages > .pdfviewer-right > .pdfviewer-page").toggleClass("img-night-mode img-light-mode");let e=$("#pdfviewer-pages > .pdfviewer-right > .pdfviewer-page:first").hasClass("img-night-mode");e?imageFilter.nightMode():imageFilter.lightMode(),store.save("il.nightMode",e)}toggleTextLayer(e){let t=e.data.object,i=t.page;0===$("#pdfviewer-pages").find(".pdfviewer-text").length?(t.clearHighlights(e),t.clearNotes(e),void 0===t.selectable&&(t.selectable=new Selectable({lasso:{backgroundColor:"transparent"},lassoSelect:"sequential",appendTo:"#pdfviewer-pages",maxSelectable:1e3})),t.selectable.off("end"),t.selectable.on("end",t.copyText),t.getBoxes(i)):t.destroyTextLayer()}destroyTextLayer(){$("#pdfviewer-pages").find(".pdfviewer-text").remove(),"object"==typeof this.selectable&&(this.selectable.off("end",this.copyText),this.selectable.disable(),this.selectable.destroy(),this.selectable=void 0)}copyText(){let e="";if($(".pdfviewer-text").children(".ui-selected").each(function(){e=e+$(this).attr("data-text")+" "}),e=(e=e.replace(/(- )/g,"")).replace(/\s{2,}/g," "),""===(e=$.trim(e)))return!1;$('").appendTo("body"),$("#copy-text-container").select();try{document.execCommand("copy"),$("#copy-text-container").remove()}catch(e){return $.jGrowl("Copied to clipboard not supported by this browser."),!1}$.jGrowl('
'+e+"
",{header:"Copied to clipboard",theme:"bg-primary"}),this.clear()}getHighlights(){$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/highlights",data:{id:$("body").data("id")},async:!0})).done(function(e){$("#pdfviewer-pages").find(".pdfviewer-highlights").remove();let t="";"underlined"===store.load("il.highlightStyle")&&(t="underlined"),_.forEach(e.highlights,function(e,i){let a=$("#pdfviewer-pages").find(".pdfviewer-page").eq(i-1);$(e).addClass(t).insertAfter(a.children("img"))})})}showAnnotations(e){let t=e.data.object;0===$("#pdfviewer-pages").find(".pdfviewer-highlights").length&&t.getHighlights(),t.showNotes(e)}hideAnnotations(e){let t=e.data.object;t.clearHighlights(e),t.clearNotes(e)}addHighlights(e){let t=e.data.object,i=t.page;t.clearNotes(e),$(this).hasClass("highlight-blue")?(store.save("il.highlight","B"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-blue")):$(this).hasClass("highlight-yellow")?(store.save("il.highlight","Y"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-yellow")):$(this).hasClass("highlight-green")?(store.save("il.highlight","G"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-green")):$(this).hasClass("highlight-red")&&(store.save("il.highlight","R"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-red")),0===$("#pdfviewer-pages").find(".pdfviewer-highlights").length&&t.getHighlights(),void 0===t.selectable&&(t.selectable=new Selectable({lasso:{backgroundColor:"transparent"},lassoSelect:"sequential",appendTo:"#pdfviewer-pages",maxSelectable:1e3})),t.selectable.off("end"),t.selectable.on("end",t.saveHighlights),0===$("#pdfviewer-pages").find(".pdfviewer-text").length&&t.getBoxes(i)}saveHighlights(e,t){let i,a=window.pdfmainview||views.pdfmain,o={},n=store.load("il.highlight");switch(n){case"R":i="red";break;case"G":i="green";break;case"B":i="blue";break;case"Y":i="yellow"}_.forEach(t,function(e,t){let a,n,s,r,l=$(e.node),d=l.parent().siblings(".pdfviewer-highlights"),c=l.attr("style").split(";");l.clone().removeClass("ui-selectable ui-selected").addClass(i).appendTo(d),_.forEach(c,function(e){let t=e.split(":");switch(t[0]){case"top":a=10*parseFloat(t[1].slice(0,-1));break;case"left":n=10*parseFloat(t[1].slice(0,-1));break;case"width":s=10*parseFloat(t[1].slice(0,-1));break;case"height":r=10*parseFloat(t[1].slice(0,-1))}}),o[t]={page:l.closest(".pdfviewer-page").data("page"),top:a,left:n,width:s,height:r,position:l.data("position"),text:l.attr("data-text")}}),"object"==typeof o[0]&&$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/savehighlights",data:{id:$("body").data("id"),color:n,boxes:JSON.stringify(o)},async:!0})).done(function(){a.getHighlights()})}clearHighlights(e){let t=e.data.object,i=$("#pdfviewer-pages");i.find(".pdfviewer-text").remove(),store.delete("il.highlight"),"object"==typeof t.selectable&&(t.selectable.off("end",t.saveHighlights),t.selectable.destroy(),t.selectable=void 0),i.find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}),i.find(".pdfviewer-highlights").remove()}eraserInit(e){let t=e.data.object,i=$("#pdfviewer-pages");i.find(".pdfviewer-highlights").length>0&&(void 0===t.selectable&&(t.selectable=new Selectable({lasso:{backgroundColor:"transparent"},lassoSelect:"sequential",appendTo:"#pdfviewer-pages",maxSelectable:1e3})),t.selectable.off("end"),t.selectable.on("end",t.deleteHighlights),0===i.find(".pdfviewer-text").length&&t.getBoxes(t.page),i.find(".pdfviewer-page").addClass("cursor-eraser"))}deleteHighlights(e,t){let i=window.pdfmainview||views.pdfmain,a={};_.forEach(t,function(e,t){let i=$(e.node),o=i.parent().siblings(".pdfviewer-highlights"),n=i.data("position");o.children('[data-position="'+n+'"]').remove(),a[t]={page:i.closest(".pdfviewer-page").data("page"),position:n}}),"object"==typeof a[0]&&$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/deletehighlights",data:{id:$("body").data("id"),boxes:JSON.stringify(a)},async:!0})).done(function(){i.getHighlights()})}highlightStyle(){!0===$(this).prop("checked")?($("#pdfviewer-pages").find(".pdfviewer-highlights").addClass("underlined"),store.save("il.highlightStyle","underlined")):($("#pdfviewer-pages").find(".pdfviewer-highlights").removeClass("underlined"),store.save("il.highlightStyle","highlight"))}getLinks(){let e=new EventSource(IL_BASE_URL+"index.php/pdf/links?id="+$("body").data("id"));e.onmessage=function(t){if("CLOSE"===t.data||0===$("#pdfviewer-pages").length)e.close();else{let e=JSON.parse(t.data);_.forEach(e,function(e,t){$("#pdfviewer-pages").find(".pdfviewer-page").eq(t-1).append(e)})}}}getBoxes(e){let t=this;$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/boxes",data:{id:$("body").data("id"),page:e},async:!0})).done(function(e){$("#pdfviewer-pages").find(".pdfviewer-text").remove(),_.forEach(e.boxes,function(e,i){let a=$("#pdfviewer-pages").find(".pdfviewer-page").eq(i-1);a.append(e),t.selectable.add(a.children(".pdfviewer-text").children().get())})})}search(e){if(13!==e.which)return!1;let t,i=e.data.object,a=$(this),o=$(".pdfviewer-right > div:last-child").data("page"),n=$("#pdfviewer-results > .pdfviewer-no-results-container"),s=$("#pdfviewer-results > .pdfviewer-results-container"),r=$("#pdfviewer-search-progress"),l=$("#pdfviewer-pages");n.removeClass("d-none"),s.empty(),l.find(".pdfviewer-result-boxes").remove(),"object"==typeof i.sseSearch&&2!==i.sseSearch.readyState&&(i.sseSearch.close(),clearTimeout(t),r.addClass("d-none"),r.find("div").width("0%").attr("aria-value-now","0%")),t=setTimeout(function(){r.removeClass("d-none")},500),i.sseSearch=new EventSource(IL_BASE_URL+"index.php/pdf/search?id="+$("body").data("id")+"&query="+a.val()),i.sseSearch.onmessage=function(e){if("CLOSE"===e.data||0===l.length)i.sseSearch.close(),clearTimeout(t),r.addClass("d-none"),r.find("div").width("0%").attr("aria-value-now","0%");else{let t=JSON.parse(e.data);_.forEach(t.boxes,function(e,t){l.find(".pdfviewer-page").eq(t-1).children("img").after(e)}),_.forEach(t.snippets,function(e){$(e).appendTo("#pdfviewer-results > .pdfviewer-results-container"),!1===n.hasClass("d-none")&&n.addClass("d-none")});let i=Math.floor(Math.min(100,100*t.last_page/o));r.find("div").width(i+"%").attr("aria-value-now",i+"%"),0===s.find("a.bg-dark").length&&s.find("a").eq(0).trigger("click").focus()}},i.showResults(),!1===$(".navbar-toggler").is(":visible")&&i.showLeft()}showResults(e){let t="object"==typeof e?e.data.object:this;$("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-bookmarks").addClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").removeClass("d-none"),t.redrawNoteLine(),t.redrawSnippetLine()}scrollToResult(e){let t=e.data.object;$("#pdfviewer-results .snippet").removeClass("bg-dark"),$(this).addClass("bg-dark");let i=$("#"+$(this).data("box"));t.drawSnippetLine($(this).data("box")),t.scrollToElement(i),$(".pdfviewer-result-boxes > div").removeClass("active"),i.addClass("active")}nextResult(){let e=$("#pdfviewer-results a.bg-dark").next();1===e.length?e.trigger("click"):$("#pdfviewer-results a").eq(0).trigger("click")}prevResult(){let e=$("#pdfviewer-results a.bg-dark").prev();1===e.length?e.trigger("click"):$("#pdfviewer-results a").last().trigger("click")}showNotes(e){let t=e.data.object;$("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-bookmarks").addClass("d-none"),$("#pdfviewer-notes").removeClass("d-none"),$("#pdfviewer-results").addClass("d-none"),t.redrawSnippetLine(),$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/notelist",data:{id:$("body").data("id")}})).done(function(e){$("#pdfviewer-notes").html(e.list),_.forEach(e.pages,function(e,t){let i=$("#pdfviewer-pages").find(".pdfviewer-page").eq(t-1);i.find(".pdfviewer-notes").remove(),i.append(e)}),$(".pdfnote").tooltip({animation:!1,template:''}).on("shown.bs.tooltip",function(){"function"==typeof window.MathJax.typeset&&window.MathJax.typeset(),$(this).tooltip("update")}),$("#pdfviewer-notes").on("click",".note-btn",function(){let e=$(this).data("id");t.scrollToElement($("#pdfnote-"+e)),$(".note-btn").removeClass("active"),$(this).addClass("active"),$(".pdfnote").tooltip("hide"),t.drawNoteLine(e)}),$(".pdfnote").on("click",function(){let e=$(this).data("id");$("#pdfviewer-notes .note-btn").removeClass("active"),$("#pdfviewer-notes").find('.note-btn[data-id="'+e+'"]').addClass("active"),t.drawNoteLine(e)}),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset()})}editNote(e){let t=$(this).parent();t.addClass("d-none"),t.next().removeClass("d-none")}saveNote(e){let t=e.data.object,i=$(this),a=i.find("textarea").val(),o=i.parent().data("id")||0,n=$("body").data("id");e.preventDefault(),$.when(model.save({url:i.attr("action"),data:i.serialize()+"&id="+n,async:!0})).done(function(){i.addClass("d-none"),""===$.trim(a)||0===o?t.showNotes(e):(i.prev().removeClass("d-none").find("button").eq(0).text(a),$("#pdfnote-"+o).attr("data-title",a).attr("data-original-title",a),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset())})}createNewNote(e){let t=e.data.object;!0===$(".pdfviewer-page").hasClass("cursor-cross")?t.clearNewNote():(t.clearHighlights(e),t.showNotes(e),t.showLeft(),$(".pdfviewer-page").addClass("cursor-cross"),$(".pdfviewer-page").on("click.createnote",".pdfviewer-notes",function(e){let i=Math.round(1e3*(e.pageX-$(this).offset().left)/$(this).width()),a=Math.round(1e3*(e.pageY-$(this).offset().top)/$(this).height()),o=$(this).closest(".pdfviewer-page").data("page"),n=$("#new-note-form");n.removeClass("d-none").find('[name="pg"]').val(o),n.find('[name="left"]').val(i),n.find('[name="top"]').val(a),$(".pdfnote.new").remove(),$('
').appendTo(this),t.clearNewNote()}))}clearNotes(e){e.data.object.clearNewNote(),$("#pdfviewer-notes").empty(),$("#pdfviewer-pages").find(".pdfviewer-notes").remove()}clearNewNote(){$(".pdfviewer-page").removeClass("cursor-cross"),$(".pdfviewer-page").off("click.createnote")}drawNoteLine(e){let t=$("#pdfnote-"+e),i=$("#pdfviewer-notes").find('.note-group[data-id="'+e+'"]'),a=t[0].getBoundingClientRect(),o=i[0].getBoundingClientRect(),n=o.right,s=Math.min(o.top+15,a.top),r=a.left-o.right,l=a.top-(o.top+15),d="";(null===i[0].offsetParent||s<50||l+s>$(window).height()||r<1)&&(d="d-none");let c="";l<0&&(c='transform="scale (-1, 1)" transform-origin="center"',l=Math.abs(l)),0===l&&(l=1);let h=`\n \n \n `;$("#note-line").remove(),t.parent().prepend(h)}redrawNoteLine(){let e=$("#note-line");1===e.length&&this.drawNoteLine(e.attr("data-note-id"))}drawSnippetLine(e){let t=$("#"+e),i=$(".pdfviewer-results-container").find('[data-box="'+e+'"]'),a=t[0].getBoundingClientRect(),o=i[0].getBoundingClientRect(),n=o.right,s=Math.min(o.top+20,a.top),r=a.left-o.right,l=a.top-(o.top+20),d="";(null===i[0].offsetParent||s<50||l+s>$(window).height()||r<1)&&(d="d-none");let c="";l<0&&(c='transform="scale (-1, 1)" transform-origin="center"',l=Math.abs(l)),0===l&&(l=1);let h=`\n \n \n `;$("#snippet-line").remove(),t.parent().prepend(h)}redrawSnippetLine(){let e=$("#snippet-line");1===e.length&&this.drawSnippetLine(e.attr("data-snippet-id"))}openLink(e){let t=e.data.object,i=$(this).data("href");"number"==typeof i?t.scrollToPage(i):window.open(i)}}views.pdfmain=new PdfMainView;class PdfManageView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){$("#upload-form").uploadable(),$("#delete-pdf").confirmable({submit:function(){let e=$("body").data("id");$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/delete",data:{id:e}})).done(function(){B.history.loadUrl()})}}),$("#reindex-pdf").confirmable({submit:function(){let e=$("body").data("id");$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/extract",data:{id:e}})).done(function(){B.history.loadUrl()})}}),$("#ocr-pdf").confirmable({submit:function(){let e=$("#ocr-form");$.when(model.save({url:e.attr("action"),data:e.serialize()})).done(function(){B.history.loadUrl()})}}),$("body").off("submit.pdfmanage").on("submit.pdfmanage","#ocr-form",function(e){e.preventDefault()}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}}views.pdfmanage=new PdfManageView;class ImportWizardView extends View{constructor(){super(),this.parent="#content-col"}}views.importwizard=new ImportWizardView;class ImportUidView extends View{constructor(){super(),this.parent="#content-col",this.inputType="",this.events={"click #fetch-record":"fetch","input #uid":"uidResolve","keydown #uid":"preventSubmit"}}afterRender(e){formStyle.init(),$("#upload-form").uploadable(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}uidResolve(e){let t=$.trim($(this).val());if(!0===/^10\.\d{4}/.test(t))$("#new-uid-type").val("DOI");else if(!0===/^http/i.test(t)){let e=new URL(t).pathname.substr(1);!0===/^10\.\d{4}/.test(e)&&($(this).val(e),$("#new-uid-type").val("DOI"))}else!0===/^pmid:/i.test(t)?$("#new-uid-type").val("PMID"):!0===/^ieee:/i.test(t)?$("#new-uid-type").val("IEEE"):!0===/^arxiv:/i.test(t)?$("#new-uid-type").val("ARXIV"):!0===/^[0-9]{4}.{14}[A-Z]/.test(t)?$("#new-uid-type").val("NASAADS"):!0===/^pmc.*|pmcid:/i.test(t)?$("#new-uid-type").val("PMCID"):!0===/^OL/.test(t)?$("#new-uid-type").val("OL"):!0===/^[A-Z]{2}\d+/.test(t)?$("#new-uid-type").val("PAT"):!0===/^[SP]\d/.test(t)?$("#new-uid-type").val("DIRECT"):!0===/^ISBN:\s?\d/.test(t)?$("#new-uid-type").val("ISBN"):$("#new-uid-type").val("");$("#select-type").collapse("show")}fetch(e){let t=$.trim($("#uid").val());switch($("#new-uid-type").val()){case"DOI":$.when(model.load({url:window.IL_BASE_URL+"index.php/crossref/fetch",data:{uid:t}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))}).fail(function(e){404===e.status&&$("#uid-message").removeClass("d-none").html("No record found. Try another UID.")});break;case"PMID":let e=t.replace(/\D/g,"");$.when(model.load({url:"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id="+e,cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/pubmed/format",data:{xml:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"PMCID":let i=$.trim(t.replace(/pmcid:/gi,""));$.when(model.load({url:"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&retmode=xml&id="+i,cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/pmc/format",data:{xml:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"ISBN":let a=$.trim(t.replace(/isbn:/gi,""));$.when(model.load({url:"https://openlibrary.org/api/books?bibkeys=ISBN:"+a+"&jscmd=data&format=json",cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/ol/convert",data:{json:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"OL":let o=$.trim(t.replace(/isbn:/gi,""));$.when(model.load({url:"https://openlibrary.org/api/books?bibkeys=OLID:"+o+"&jscmd=data&format=json",cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/ol/convert",data:{json:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"IEEE":let n=t.replace(/ieee:\s?/i,"");$.when(model.load({url:window.IL_BASE_URL+"index.php/ieee/fetch",data:{uid:n}})).done(function(e){let t=e.items[0];$(".import-wizard-uid").html('Record found:
'+t.title+"
"),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none")});break;case"ARXIV":let s=t.replace(/arxiv:\s?/i,"");$.when(model.load({url:arxiv.url+s,cors:!0,dataType:"xml"})).done(function(e){let t=$(e).find("entry"),i=t.children("title").text();$(".import-wizard-uid").html('Record found:
'+i+"
"),$("#metadata").val(arxiv.metadata($(e))),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none")}).fail(function(e){400===e.status&&$("#uid-message").removeClass("d-none").html("No record found. Try another UID.")});break;case"NASAADS":$.when(model.load({url:window.IL_BASE_URL+"index.php/nasa/fetch",data:{uid:t}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))});break;case"PAT":let r=t.replace(/patent:\s?/i,"");$.when(model.load({url:window.IL_BASE_URL+"index.php/patents/fetch",data:{uid:r}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})}}preventSubmit(e){13===e.which&&(e.preventDefault(),e.data.object.fetch())}}views.importuid=new ImportUidView;class ImportFileView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){formStyle.init(),$("#upload-form").uploadable(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}}views.importfile=new ImportFileView;class ImportTextView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){formStyle.init(),$("#upload-form").uploadable(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}}views.importtext=new ImportTextView;class ImportManualView extends View{constructor(e){super(),this.parent="#content-col",this.editmain=e}afterRender(e){formStyle.init(),$("#upload-form").uploadable({pdftitles:function(e,t){$("#extracted-titles").empty(),t.titles.length>0&&$("#title").val(t.titles.pop())},change:function(e,t){$("#title").val(t.name.substr(0,t.name.lastIndexOf(".")))},clear:function(e){$("#title").val("")}}),this.editmain.uploadFormWidgets(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}}views.importmanual=new ImportManualView(views.editmain);class ExternalMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .search-form":"search","click .delete-search":"deleteSearch","click .edit-search":"loadForm"}}afterRender(e){formStyle.init(),$(".clone-button").clonable({target:"#search-row"}),$(this.parent).find("form").saveable()}search(e){e.preventDefault(),$(this).saveable("save");let t=$(this).serialize();router.navigate($(this).attr("action")+"?"+t,{trigger:!0})}deleteSearch(e){let t=$(this);$.when(model.save({url:t.data("url"),data:{id:t.data("id")}})).done(function(){B.history.loadUrl()})}loadForm(){let e=$(this).closest(".list-group-item").find("a").attr("href"),t=new URL("http://foo.bar/"+e.substr(1)).searchParams.entries(),i=[];for(let e of t){const[t,a]=e;""!==a&&i.push({name:t,value:a})}let a=$("#content-col").find("form");a.saveable("saveParams",i),a.saveable("load")}}views.ieeemain=new ExternalMainView,views.arxivmain=new ExternalMainView,views.crossrefmain=new ExternalMainView,views.pubmedmain=new ExternalMainView,views.pmcmain=new ExternalMainView,views.nasamain=new ExternalMainView,views.patentsmain=new ExternalMainView,views.sciencedirectmain=new ExternalMainView,views.scopusmain=new ExternalMainView;class ExternalSearchView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .add-pdf-btn":"makeUploadable","click button":"makeUploadable"}}afterRender(e){formStyle.init(),$(window).off("resize.ExternalSearchView").on("resize.ExternalSearchView",function(){views.itemsmain.itemsHeight()}),views.itemsmain.itemsHeight(),$("#content-col .tag-filter").filterable({complete:function(){let e=$(this).closest(".collapse"),t=$(this).closest(".collapse").find("table");e.find(".label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),t.find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}makeUploadable(){$(this).closest("form").uploadable()}}views.ieeesearch=new ExternalSearchView,views.arxivsearch=new ExternalSearchView,views.crossrefsearch=new ExternalSearchView,views.pubmedsearch=new ExternalSearchView,views.pmcsearch=new ExternalSearchView,views.nasasearch=new ExternalSearchView;class GlobalSettingsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #settings-form":"submitForm"}}afterRender(e){formStyle.init()}submitForm(e){e.preventDefault();let t=$(this),i=$.trim($("#wpad-url").val());!0===$("#connection-url").prop("checked")&&""!==i?$.getScript(i,function(){let e=FindProxyForURL("","www.crossref.org"),i="",a=e.split(";");_.forEach(a,function(e){if(0===_.trim(e).indexOf("PROXY"))return i=e.substr(6),$("#proxy-pac").val(i),!1}),$.when(model.save({url:t.attr("action"),data:t.serialize()}))}).fail(function(){$.jGrowl("Unable to fetch the PAC/WPAD file.",{header:"Error",theme:"bg-danger"})}):$.when(model.save({url:t.attr("action"),data:t.serialize()}))}}views.globalsettingsmain=new GlobalSettingsMainView;class UsersMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .update-user":"updateUser","click #create-user":"createUser"}}afterRender(e){$(".reset-password").confirmable({submit:this.resetPassword})}updateUser(){let e=$(this).closest("tr"),t=e.find(".email").val();""!==$.trim(t)?$.when(model.save({url:window.IL_BASE_URL+"index.php/users/update",data:{user:{username:e.find(".username").text(),first_name:e.find(".first-name").val(),last_name:e.find(".last-name").val(),email:t,permissions:e.find(".permissions").val(),status:e.find(".status").val()}}})).done(function(){B.history.loadUrl()}):$.jGrowl("Email is required.",{header:"Info",theme:"bg-primary"})}createUser(){let e=$(this).closest("tr"),t=e.find(".email").val();""!==$.trim(t)?$.when(model.save({url:window.IL_BASE_URL+"index.php/users/create",data:{user:{username:e.find(".username").val(),first_name:e.find(".first-name").val(),last_name:e.find(".last-name").val(),email:t,permissions:e.find(".permissions").val()}}})).done(function(e){"string"==typeof e.password&&$.jGrowl(e.password,{sticky:!0,theme:"bg-dark text-light"}),B.history.loadUrl()}):$.jGrowl("Email is required.",{header:"Info",theme:"bg-primary"})}resetPassword(){let e=$(this).closest("tr"),t=e.find(".email").val();""!==$.trim(t)?$.when(model.save({url:window.IL_BASE_URL+"index.php/users/reset",data:{user:{username:e.find(".username").text(),email:t}}})).done(function(e){"string"==typeof e.password&&$.jGrowl(e.password,{sticky:!0,theme:"bg-dark"})}):$.jGrowl("User's email is required to reset password.",{header:"Info",theme:"bg-primary"})}}views.usersmain=new UsersMainView;class DetailsMainView extends View{constructor(){super(),this.parent="#content-col"}}views.detailsmain=new DetailsMainView;class LogsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .form-chart":"submitForm","submit #form-list":"drawTable"}}afterRender(e){formStyle.init(),chart.draw("chart-opens",_.keys(e.opens),null,_.values(e.opens)),chart.draw("chart-pages",_.keys(e.pages),null,_.values(e.pages)),chart.draw("chart-downloads",_.keys(e.downloads),null,_.values(e.downloads)),window.tables["table-logs"]=$("#table-logs").DataTable({deferRender:!0,order:[[2,"desc"],[0,"asc"]]})}submitForm(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action"),data:t.serialize()})).done(function(e){void 0!==e.opens?chart.draw("chart-opens",_.keys(e.opens),null,_.values(e.opens)):void 0!==e.pages?chart.draw("chart-pages",_.keys(e.pages),null,_.values(e.pages)):void 0!==e.downloads&&chart.draw("chart-downloads",_.keys(e.downloads),null,_.values(e.downloads))})}drawTable(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action"),data:t.serialize()})).done(function(e){window.tables["table-logs"].clear().rows.add(e).draw()})}}views.logsmain=new LogsMainView;class CitationMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #form-new-csl":"submitForm"}}afterRender(e){window.tables["table-csl"]=$("#table-csl").DataTable({deferRender:!0,data:e.styles,columnDefs:[{orderable:!1,targets:2}]}),$("#modal-csl").off("shown.bs.modal").on("shown.bs.modal",function(e){$("#modal-csl").find(".modal-title").text($(e.relatedTarget).attr("data-name")),$.when(model.load({url:window.IL_BASE_URL+"index.php/citation/get",data:{id:$(e.relatedTarget).attr("data-id")}})).done(function(e){$("#modal-csl").find("code").html(e.csl)})})}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){t[0].reset()})}}views.citationmain=new CitationMainView;class MainView{constructor(){sidebar.init(),""!==location.hash&&"#"!==location.hash||1!==$("#side-menu").length||router.navigate("dashboard/main",{trigger:!0,replace:!0}),$("#signin-form").on("submit",function(e){e.preventDefault();let t=$(this),i=new URL(window.location.href).searchParams.get("ref");""!==$.trim(t.find('[name="username"]').val())&&""!==$.trim(t.find('[name="password"]').val())&&$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(e){if(void 0===e.info)if("string"==typeof i){let e=window.atob(i);new URL(e).hostname===location.hostname?location.replace(e):location.replace(IL_BASE_URL+"index.php/#dashboard/main")}else location.replace(IL_BASE_URL+"index.php/#dashboard/main")})}),$("#migrate-form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action")+"?"+t.serialize()})).done(function(e){void 0===e.info&&location.replace(window.IL_BASE_URL)})}),$("#sign-out").on("click",function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/authentication/signout"})).done(function(){location.assign(window.IL_BASE_URL)})}),$(".modal-content").draggable({containment:"document",handle:".modal-header"}),$("#keyboard-toggle").on("click",function(){keyboard.init()}),$("#content-col").on("click","#open-settings",function(){""===$.trim($("#modal-settings").find(".modal-body").html())&&$.when(model.load({url:window.IL_BASE_URL+"index.php/settings/display"})).done(function(e){$("#modal-settings").find(".modal-body").html(e.html),formStyle.init()})}),$("#modal-settings .modal-footer button").eq(0).on("click",function(e){$("#modal-settings form").trigger("submit")}),$("#modal-settings").on("submit","form",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()}),$("#modal-settings").modal("hide")}),searchlist.init()}}class MigrationView{constructor(){$("#migrate-form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action")+"?"+t.serialize()})).done(function(e){void 0===e.info&&location.replace(window.IL_BASE_URL)})})}}class RegistrationView{constructor(){$("#signup-form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(e){void 0===e.info&&location.assign(window.IL_BASE_URL)})})}}class ResetpasswordView{constructor(){$("form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(e){$(".container-fluid").html(e.html)})}),$("body").on("click","#new-password",function(){let e=window.getSelection(),t=document.createRange();t.selectNodeContents($("#new-password")[0]),e.removeAllRanges(),e.addRange(t)})}}class ItemView{constructor(){sidebar.init();let e="string"==typeof store.load("il.itemReferrer")?store.load("il.itemReferrer"):window.IL_BASE_URL+"#items/main";$("#item-back-link").attr("href",e);let t=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",t).data("id",t),$("#id-hidden").val(t),$("a.add-id-link").each(function(){let e=$(this).attr("href").split("id=");$(this).attr("href",e[0]+"id="+t)}),$("#keyboard-toggle").on("click",function(){keyboard.init()}),$("#sign-out").on("click",function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/authentication/signout"})).done(function(){location.assign(window.IL_BASE_URL)})});let i=sessionStore.load("il.idList");if(null===i||i.length<2)$("#left-item-list").addClass("d-none");else{let e=$("#left-item-list .left-item-link").detach(),a=e.attr("href");i.forEach(function(i){let o=i.id===t?"bg-darker-10":"";e.clone().addClass(o).attr("href",a.replace("{ID}",i.id)).attr("data-id",i.id).html(i.title).appendTo("#left-item-list")}),e=void 0,$("#left-item-list").removeClass("d-none").hide().fadeIn()}}clickTitle(){let e=$("#left-item-list"),t=$("#left-item-list .left-item-link.bg-darker-10");if(0===t.length)return e.addClass("d-none"),void sessionStore.delete("il.idList");if(e.hasClass("d-none"))return;let i=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("#left-item-list .left-item-link").each(function(){$(this).removeClass("bg-darker-10"),$(this).attr("data-id")===i&&$(this).addClass("bg-darker-10")});let a=t.position().top,o=e.scrollTop(),n=t[0].getBoundingClientRect(),s=e[0].getBoundingClientRect();(n.top<10||s.bottom-n.bottom<10)&&e.animate({scrollTop:o+a-$(window).height()/3},250),$("a.add-id-link").each(function(){let e=$(this).attr("href").split("id=");$(this).attr("href",e[0]+"id="+i)}),$("body").attr("data-id",i).data("id",i),1===$("#id-hidden").length&&$("#id-hidden").val()!==i&&$.when(model.load({url:window.IL_BASE_URL+"index.php/notes/user",data:{id:i}})).done(function(e){$("#notes-ta").val(e.user.note),$("#id-hidden").val(i),null!==window.tinymce.activeEditor&&!0===window.tinymce.activeEditor.initialized&&window.tinymce.activeEditor.load()})}changeTitleLink(){if($("#left-item-list").hasClass("d-none"))return;let e="#"+new URL("http://foo.bar/"+location.hash.substring(1)).pathname.substring(1);$("#left-item-list .left-item-link").each(function(){$(this).attr("href",e+"?id="+$(this).attr("data-id"))})}}class ProjectView{constructor(){sidebar.init();let e=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",e).data("id",e),$("a.add-id-link").each(function(){let t=$(this).attr("href").split("id=");$(this).attr("href",t[0]+"id="+e)}),$("#id-hidden").val(e),$("#content-col").on("click",".open-notes",{object:this},this.openNotes),$("#keyboard-toggle").on("click",function(){keyboard.init()}),$("#content-col").on("click","#open-settings",function(){""===$.trim($("#modal-settings").find(".modal-body").html())&&$.when(model.load({url:window.IL_BASE_URL+"index.php/settings/display"})).done(function(e){$("#modal-settings").find(".modal-body").html(e.html),formStyle.init()})}),$("#modal-settings .modal-footer button").eq(0).on("click",function(e){$("#modal-settings form").trigger("submit")}),$("#modal-settings").on("submit","form",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()}),$("#modal-settings").modal("hide")}),$("#sign-out").on("click",function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/authentication/signout"})).done(function(){location.assign(window.IL_BASE_URL)})}),searchlist.init()}openNotes(e){null!==window.tinymce.activeEditor&&!0===window.tinymce.activeEditor.initialized?$("#notes-window").removeClass("d-none"):e.data.object.loadNotes()}loadNotes(){let e=this,t=$("body").data("id");$.when(model.load({url:window.IL_BASE_URL+"index.php/project/usernotes",data:{id:t}})).done(function(t){$("#notes-ta").val(t.user.note),e.initNotes()})}initNotes(){window.tinymce.init({theme:"silver",selector:"#notes-ta",content_css:window.IL_BASE_URL+"css/style.css",resize:"both",min_width:300,min_height:300,menubar:!1,plugins:"importcss save lists advlist link image code fullscreen table searchreplace",toolbar1:"save undo redo fullscreen code | formatselect link unlink image table searchreplace",toolbar2:"bold italic underline strikethrough subscript superscript removeformat | forecolor backcolor | outdent indent bullist numlist",save_onsavecallback:function(e){let t=$("#note-form");$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){$("#user-note").html(e.getContent()),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset()})},image_description:!1,relative_urls:!1,remove_script_host:!1,image_dimensions:!1,image_class_list:[{title:"Auto width",value:"mce-img-fluid"}]}).then(function(){let e=$("#notes-window");e.removeClass("d-none"),e.position({my:"left bottom",at:"left bottom",of:"#content-col"}),$(window).off("resize.notes").on("resize.notes",function(){$("#notes-window").position({my:"left bottom",at:"left bottom",of:"#content-col"})}),e.draggable({handle:".card-header",containment:"body"}),e.find(".close").off("click.notes").on("click.notes",function(){$("#notes-window").addClass("d-none")})})}}$(function(){B.history.start(),$("body").on("click","a",function(){let e=$(this).attr("href");return e.indexOf("//")>0||0===e.indexOf("mailto")||0===e.indexOf("data")?(!0===/\/item#/.test(e)&&store.save("il.itemReferrer",location.href),!0):"#"!==e&&""!==e&&void router.navigate(e,{trigger:!0})}),$("body").on("click","#abort-request",function(){model.abort()}),$(document).on("keydown.hotkeys",null,"a",function(){$(".navigation-left").trigger("click")}),$(document).on("keydown.hotkeys",null,"w",function(){$(".navigation-left").trigger("click")}),$(document).on("keydown.hotkeys",null,"d",function(){$(".navigation-right").trigger("click")}),$(document).on("keydown.hotkeys",null,"s",function(){$(".navigation-right").trigger("click")}),$(document).on("keydown.hotkeys",null,"esc",function(){1===$("#pdfviewer-menu").length&&"object"==typeof views.pdfmain&&(views.pdfmain.destroyCropper(),views.pdfmain.destroyTextLayer(),views.pdfmain.clearNewNote(),$("#pdfviewer-highlight-menu .highlight-cancel").click()),1===$("#pdfviewer-menu").length&&"object"==typeof window.pdfmainview&&(window.pdfmainview.destroyCropper(),window.pdfmainview.destroyTextLayer(),window.pdfmainview.clearNewNote(),$("#pdfviewer-highlight-menu .highlight-cancel").click())}),$(document).on("keydown.hotkeys",null,"h",function(){1===$("#pdfviewer-menu").length&&($(".left-container, #pdfviewer-menu").toggleClass("d-none"),$(window).trigger("resize.PdfMainView"))})}); \ No newline at end of file +"use strict";jQuery.fn.extend({insertAtCaret:function(e){return this.each(function(t){if(document.selection){this.focus(),document.selection.createRange().text=e,this.focus()}else if(this.selectionStart||0===this.selectionStart){let t=this.selectionStart,i=this.selectionEnd,a=this.scrollTop;this.value=this.value.substring(0,t)+e+this.value.substring(i,this.value.length),this.focus(),this.selectionStart=t+e.length,this.selectionEnd=t+e.length,this.scrollTop=a}else this.value+=e,this.focus()})}}),window.IL=[],window.charts=[],window.tables=[];let _=window._,B=window.Backbone;$.widget("il.typeahead",{searchId:"",ignoredKeys:[9,13,16,17,18,20,27,33,34,35,36,37,38,39,40,45],options:{delay:300,minLength:0,source:""},_getCreateOptions:function(){return{delay:this.element.attr("data-delay"),minLength:this.element.attr("data-minLength"),source:this.element.attr("data-source")}},_create:function(){this._on(this.element,{input:this._search,focus:this._search});let e=this.element.parent().next();this._on(e,{"click button":function(e){this.element.val($(e.target).text()).attr("data-id",$(e.target).attr("data-id")),this._clearMenus(),this._trigger("onSelect",null,{element:this.element})}}),this._on(e,{"keyup button":function(e){e.stopPropagation(),38===e.which&&$(e.target).prev().focus(),40===e.which&&$(e.target).next().focus(),27===e.which&&(this.element.focus(),this._clearMenus())}}),this._on("body",{click:this._clearMenus}),this._on(this.element.closest(".typeahead"),{click:function(e){e.stopPropagation()}}),this._on(this.window,{resize:this._resizeMenus})},_search:function(e){return 9===e.which||40===e.which?($(".typeahead").find("button:first").focus(),!1):(27===e.which&&this._clearMenus(),this.element.val().length=this.options.minLength?($(this.options.targets).addClass("d-none"),$(this.options.targets).filter(function(){let e=$(this),a=e.text(),o=t.test(a);return!0===o&&e.html(a.replace(i,'$1')),o}).removeClass("d-none")):$(this.options.targets).removeClass("d-none").each(function(){let e=$(this);e.html(e.text())}),this._trigger("complete",this.event)},_remoteSearch:function(){let e=this,t=this.options.source,i=this.options.container;$.when(model.load({url:t,data:{q:e.searchStr}})).done(function(t){$(i).replaceWith(t.html),e._trigger("complete",e.event)})},_escapeRegexp:function(e){let t=new RegExp("[\\"+["[","]","/","{","}","(",")","*","+","?",".","\\","^","$","|"].join("\\")+"]","gui");return e.replace(t,"\\$&")}}),$.widget("il.expandable",{table:'
',cell1:'
',cell2:'
',_create:function(){this._expandability(),this._on(this.window,{resize:this._expandability})},_expandability:function(){if(this.element.innerHeight()>40&&0===this.element.find(".il-expandable-left").length){this.element.wrapInner(this.cell2).wrapInner(this.table),this.element.children().prepend(this.cell1);let e="il-expandable-"+this.uuid;this.element.find(".il-expandable-left").find("button").attr("aria-controls",e),this.element.find(".il-expandable-right").attr("id",e).attr("aria-expanded","false").addClass("text-truncate"),this._on(this.element,{"click .il-expandable-left > button":this._toggle})}},_toggle:function(){this.element.find(".il-expandable-left").find(".mdi").toggleClass("mdi-chevron-right mdi-chevron-down"),this.element.find(".il-expandable-right").toggleClass("text-truncate").attr("aria-expanded",function(e,t){return"false"===t?"true":"false"})}}),$.widget("il.clonable",{options:{target:""},_create:function(){""!==this.options.target&&(this._addClass($(this.options.target),"clonable-target-"+this.uuid),this._on(this.element,{click:this._clone}),this._on(this.element.next(".remove-clone-button"),{click:this._removeClone}))},_clone:function(){let e=$(this.options.target),t="clonable-target-"+this.uuid,i=e.clone();e.removeAttr("id"),i.find("[id]").each(function(){let e=$(this).attr("id"),t=_.uniqueId();$(this).attr("id",e+"-"+t),i.find('[for="'+e+'"]').attr("for",e+"-"+t)}),i.find("[name]").each(function(){let e=$(this).attr("name").replace(/\[(\d+)]/,function(e,t){return"["+(parseInt(t)+1)+"]"});$(this).attr("name",e)}),i.find('[type="text"], [type="number"]').each(function(){this.value=""}),i.insertAfter($("."+t).last()),formStyle.init(),this._trigger("onClone",null,{clonedTarget:i[0]})},_removeClone:function(){let e="clonable-target-"+this.uuid,t=$("."+e),i=t.last(),a=i.attr("id");t.length<2||(i.remove(),$("."+e).last().attr("id",a))}}),$.widget("il.confirmable",{options:{target:"#modal-confirm",title:"Confirmation",body:"Confirm?",button:"Yes",submit:function(){}},_getCreateOptions:function(){return{target:this.element.data("target"),title:this.element.data("title"),body:this.element.data("body"),button:this.element.data("button")}},_create:function(){this._on(this.element,{click:this._modal})},_modal:function(){let e=this,t=$(this.options.target),i=t.find(".modal-footer > button").eq(0);t.find(".modal-title").html(this.options.title),t.find(".modal-body").html(this.options.body),t.find(".modal-footer > button").eq(0).html(this.options.button),formStyle.init(),t.modal("show"),$(i).off("click").on("click",function(i){e._trigger("submit",i),t.modal("hide")})}}),$.widget("il.saveable",{_create:function(){"form"===this.element.get(0).nodeName.toLowerCase()&&void 0!==this.element.attr("id")&&(this._on(this.element,{save:this.save}),this.load())},save:function(){let e=this.element,t=[],i=this.element.serializeArray();_.forEach(i,function(i,a){"hidden"!==e.find('input[name="'+i.name+'"]').attr("type")&&t.push({name:i.name,value:i.value})}),store.save("saveable."+this.element.attr("id"),t)},load:function(){let e=0,t=this,i=store.load("saveable."+this.element.attr("id"))||[];this.element.get(0).reset(),this.element.find(":checkbox").prop("checked",!1),_.forEach(i,function(i){let a=t.element.find("[name='"+i.name+"']");0===a.length&&e<3&&(t.element.find(".clone-button").trigger("click"),e++,a=t.element.find("[name='"+i.name+"']")),a.val([i.value])}),formStyle.updateForm(this.element)},saveParams:function(e){store.save("saveable."+this.element.attr("id"),e)}}),$.widget("il.uploadable",{options:{multiple:!1,maxFiles:1e3},maxFilesMessage:"Maximum number of files reached.",maxSizeMessage:"File {{filename}} exceeds the size limit of {{limit}} MB.",fileItem:'
\n
\n {{filename}}\n
\n
\n
\n
\n
',_getCreateOptions:function(){return{multiple:!0===this.element.find(":file").prop("multiple")}},_create:function(){void 0===IL.uploader&&(IL.uploader={}),this._on(this.element,{submit:this._submit}),this._on(this.element.find(".uploadable-url"),{keydown:this._urlSubmit}),this._on(this.element.find(".uploadable-clear"),{click:this._clearFiles}),this._on(this.element.find(":file"),{change:this._pdfTitle});let e=this,t=this.element.find(".uploadable-select"),i=this.element.find(".uploadable-clear"),a=this.element.find(".uploadable-list"),o=Math.min(window.MAX_UPLOAD,window.MAX_POST),n=0,s=0;IL.uploader[this.uuid]=new window.ss.SimpleUpload({button:t,url:e.element.attr("action"),name:e.element.find(":file").attr("name"),form:e.element,responseType:"json",overrideSubmit:!1,maxSize:o/1024,multiple:e.options.multiple,multipleSelect:e.options.multiple,autoSubmit:!1,onChange:function(t,o,s,r,l){if(!1===e.options.multiple&&this.clearQueue(),this.getQueueSize()>=e.options.maxFiles)return $.jGrowl(e.maxFilesMessage,{header:"Info",sticky:!1,theme:"bg-primary"}),!1;e._addFile(l),n+=r,a.children("div").eq(0).removeClass("d-none"),i.removeClass("d-none"),"application/pdf"===l.type&&e._pdfTitle(l)},onSubmit:function(t){this.setProgressContainer(e.element.find('div[data-file="'+_.escape(t)+'"]')),this.setProgressBar(e.element.find('div[data-file="'+_.escape(t)+'"] .progress-bar'))},onSizeError:function(t,i){let a=e.maxSizeMessage.replace(/{{filename}}/,_.escape(t)).replace(/{{limit}}/,o/1048576);$.jGrowl(a,{header:"Info",sticky:!1,theme:"bg-primary"}),n-=i,this.getQueueSize()>0&&this.submit()},onDone:function(t,i,a,o,r,l){let d=100*(s+=l)/n;e.element.find(".uploadable-progress .progress-bar").attr("aria-valuenow",d).css("width",d+"%"),this.getQueueSize()>0&&this.submit()},onAllDone:function(){this.destroy(),$.jGrowl("Upload has finished.",{header:"Info",theme:"bg-primary"}),B.history.loadUrl()},onError:function(e,t,i,a,o){let n={status:i,statusText:a,responseJSON:JSON.parse(o)};model._onFail(n),this.getQueueSize()>0&&this.submit()}})},_addFile:function(e){let t=this.fileItem.replace(/{{filename}}/g,_.escape(e.name)),i=this.element.find(".uploadable-list").find(".list-group-item").eq(1).children();!0===this.options.multiple?i.append(t):i.html(t),this.element.find(".uploadable-list").removeClass("d-none"),this._trigger("change",null,e)},_submit:function(e){e.preventDefault(),"object"==typeof IL.uploader[this.uuid]&&IL.uploader[this.uuid].getQueueSize()>0?IL.uploader[this.uuid].submit():$.when(model.save({url:this.element.attr("action"),data:this.element.serialize()})).done(function(){B.history.loadUrl()})},_urlSubmit:function(e){if(13===e.which)return this.element.trigger("submit"),!1},_clearFiles:function(){this.element.find(".uploadable-list").addClass("d-none"),this.element.find(".uploadable-list").find(".list-group-item").eq(1).children().empty(),this.element.find(".uploadable-clear").addClass("d-none"),IL.uploader[this.uuid].clearQueue(),this._trigger("clear")},_pdfTitle:function(e){if("function"!=typeof this.options.pdftitles)return!1;if(e.size>5242880)return this._trigger("pdftitles",null,{titles:[]}),!1;let t=this,i=new FileReader,a=function(){let e,o=i.result,n=new RegExp(//g),s=[],r=0;for(;e=n.exec(o);){let t=$(e[0]);s[r]=$.trim(t.text()),r++}let l=0===(s=s.filter(Boolean)).length?[]:s;t._trigger("pdftitles",null,{titles:l}),i.removeEventListener("load",a),i=null};i.addEventListener("load",a),i.readAsText(e)}}),$.jGrowl.defaults.pool=3,$.jGrowl.defaults.life=5e3,$.jGrowl.defaults.position="top-right",$.jGrowl.defaults.closeTemplate='',$.jGrowl.defaults.closerTemplate="";class Overlay{constructor(){this.delay=800,this.timeId=null,this.template=''}start(e){let t=this;return"number"==typeof this.timeId&&this.stop(),e="number"==typeof e?e:this.delay,this.timeId=setTimeout(function(){let e=$("#overlay");0===e.length&&($("body").append(t.template),e.fadeIn(250,function(){}))},e),!0}stop(){let e=$("#overlay");return clearTimeout(this.timeId),this.timeId=null,e.length>0&&e.fadeOut(150,function(){e.remove()}),!0}}let overlay=new Overlay;class LocalStore{save(e,t){if(null==t||"function"==typeof t)return!1;localStorage.setItem(e,this._serialize(t))}load(e){return this._unserialize(localStorage.getItem(e))}delete(e){localStorage.removeItem(e)}clear(){localStorage.clear()}_serialize(e){return JSON.stringify(e)}_unserialize(e){return JSON.parse(e)}}let store=new LocalStore;class SessionStore{save(e,t){if(null==t||"function"==typeof t)return!1;sessionStorage.setItem(e,this._serialize(t))}load(e){return this._unserialize(sessionStorage.getItem(e))}delete(e){sessionStorage.removeItem(e)}clear(){sessionStorage.clear()}_serialize(e){return JSON.stringify(e)}_unserialize(e){return JSON.parse(e)}}let sessionStore=new SessionStore;class FormStyle{init(){let e=this;$(":checkbox, :radio").each(function(){e.updateStyle($(this))}).off("change.formstyle").on("change.formstyle",function(){e.changeState($(this))}).off("focus.formstyle").on("focus.formstyle",function(){$(this).next().find(".label-text").css("text-decoration","underline dotted 1px")}).off("blur.formstyle").on("blur.formstyle",function(){$(this).next().find(".label-text").css("text-decoration","none")})}changeState(e){let t=this;$('input[name="'+e.attr("name")+'"]').each(function(){t.updateStyle($(this))})}updateStyle(e){let t=e.next().find(".mdi");"radio"===e.attr("type")?!0===e.prop("checked")?t.removeClass("mdi-radiobox-blank").removeClass("text-muted").addClass("mdi-radiobox-marked text-primary"):t.removeClass("mdi-radiobox-marked").removeClass("text-primary").addClass("mdi-radiobox-blank text-muted"):"checkbox"===e.attr("type")&&(!0===e.prop("checked")?t.removeClass("mdi-checkbox-blank-outline").removeClass("text-muted").addClass("mdi-checkbox-marked text-primary"):t.removeClass("mdi-checkbox-marked").removeClass("text-primary").addClass("mdi-checkbox-blank-outline text-muted"))}updateForm(e){let t=this;e.find(":checkbox, :radio").each(function(){t.updateStyle($(this))})}}let formStyle=new FormStyle;class Keyboard{init(){let e=$("#keyboard-window");!0!==e.hasClass("d-lg-block")?(e.addClass("d-lg-block"),0===e.length&&$.when(model.load({url:window.IL_BASE_URL+"index.php/keyboard"})).done(function(e){$("body").append(e.html);let t=$("#keyboard-window");t.position({my:"bottom",at:"bottom",of:"body"}),$(window).off("resize.keyboard").on("resize.keyboard",function(){t.position({my:"bottom",at:"bottom",of:"body"})}),t.draggable({handle:".card-header",containment:"body"}),t.find(".close").off("click.keyboard").on("click.keyboard",function(){t.removeClass("d-lg-block")}),t.find(".tab-content").on("mousedown",function(){return!1}),$("#keyboard").on("click",".btn",function(){let e=$(this).html();1===$("#notes-ta_ifr").length?tinymce.execCommand("mceInsertContent",!1,e):$(":focus").insertAtCaret(e).trigger("input")})})):e.removeClass("d-lg-block")}}let keyboard=new Keyboard;class ExportForm{init(){let e=decodeURIComponent($("#open-export").data("exportUrl")).indexOf("index.php/summary")>0?"summary":"items",t=$("#modal-export");""===$.trim(t.find(".modal-body").html())&&$.when(model.load({url:window.IL_BASE_URL+"index.php/"+e+"/exportform"})).done(function(e){t.find(".modal-body").append(e.html),formStyle.init(),$("#export-form").saveable(),t.find(".modal-footer button:first-child").off("click").on("click",function(){exportform.formSubmit()}),$("#export-styles").typeahead(),$("#export-styles").off("focus").on("focus",function(){t.find('[name="export"]').val(["citation"]),formStyle.updateForm($("#export-form"))})})}formSubmit(){let e=decodeURIComponent($("#open-export").data("exportUrl")),t=$("#export-form"),i=""===new URL(e).search?"?":"&";window.open(e+i+t.serialize()),t.saveable("save")}}let exportform=new ExportForm;class OmnitoolForm{init(){let e=$("#modal-omnitool");if(""===$.trim(e.find(".modal-body").html()))$.when(model.load({url:window.IL_BASE_URL+"index.php/items/omnitoolform"})).done(function(t){e.find(".modal-body").append(t.html),formStyle.init(),e.find(".modal-footer button:first-child").on("click",function(){omnitoolform.formSubmit()}),$("#tag-filter-omnitool").filterable({complete:function(){$("#omnitool-tags .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$("#omnitool-tags .tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})});else{let t=e.find("form");t[0].reset(),formStyle.updateForm(t)}}formSubmit(){let e=decodeURIComponent($("#open-omnitool").data("omnitoolUrl")),t=$("#modal-omnitool").find("form");$("#modal-omnitool").modal("hide"),$.when(model.save({url:e,data:t.serialize()})).done(function(){B.history.loadUrl()})}}let omnitoolform=new OmnitoolForm;class QuickSearch{init(){let e=this,t=$("#quick-search-form");t.off("submit").on("submit",function(t){t.preventDefault(),e.formSubmit()}),$("#modal-quick-search .modal-footer").find("button.search-submit").off("click").on("click",function(){e.formSubmit()}),t.saveable()}formSubmit(){let e=$("#modal-quick-search"),t=$("#quick-search-form"),i=""===new URL("http://foo.bar/"+t.attr("action").substr(1)).search?"?":"&";t.saveable("save"),router.navigate(t.attr("action")+i+t.serialize(),{trigger:!0}),e.modal("hide")}}let quicksearch=new QuickSearch;class AdvancedSearch{init(){let e=this,t=$("#advanced-search-form");t.off("submit").on("submit",function(t){t.preventDefault(),e.formSubmit()}),$("#modal-advanced-search .modal-footer").find("button.search-submit").off("click").on("click",function(){e.formSubmit()}),$("#advanced-search-form .clone-button").clonable({target:"#clone-target",onClone:function(e,t){$(t.clonedTarget).find("select.fields").trigger("change")}}),t.saveable(),t.on("change","select.fields",this.hideBooleans),this.hideBooleans(),$("#tag-filter-search").filterable({complete:function(){$("#search-tags .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$("#search-tags .tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}formSubmit(){let e=$("#modal-advanced-search"),t=$("#advanced-search-form"),i=""===new URL("http://foo.bar/"+t.attr("action").substr(1)).search?"?":"&";t.saveable("save"),router.navigate(t.attr("action")+i+t.serialize(),{trigger:!0}),e.modal("hide")}hideBooleans(e){let t,i=void 0===e?$("#advanced-search-form").find("select.fields"):$(this);$.each(i,function(e,i){switch($(i).val()){case"AU":case"T1":case"T2":case"T3":case"KW":case"YR":case"C1":case"C2":case"C3":case"C4":case"C5":case"C6":case"C7":case"C8":t=!0;break;default:t=!1}t?$(i).closest(".row").removeClass("text-search").addClass("string-search"):$(i).closest(".row").removeClass("string-search").addClass("text-search")})}}let advancedsearch=new AdvancedSearch;class SearchList{init(){$("#modal-searches").on("show.bs.modal",searchlist.load)}load(e){let t=$("#modal-searches");$.when(model.load({url:window.IL_BASE_URL+"index.php/search/list",async:!0})).done(function(e){t.find(".modal-body").html(e.html),t.find(".modal-body").on("click",".delete-search",searchlist.deleteSearch)})}deleteSearch(e){let t=$(this);$.when(model.save({url:t.data("url"),data:{id:t.data("id")}})).done(function(){searchlist.load()})}}let searchlist=new SearchList;class Sidebar{init(){let e=this,t=$("#side-menu"),i=$(".navbar-toggler");$(window).on("popstate",function(){let i=location.hash.split("?")[0],a=t.find('a[href^="'+i+'"]');if(0!==a.length){if(t.find("a").removeClass("clicked"),""===location.hash||"#"===location.hash)return!0;e.expandSidebar(a)}}),t.metisMenu();let a=location.hash.split("?")[0],o=t.find('a[href^="'+a+'"]');if(0===o.length){let e=_.dropRight(location.hash.split("/"));o=t.find('a[href="'+e+'"]')}this.expandSidebar(o),t.on("click","a",function(){location.hash===$(this).attr("href")&&B.history.loadUrl(),""!==$(this).attr("href")&&"#"!==$(this).attr("href")&&i.is(":visible")&&i.trigger("click")})}expandSidebar(e){e.parents("ul.collapse").not(".in").each(function(){$(this).addClass("in").prev().click()}),e.addClass("clicked")}}let sidebar=new Sidebar;class ILChart{constructor(){void 0!==window.Chart&&(window.Chart.defaults.global.defaultFontFamily="Noto Sans",window.Chart.defaults.global.defaultFontColor="#777777",window.Chart.plugins.register({beforeDatasetsDraw:function(e,t){let i=e.chart.ctx,a=e.chartArea;e.options.drawBorder&&(i.strokeStyle=e.options.borderColor,i.lineWidth=1,i.strokeRect(a.left+.5,a.top+.5,a.right-a.left-.5,a.bottom-a.top-.5))}}))}draw(e,t,i,a,o,n){let s=$("#"+e),r=null!=i,l=[];if(1===s.length){let d=s.get(0).getContext("2d");l.push(chart._dataset1(a,i)),null!=n&&l.push(chart._dataset2(n,o)),void 0!==window.charts[e]&&window.charts[e].destroy(),window.charts[e]=new window.Chart(d,{type:"line",data:{labels:t,datasets:l},options:chart._options(t,r,n)})}}_dataset1(e,t){return{label:t,data:e,yAxisID:"y-axis-1",fill:!1,borderWidth:2,backgroundColor:"#2f8ded",borderColor:"#2f8ded",lineTension:.2,pointBorderColor:"#2f8ded",pointBackgroundColor:"#2f8ded",pointHoverBackgroundColor:"#2f8ded",pointHoverBorderColor:"#2f8ded",pointHitRadius:8,pointRadius:2}}_dataset2(e,t){return{label:t,data:e,yAxisID:"y-axis-2",fill:!1,borderWidth:2,backgroundColor:"#ed9b25",borderColor:"#ed9b25",lineTension:.2,pointBorderColor:"#ed9b25",pointBackgroundColor:"#ed9b25",pointHoverBackgroundColor:"#ed9b25",pointHoverBorderColor:"#ed9b25",pointHitRadius:8,pointRadius:2}}_options(e,t,i){let a=[],o={type:"linear",display:!0,position:"right",id:"y-axis-2",gridLines:{drawOnChartArea:!1,color:"#999",tickMarkLength:0},ticks:{maxTicksLimit:5,beginAtZero:!0,precision:0,padding:8}};return a.push({type:"linear",display:!0,position:"left",id:"y-axis-1",gridLines:{color:"#999",tickMarkLength:0},ticks:{maxTicksLimit:5,beginAtZero:!0,precision:0,padding:8}}),null!=i&&a.push(o),{responsive:!0,maintainAspectRatio:!1,stacked:!1,legend:{display:t},drawBorder:!0,borderColor:"#999",scales:{xAxes:[{type:"time",time:{displayFormats:{hour:"M/D",day:"M/D",week:"M/D",month:"YYYY/M",quarter:"YYYY/M",year:"YYYY"},unit:e.length>13?"day":"month"},gridLines:{color:"#999",tickMarkLength:0},ticks:{padding:8}}],yAxes:a}}}}let chart=new ILChart;class ImageFilter{constructor(){this.touchDevice=window.matchMedia("(max-width: 1199px)").matches,this.default={contrast:"1",brightness:"1",saturation:"1",hue:"0deg",invert:"0",sharpen:!1,sharpness:"0"}}compileCss(e){let t=$(".pdfviewer-right > div:first").hasClass("img-night-mode"),i=$("#adjust-contrast").val()||this.default.contrast,a=$("#adjust-brightness").val()||this.default.brightness,o=$("#adjust-saturation").val()||this.default.saturation,n=$("#adjust-sharpness").val()||this.default.sharpness,s=`contrast(${i}) brightness(${a}) saturate(${o}) hue-rotate(${t?"180deg":"0deg"}) invert(${t?"1":"0"})`;return!0===e&&"0"!==n&&(s+=" url(#sharpen)"),s}adjustFilter(e){this.touchDevice||$(".pdfviewer-right img").slice(Math.max(e-3,0),e+3).css("filter",this.compileCss(!0))}adjustSharpness(e){if(this.touchDevice)return;let t=$("#sharpen feConvolveMatrix"),i=t.attr("kernelMatrix").split(" ");i[4]=-12*parseFloat($("#adjust-sharpness").val())+16,t.attr("kernelMatrix",i.join(" ")),this.adjustFilter(e)}disableSharpening(e){this.touchDevice||$(".pdfviewer-right img").slice(Math.max(e-3,0),e+3).css("filter",this.compileCss(!1))}reset(e){this.touchDevice||($("#adjust-contrast").val(this.default.contrast),$("#adjust-brightness").val(this.default.brightness),$("#adjust-saturation").val(this.default.saturation),$("#adjust-sharpness").val(this.default.sharpness),this.adjustSharpness(e))}lightMode(){$(".pdfviewer-left img").css("filter","hue-rotate(0deg) invert(0)"),$(".pdfviewer-right img").css("filter",this.compileCss(!0))}nightMode(){$(".pdfviewer-left img").css("filter","hue-rotate(180deg) invert(1)"),$(".pdfviewer-right img").css("filter",this.compileCss(!0))}}let imageFilter=new ImageFilter,arxiv={url:"https://export.arxiv.org/api/query?start=0&max_results=1&id_list=",metadata:function(e){let t={author_last_name:[],author_first_name:[],keywords:[],uid_types:[],uids:[],secondary_title:"eprint"},i=e.find("entry");t.reference_type="article",t.title=i.children("title").text().replace(/\r?\n|\r/g," ")||"",t.abstract=i.children("summary").text().replace(/\r?\n|\r/g," ")||"";let a=new Date(i.children("published").text().replace(/\r?\n|\r/g," "));t.publication_date=a.toISOString().substr(0,10);let o=i.children("arxiv\\:doi").text().replace(/\r?\n|\r/g," ")||"";if(""!==o&&(t.uid_types.push("DOI"),t.uids.push(o)),1===i.find("id").length){t.uid_types.push("ARXIV");let e=i.find("id").text().replace(/https?:\/\/arxiv\.org\/abs\//,"");t.uids.push(e),$(".uploadable-url").val("https://arxiv.org/pdf/"+e)}return _.forEach(i.find("name"),function(e,i){let a=$(e).text().split(" ");t.author_last_name[i]=a.pop(),t.author_first_name[i]=a.join(" ")}),_.forEach(i.children("category"),function(e,i){t.keywords[i]=$(e).attr("term")}),JSON.stringify(t)}},views={};B.emulateJSON=!0;let Router=B.Router.extend({routes:{":controller(/:action)(?:query)":"dispatch"},dispatch:function(e,t,i){let a="string"==typeof e?e:"main",o="string"==typeof t?t:"main",n="string"==typeof i?"?"+i:"";$.when(model.load({url:window.IL_BASE_URL+"index.php/"+a+"/"+o+n})).done(function(e){"object"==typeof views[a+o]?views[a+o].render(e):console.error('The view "'+(a+o)+'" does not exist.')})}}),router=new Router;class Model{constructor(){this.xhr="",this.options={url:null,data:void 0,async:!1,cors:!1,dataType:"json"}}load(e){return e=_.assign({},this.options,e),this._request("GET",e.url,e.data,e.async,e.cors,e.dataType)}save(e){return e=_.assign({},this.options,e),this._request("POST",e.url,e.data,e.async,e.cors,e.dataType)}_request(e,t,i,a,o,n){let s=this,r=$.Deferred(),l=!0!==a,d=n||"json";!0===l&&"object"==typeof this.xhr&&this.abort();let c={"X-Client-Width":screen.width};!0===o&&(c={});let h=$.ajax({url:t,data:i,type:e,dataType:d,headers:c}).done(function(e){s._onSuccess(e),r.resolve(e)}).fail(function(e){s._onFail(e,o),r.reject(e)});return!0===l&&(overlay.start(),model.xhr=h),r}abort(){"object"==typeof this.xhr&&(this.xhr.abort(),this.xhr="",overlay.stop())}_onSuccess(e){this.xhr="",overlay.stop(),"string"==typeof e.info&&$.jGrowl(e.info,{header:"Info",sticky:!1,theme:"bg-primary"})}_onFail(e,t){if(this.xhr="",overlay.stop(),!1===t||void 0===t)if("abort"===e.statusText);else if(401===e.status){let e=window.IL_BASE_URL+"?ref="+window.btoa(location.href);location.replace(e)}else if(404===e.status)location.replace(window.IL_BASE_URL+"index.php/notfound/main");else if(e.status>400&&e.status<500){let t=void 0!==e.responseJSON?e.responseJSON.error:"Unspecified error.";$.jGrowl(t,{header:"Info",sticky:!1,theme:"bg-primary"})}else{let t=void 0!==e.responseJSON?e.responseJSON.error:"Unspecified error.";$.jGrowl(t,{header:e.status+" "+e.statusText,sticky:!0,theme:"bg-danger"})}}}let model=new Model;class View{constuctor(){this.events={},this.parent=""}render(e){let t=$(this.parent);return 1!==t.length?(console.error('The view container "'+this.parent+'" not found!'),!1):("string"==typeof e.title&&(document.title=e.title),"string"==typeof e.html&&(t.html(e.html),this.delegateEvents(),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset(),this.afterRender(e)),$(".modal").modal("hide"),$(".modal-backdrop").remove(),$('[data-toggle="tooltip"], .tooltip').tooltip("hide"),this)}htmlRender(){for(let e in this.events){let t=this.events[e];_.isFunction(t)||(t=this[t]);let i=e.match(/^(\S+)\s*(.*)$/);$("body").on(i[1]+".view",i[2],{object:this},t)}formStyle.init(),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset(),this.afterRender()}afterRender(e){}delegateEvents(){if(void 0===this.events)return this;this.undelegateEvents();for(let e in this.events){let t=this.events[e];_.isFunction(t)||(t=this[t]);let i=e.match(/^(\S+)\s*(.*)$/);$(this.parent).on(i[1]+".view",i[2],{object:this},t)}return this}undelegateEvents(){return 1===$(this.parent).length&&$(this.parent).off(".view"),this}}class DashboardMainView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){formStyle.init(),quicksearch.init(),advancedsearch.init();let t=void 0===e.pages_read||0===e.pages_read.length?null:Object.values(Object.values(e.pages_read)[0]),i=null===t?null:Object.keys(e.pages_read);chart.draw("myChart",Object.keys(Object.values(e.activity)[0]),Object.keys(e.activity),Object.values(Object.values(e.activity)[0]),i,t),sessionStore.delete("il.idList")}}views.dashboardmain=new DashboardMainView;class SettingsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #user-settings-form":"saveForm"}}afterRender(e){formStyle.init(),$("#timezones").typeahead(),$("#modal-settings").find(".modal-body").html("")}saveForm(e){e.preventDefault();let t=$(this);t.find(":checkbox").each(function(){!1===$(this).prop("checked")&&t.append(``)}),$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){location.reload()})}}views.settingsmain=new SettingsMainView;class ProfileMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #user-profile-form":"saveProfile","submit #user-profile-change-password":"savePassword"}}afterRender(e){$('[data-toggle="tooltip"]').tooltip({container:"#content-col"})}saveProfile(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){let e=""===$("#first_name").val()?$("#username").val():$("#first_name").val();$("#menu-first-name").text(e)})}savePassword(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){t[0].reset()})}}views.profilemain=new ProfileMainView;class ItemsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":"filterLocal","click .open-filter-remote":"filterRemote","click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){formStyle.init();let t=this;this.itemsHeight(),$(window).off("resize.ItemsMainView").on("resize.ItemsMainView",function(){t.itemsHeight()}),quicksearch.init(),advancedsearch.init(),sessionStore.save("il.idList",e.id_list),this.highlightSearch()}itemsHeight(){let e=$("#bottom-row").outerHeight();$(".navbar-toggler").is(":visible")?$("#top-row").height($(window).height()-e-$(".navbar-toggler").outerHeight(!0)-(1===$("#filter-list").length?$("#filter-list").outerHeight(!0):0)):$("#top-row").height($(window).height()-e)}filterLocal(){let e=$(this).data("src"),t=$(this).data("title");$.when(model.load({url:e})).done(function(e){$("#modal-filters .modal-title").html(t),$("#modal-filters .modal-body .container-fluid").replaceWith(e.html),$("#modal-filters").modal(),$("#modal-filters .modal-body").on("click","a",function(){$("#modal-filters").modal("hide")}),$("#modal-filters .filterable").filterable("destroy"),$("#modal-filters :text").filterable({targets:"#modal-filters a"}).val("").focus()})}filterRemote(){let e=$(this).data("src"),t=$(this).data("title");$.when(model.load({url:e})).done(function(i){$("#modal-filters .modal-title").html(t),$("#modal-filters .modal-body .container-fluid").replaceWith(i.html),$("#modal-filters").modal(),$("#modal-filters .modal-body").on("click","a",function(){$("#modal-filters").modal("hide")}),$("#modal-filters .filterable").filterable("destroy"),$("#modal-filters :text").filterable({source:e,container:"#modal-filters .container-fluid"}).val("").focus()})}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}highlightSearch(){if(location.hash.indexOf("search_query")>-1&&$(".item-container").length>0){let t=new URL("http://foo.bar/"+location.hash.substr(1));document.designMode="on";var e=window.getSelection();for(let i of t.searchParams)if(0===i[0].indexOf("search_query")){let t=i[1].split(" ");for(let i of t)if(e.collapse(document.getElementsByClassName("item-container")[0],0),(i=i.replace("*","")).length>1)for(;window.find(i,!1);)document.execCommand("hiliteColor",!1,"#ffff9bbf"),document.execCommand("foreColor",!1,"#222426")}e.collapseToEnd(),document.designMode="off",e.removeAllRanges(),$("#top-row").scrollTop(0)}}}views.itemsmain=new ItemsMainView,views.itemsfilter=new ItemsMainView;class ItemsCatalogView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":views.itemsmain.filterLocal,"click .open-filter-remote":views.itemsmain.filterRemote,"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){views.itemsmain.afterRender(e)}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}}views.itemscatalog=new ItemsCatalogView;class ClipboardMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":views.itemsmain.filterLocal,"click .open-filter-remote":views.itemsmain.filterRemote,"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){views.itemsmain.afterRender(e)}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).done(function(){B.history.loadUrl()}).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}}views.clipboardmain=new ClipboardMainView,views.clipboardfilter=new ClipboardMainView;class ProjectsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #project-form":"submitForm","click .join":"joinProject","click .leave":"leaveProject","click .activate":"activateProject","click .inactivate":"inactivateProject"}}afterRender(e){formStyle.init(),$('[data-toggle="tooltip"]').tooltip(),$(".delete").confirmable({submit:function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/delete",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}}),$("#filter-active").filterable({targets:".active-project",complete:function(){$(".active-project-container").removeClass("d-none"),$(".active-project.d-none").closest(".active-project-container").addClass("d-none")}}),$("#filter-open").filterable({targets:".open-project",complete:function(){$(".open-project-container").removeClass("d-none"),$(".open-project.d-none").closest(".open-project-container").addClass("d-none")}}),$("#filter-inactive").filterable({targets:".inactive-project",complete:function(){$(".inactive-project-container").removeClass("d-none"),$(".inactive-project.d-none").closest(".inactive-project-container").addClass("d-none")}})}submitForm(e){let t=e.data.object;e.preventDefault(),$.when(model.save({url:$(this).attr("action"),data:$(this).serialize()})).done(function(e){$("#content-col").html(e.html),t.afterRender()})}joinProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/join",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}leaveProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/leave",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}activateProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/activate",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}inactivateProject(){$.when(model.save({url:window.IL_BASE_URL+"index.php/project/inactivate",data:{project_id:$(this).data("projectId")}})).done(function(){B.history.loadUrl()})}}views.projectsmain=new ProjectsMainView;class ProjectBrowseView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-filter-local":views.itemsmain.filterLocal,"click .open-filter-remote":views.itemsmain.filterRemote,"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"click #open-omnitool":omnitoolform.init}}afterRender(e){formStyle.init(),views.itemsmain.afterRender(e)}clipboard(){let e=$(this),t=e.closest(".item-container").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)})}project(){let e=$(this),t=e.closest(".item-container").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e)),B.history.loadUrl()})}}views.projectbrowse=new ProjectBrowseView,views.projectfilter=new ProjectBrowseView;class ProjectEditView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #project-form":"submitForm"}}afterRender(e){formStyle.init(),$("#content-col").find('[data-toggle="tooltip"]').tooltip()}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.projectedit=new ProjectEditView;class ProjectDiscussionView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #message-form":"bindForm"}}afterRender(e){}bindForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.projectdiscussion=new ProjectDiscussionView;class ProjectNotesView extends View{constructor(){super(),this.parent="#content-col",this.events={}}afterRender(e){}}views.projectnotes=new ProjectNotesView,views.projectcompilenotes=new ProjectNotesView;class TagsManageView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .edit-tag-form":"editTag","submit #tag-form":"createTag"}}editTag(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}createTag(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.tagsmanage=new TagsManageView;class NormalizeMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"change #select-metadata":"changeSource","submit .edit-form":"submitForm"}}afterRender(e){let t=$("#search-metadata");t.filterable({source:t.attr("data-source"),container:t.attr("data-container")})}changeSource(e){e.data.object;let t=$("#search-metadata"),i=window.IL_BASE_URL+"index.php/normalize/search"+$(this).val();t.filterable("destroy"),$("#results").empty(),t.attr("data-source",i).val(""),t.filterable({source:t.attr("data-source"),container:t.attr("data-container")})}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()}))}}views.normalizemain=new NormalizeMainView;class NormalizeResultsView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .edit-form":"submitForm"}}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}}views.normalizeauthors=new NormalizeResultsView,views.normalizeeditors=new NormalizeResultsView,views.normalizeprimary=new NormalizeResultsView,views.normalizesecondary=new NormalizeResultsView,views.normalizetertiary=new NormalizeResultsView;class DuplicatesMainView extends View{constructor(){super(),this.parent="#content-col"}}views.duplicatesmain=new DuplicatesMainView;class DuplicatesFindView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .merge-form":"merge"}}merge(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){t.closest(".card").remove()})}}views.duplicatesfind=new DuplicatesFindView;class ReindexMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click #reindex":"reindex","click #defragment":"defragment","click #check-fts":"integrityFts","click #check-db":"integrityDb","click #reextract":"reextract"}}integrityFts(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/checkfts"}))}integrityDb(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/checkdb"}))}defragment(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/defragment"})).done(function(){B.history.loadUrl()})}reindex(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/reindex"})).done(function(){B.history.loadUrl()})}reextract(){$.when(model.load({url:window.IL_BASE_URL+"index.php/reindex/reextract"})).done(function(){B.history.loadUrl()})}}views.reindexmain=new ReindexMainView;class SummaryMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .clipboard":"clipboard","click .project":"project","click #open-export":exportform.init,"submit .form-uid":"submitForm","click .open-notes":"openNotes","click .rescan-pdf":"rescanPdf"}}afterRender(e){formStyle.init(),$(".truncate").expandable();let t=this;this.itemHeight(),$(window).off("resize.SummaryMainView").on("resize.SummaryMainView",function(){t.itemHeight()}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink()),$("#delete-item").confirmable({submit:function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/item/delete",data:{id:$("body").data("id")}})).done(function(){location.assign(window.IL_BASE_URL+"index.php#dashboard/main")})}});let i=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",i).data("id",i),$("a.add-id-link").each(function(){let e=$(this).attr("href").split("id=");$(this).attr("href",e[0]+"id="+i)});let a=sessionStore.load("il.idList");if(a){let e=a[a.indexOf(a.find(e=>e.id===i))-1],t=a[a.indexOf(a.find(e=>e.id===i))+1];void 0===e?$("#summary-previous").addClass("disabled").attr("tabindex","-1").attr("aria-disabled","true"):$("#summary-previous").attr("href","#summary?id="+e.id),void 0===t?$("#summary-next").addClass("disabled").attr("tabindex","-1").attr("aria-disabled","true"):$("#summary-next").attr("href","#summary?id="+t.id)}else $("#summary-next, #summary-previous").remove();$("#autoupload-doi-form").saveable()}itemHeight(){let e=$("#bottom-row").outerHeight();$(".navbar-toggler").is(":visible")?$("#top-row").height($(window).height()-e-$(".navbar-toggler").outerHeight(!0)):$("#top-row").height($(window).height()-e)}clipboard(){let e=$(this),t=$("body").data("id"),i=!0===e.prop("checked")?"add":"delete";$.when(model.save({url:window.IL_BASE_URL+"index.php/clipboard/"+i,data:{id:t}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}project(){let e=$(this),t=$("body").data("id"),i=e.val(),a=!0===e.prop("checked")?"additem":"deleteitem";$.when(model.save({url:window.IL_BASE_URL+"index.php/project/"+a,data:{id:t,project_id:i}})).fail(function(){e.prop("checked",!e.prop("checked")),formStyle.changeState(e)}).done(function(t){!0===t.max_count&&(e.prop("checked",!e.prop("checked")),formStyle.changeState(e))})}submitForm(e){let t=$(this);e.preventDefault(),$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()}),$("#autoupload-doi-form").trigger("save")}openNotes(){null!==window.tinymce.activeEditor&&!0===window.tinymce.activeEditor.initialized?$("#notes-window").removeClass("d-none"):views.summarymain.loadNotes()}loadNotes(){let e=this,t=$("body").attr("data-id");$.when(model.load({url:window.IL_BASE_URL+"index.php/notes/user",data:{id:t}})).done(function(i){$("#notes-ta").val(i.user.note),$("#id-hidden").val(t),e.initNotes()})}initNotes(){null===window.tinymce.activeEditor||!0!==window.tinymce.activeEditor.initialized?window.tinymce.init({theme:"silver",selector:"#notes-ta",content_css:window.IL_BASE_URL+"css/style.css",resize:"both",min_height:300,menubar:!1,plugins:"importcss save lists advlist link image code fullscreen table searchreplace",toolbar1:"save undo redo fullscreen code | formatselect link unlink image table searchreplace",toolbar2:"bold italic underline strikethrough subscript superscript removeformat | forecolor backcolor | outdent indent bullist numlist",save_onsavecallback:function(e){let t=$("#note-form");$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){$("#user-note").html(e.getContent()),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset()})},image_description:!1,relative_urls:!1,remove_script_host:!1,image_dimensions:!1,image_class_list:[{title:"Auto width",value:"mce-img-fluid"}],image_list:window.IL_BASE_URL+"index.php/supplements/imagelist?as=json&id="+$("body").data("id")}).then(function(){let e=$("#notes-window");e.removeClass("d-none"),e.position({my:"left bottom",at:"left bottom",of:"#content-col"}),$(window).off("resize.notes").on("resize.notes",function(){e.position({my:"left bottom",at:"left bottom",of:"#content-col"})}),e.draggable({handle:".card-header",containment:"body"}),e.find(".close").off("click.notes").on("click.notes",function(){$("#notes-window").addClass("d-none")})}):window.tinymce.activeEditor.load()}rescanPdf(){let e=$(this).data("url");$.when(model.load({url:e})).done(function(){B.history.loadUrl()})}}views.summarymain=new SummaryMainView;class NotesMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .open-notes":views.summarymain.openNotes}}afterRender(){let e=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",e).data("id",e),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}}views.notesmain=new NotesMainView;class EditMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #edit-form":"bindForm","change #reference-type":"bindReferenceType"}}afterRender(e){this.uploadFormWidgets(),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}bindForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()})}bindReferenceType(){$("#edit-form").trigger("submit")}uploadFormWidgets(){let e=this;$("input.input-typeahead").each(function(){let t=$(this);t.typeahead({source:t.data("source"),onSelect:function(){e._selectAuthor(this)}})}),$("#clone-authors").clonable({target:"#new-author-container",onClone:function(t,i){let a=$(i.clonedTarget).find(".input-typeahead");a.typeahead({source:a.data("source"),onSelect:function(){e._selectAuthor(this)}})}}),$("#clone-editors").clonable({target:"#new-editor-container",onClone:function(t,i){let a=$(i.clonedTarget).find(".input-typeahead");a.typeahead({source:a.data("source"),onSelect:function(){e._selectAuthor(this)}})}}),$("#clone-uid").clonable({target:"#uid-row"})}_selectAuthor(e){if($(e).is("[name^='author_last_name']")){let t=$(e).closest(".form-row").find('input[name^="author_first_name"]'),i=$(e).val().split(",");$(e).val($.trim(i[0]||"")),t.val($.trim(i[1]||""))}if($(e).is("[name^='editor_last_name']")){let t=$(e).closest(".form-row").find('input[name^="editor_first_name"]'),i=$(e).val().split(",");$(e).val($.trim(i[0]||"")),t.val($.trim(i[1]||""))}}}views.editmain=new EditMainView;class ItemdiscussionMainView extends View{constructor(){super(),this.parent="#content-col",this.messagesId="",this.events={"submit #message-form":"bindForm"}}afterRender(e){this.messagesId=setInterval(this.refreshMessages,1e4),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}bindForm(e){e.preventDefault();let t=e.data.object,i=$(this);$.when(model.save({url:i.attr("action"),data:i.serialize()})).done(function(){t.refreshMessages(),i.get(0).reset()})}refreshMessages(){if(0===$("#message-list").length)return void clearInterval(this.messagesId);let e=$("body").data("id");$.when(model.load({url:window.IL_BASE_URL+"index.php/itemdiscussion/messages?id="+e})).done(function(e){$("#message-list").html(e.html),$("#message").val("")})}}views.itemdiscussionmain=new ItemdiscussionMainView;class TagsItemView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #tag-form":"createTags","change .tag-inputs":"changeTags"}}afterRender(e){formStyle.init(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}createTags(e){e.preventDefault();let t=e.data.object,i=$(this);""!==$("#new_tags").val()&&$.when(model.save({url:i.attr("action"),data:i.serialize()})).done(function(e){$("#content-col").html(e.html),t.afterRender()})}changeTags(){let e=$(this),t=$("body").data("id");e.is(":checked")?$.when(model.save({url:window.IL_BASE_URL+"index.php/tags/additem",data:{id:t,tag_id:e.val()}})).fail(function(){e.prop("checked",!1),formStyle.updateStyle(e)}):$.when(model.save({url:window.IL_BASE_URL+"index.php/tags/deleteitem",data:{id:t,tag_id:e.val()}})).fail(function(){e.prop("checked",!0),formStyle.updateStyle(e)})}}views.tagsitem=new TagsItemView;class SupplementsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .rename-file":"renameFile","keydown input.form-control":"submitInput"}}afterRender(e){formStyle.init(),$("#upload-form").uploadable({maxFiles:64}),$(".delete-file").confirmable({submit:function(){let e=$(this).closest("li").find(".filename-link").text().trim(),t=$("body").data("id");$.when(model.save({url:window.IL_BASE_URL+"index.php/supplements/delete",data:{id:t,filename:e}})).done(function(){B.history.loadUrl()})}}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}renameFile(){let e=$(this).closest("li").find(".filename-link"),t=$(this).closest("li").find("input");if(e.hasClass("d-none")){let i=$.trim(e.text()),a=$.trim(t.val());$.when(model.save({url:window.IL_BASE_URL+"index.php/supplements/rename",data:{id:$("body").data("id"),filename:i,newname:a}})).done(function(){B.history.loadUrl()})}else e.addClass("d-none"),t.removeClass("d-none").addClass("d-inline-block").val($.trim(e.text())).focus()}submitInput(e){13===e.which&&$(this).closest(".list-group-item").find(".rename-file").trigger("click")}}views.supplementsmain=new SupplementsMainView;class PdfMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"change #pdfviewer-zoom":"selectZoom","input #pdfviewer-page-input":"inputPageNum","click #pdfviewer-first":"buttonPageNum","click #pdfviewer-prev":"buttonPageNum","click #pdfviewer-next":"buttonPageNum","click #pdfviewer-last":"buttonPageNum","click .pdfviewer-thumb":"thumbPageNum","click #pdfviewer-image":"toggleCropper","click #copy-image-btn":"getCroppedImage","click #save-image-btn":"saveCroppedImage","click #pdfviewer-left-btn":"toggleLeft","click #pdfviewer-previews-btn":"showThumbs","click #pdfviewer-bookmarks-btn":"showBookmarks","click #pdfviewer-results-btn":"showResults","click #pdfviewer-bookmarks a":"clickBookmark","click #pdfviewer-night-btn":"nightMode","click #pdfviewer-text-btn":"toggleTextLayer","click .highlight-color":"addHighlights","click .highlight-eraser":"eraserInit","click #pdfviewer-annot-menu .annot-show":"showAnnotations","click #pdfviewer-annot-menu .annot-hide":"hideAnnotations","click .highlight-cancel":"clearHighlights","dblclick .pdfviewer-page":"dblZoom","keyup #pdfviewer-search-input":"search","click #pdfviewer-results > .pdfviewer-results-container > a":"scrollToResult","click #pdfviewer-result-up":"prevResult","click #pdfviewer-result-down":"nextResult","click #pdfviewer-notes-btn":"showNotes","click .note-edit-btn":"editNote","submit .note-form":"saveNote","submit #new-note-form":"saveNote","click #pdfviewer-new-note-btn":"createNewNote","click .pdflink":"openLink","change #pdfviewer-underlined":"highlightStyle"}}afterRender(e){this.selectable=void 0,this.page=void 0,this.sseSearch=void 0;let t=this;if(this.throttledZoom=_.throttle(function(e){t.pageZoom(e)},500,{leading:!0,trailing:!0}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink()),0===$("#pdfviewer-pages").length)return;"underlined"===store.load("il.highlightStyle")&&$("#pdfviewer-underlined").prop("checked",!0),formStyle.init(),$("#content-col").find('[data-toggle="tooltip"]').tooltip();let i=new URL(location.href).searchParams.get("id")||"";""!==i&&$("body").attr("data-id",i).data("id",i),$(window).off("resize.PdfMainView").on("resize.PdfMainView",function(){t.pagesHeight(),t.pageZoom(store.load("il.pageZoom")||"auto"),$(".pdfviewer-right").trigger("scroll")}),this.pagesHeight(),new LazyLoad({container:$("#pdfviewer-pages .pdfviewer-left").get(0),elements_selector:".lazy",load_delay:250,threshold:400}),this.lazyLoad=new LazyLoad({container:document.querySelector(".pdfviewer-right"),elements_selector:".lazy",load_delay:250,threshold:1e3}),!0===store.load("il.nightMode")&&$("#pdfviewer-night-btn").click(),!0===store.load("il.leftPanel")&&(this.showLeft(),this.showThumbs()),this.pageZoom(store.load("il.pageZoom")||"auto"),$("#adjust-sharpness").val(imageFilter.default.sharpness),$(".pdfviewer-right").off("scroll").on("scroll",_.throttle(function(){t.redrawNoteLine(),t.redrawSnippetLine(),imageFilter.disableSharpening(t.page),clearTimeout($.data(window,"scrollTimer")),$.data(window,"scrollTimer",setTimeout(function(){$(".pdfviewer-right > div").each(function(){return!t.detectVisiblePage(this,this.getBoundingClientRect(),$(".pdfviewer-right")[0].getBoundingClientRect())}),"object"==typeof t.selectable&&t.selectable.refresh(),imageFilter.adjustSharpness(t.page)},200))},20)),$(".pdfviewer-left").off("scroll").on("scroll",_.throttle(function(){t.redrawNoteLine(),t.redrawSnippetLine()},20)),"object"==typeof t.selectable&&(t.selectable.disable(),t.selectable.destroy()),"object"==typeof t.cropper&&t.destroyCropper();let a={},o=$.Event("keyup");null!==(a=location.hash.length>1?new URL("http://foo.bar/"+location.hash.substring(1)).searchParams:new URL(location.href).searchParams).get("search")&&(o.which=13,$("#pdfviewer-search-input").val(a.get("search")).trigger(o));let n=a.get("page")||$("#pdfviewer-page-input").val();this.setPageNumber(n),this.scrollToPage(n,0),this.getLinks()}selectZoom(e){e.data.object.throttledZoom($(this).val())}dblZoom(e){let t=store.load("il.pageZoom");if("auto"===t){let e=100*($(".pdfviewer-right").width()-30)/(.5*$(".pdfviewer-page > img").eq(0).attr("width"));[50,75,100,125,150,200,250,300].forEach(function(i){i<=e&&(t=i.toString())})}else t="auto";e.data.object.pageZoom(t)}pageZoom(e){"screen"===e&&(e="auto");let t,i=this.page;if($("#pdfviewer-zoom").val(e),store.save("il.pageZoom",e),"auto"===e){let t=$(".pdfviewer-right").width()-30,i=$(".pdfviewer-page > img").eq(0).attr("width"),a=Math.max(100*t/i,50);[50,75,100,125,150,200,250,300].forEach(function(t){t<=a&&(e=t.toString())})}switch(e){case"50":case"100":case"200":t="200";break;case"125":case"250":t="250";break;case"75":case"150":case"300":t="300";break;default:t="200"}$(".pdfviewer-page > img").each(function(){this.style.width=Math.ceil(.01*e*this.getAttribute("width"))+"px",this.style.height=Math.ceil(.01*e*this.getAttribute("height"))+"px",null!==this.getAttribute("data-src")&&(this.removeAttribute("data-was-processed"),this.classList.remove("loaded"),this.setAttribute("data-src",this.getAttribute("data-src").replace(/zoom=\d+/,"zoom="+t)))}),this.lazyLoad.update(),this.scrollToPage(i,0)}pagesHeight(){let e=$("#pdfviewer-menu").outerHeight();$(".navbar-toggler").is(":visible")?$("#pdfviewer-pages, .pdfviewer-left, .pdfviewer-right").height($(window).height()-e-$(".navbar-toggler").outerHeight(!0)):$("#pdfviewer-pages, .pdfviewer-left, .pdfviewer-right").height($(window).height()-e)}detectVisiblePage(e,t,i){return t.top-i.top>0&&t.top-i.top0&&i.bottom-t.bottom0&&t.bottom-i.bottom>0&&(this.setPageNumber($(e).data("page")),!0)}setPageNumber(e){let t=this;t.page!==parseInt(e)&&(t.page=parseInt(e),void 0!==this.pageTimer&&clearTimeout(this.pageTimer),this.pageTimer=_.delay(function(){$("#pdfviewer-page-input").val(e),$(".pdfviewer-thumb").children("div").removeClass("bg-primary").addClass("bg-secondary"),$(".pdfviewer-thumb").eq(e-1).children("div").removeClass("bg-secondary").addClass("bg-primary"),$("#pdfviewer-pages .pdfviewer-left").animate({scrollTop:$(".pdfviewer-thumb").eq(e-1).position().top+$("#pdfviewer-pages .pdfviewer-left").scrollTop()-$(".pdfviewer-thumb").eq(e-1).height()/2},100),$("#pdfviewer-pages").find(".pdfviewer-text").length>0&&t.getBoxes(e),$("#pdfviewer-pages").find(".pdfviewer-highlights").length>0&&t.getHighlights(),model.load({url:window.IL_BASE_URL+"index.php/pdf/logpage",data:{id:$("body").data("id"),page:e},async:!0})},400))}buttonPageNum(e){let t,i,a=600;switch($(this).data("value")){case"first":i=1;break;case"prev":for(t=i=parseInt($("#pdfviewer-page-input").val());t>i-10;t--){let e=$(".pdfviewer-page").eq(t-1)[0].getBoundingClientRect(),a=$(".pdfviewer-page").eq(t-2)[0].getBoundingClientRect();if(e.top>a.top){i=t-1;break}}a=200;break;case"next":for(t=i=parseInt($("#pdfviewer-page-input").val());te.top){i=t+1;break}}a=200;break;case"last":i=$(".pdfviewer-page").last().data("page")}e.data.object.scrollToPage(i,a)}inputPageNum(e){let t=e.data.object,i=$(this).val();void 0!==t.t&&clearTimeout(t.t),t.t=_.delay(function(){t.scrollToPage(i)},300)}thumbPageNum(e){e.data.object.scrollToPage($(this).data("page"))}scrollToPage(e,t){let i=void 0===t?400:t;1===$('.pdfviewer-page[data-page="'+e+'"]').length&&$(".pdfviewer-right").animate({scrollTop:$('.pdfviewer-page[data-page="'+e+'"]').position().top+$(".pdfviewer-right").scrollTop()-12},i)}scrollToElement(e,t){let i=void 0===t?400:t,a=$(".pdfviewer-right"),o=e.offset().top;(o<100||o>$(window).height()-100)&&a.animate({scrollTop:o+a.scrollTop()-$(window).height()/2},{duration:i,queue:!1});let n=e[0].getBoundingClientRect(),s=a[0].getBoundingClientRect();(n.lefts.right)&&a.animate({scrollLeft:a.scrollLeft()+n.left-s.left-.5*a.width()},{duration:i,queue:!1})}toggleCropper(e){if(void 0===e.data.object.cropper){e.data.object.clearHighlights(e),e.data.object.clearNotes(e),e.data.object.pageZoom("auto"),e.data.object.destroyTextLayer(),$(".dropdown.show .dropdown-toggle").dropdown("toggle"),$("#pdfviewer-menu").find("button, input, select").prop("disabled",!0),$(".btn-group-toggle").addClass("disabled").children().addClass("disabled"),$("#pdfviewer-image").prop("disabled",!1);let t=e.data.object.page-1;e.data.object.cropper=new Cropper($(".pdfviewer-page > img")[t],{background:!1,viewMode:1,dragMode:"move",initialAspectRatio:1,rotatable:!1,movable:!1,zoomable:!1,autoCropArea:.5,ready:function(){let e=$("#copy-image-btn-temp").clone(),t=$("#save-image-btn-temp").clone();$(".cropper-crop-box").append('
'),e.attr("id","copy-image-btn").removeClass("d-none").appendTo("#crop-buttons"),t.attr("id","save-image-btn").removeClass("d-none").appendTo("#crop-buttons")}}),$("#pdfviewer-pages > .pdfviewer-right > .pdfviewer-page:first").hasClass("img-night-mode")&&e.data.object.nightMode()}else e.data.object.destroyCropper()}destroyCropper(){$("#pdfviewer-menu").find("button, input, select").prop("disabled",!1),$(".btn-group-toggle").removeClass("disabled").children().removeClass("disabled"),"object"==typeof this.cropper&&(this.cropper.destroy(),this.cropper=void 0)}getCroppedImage(e){let t=e.data.object,i=t.cropper.getData(!0),a=new URL(t.cropper.url);_.assign(i,{id:$("body").data("id"),page:t.page,zoom:a.searchParams.get("zoom")}),location.assign(window.IL_BASE_URL+"index.php/page/loadcrop?"+$.param(i))}saveCroppedImage(e){let t=e.data.object,i=t.cropper.getData(!0),a=new URL(t.cropper.url);_.assign(i,{id:$("body").data("id"),page:t.page,zoom:a.searchParams.get("zoom")}),model.save({url:window.IL_BASE_URL+"index.php/page/savecrop",data:$.param(i)})}toggleLeft(e){let t="object"==typeof e?e.data.object:this;$(".pdfviewer-left").hasClass("d-none")?t.showLeft():t.hideLeft()}showLeft(){$(".pdfviewer-left").removeClass("d-none"),$(window).trigger("resize.PdfMainView"),store.save("il.leftPanel",$(".pdfviewer-left").is(":visible")),!0===$("#pdfviewer-thumbs").hasClass("d-none")&&!0===$("#pdfviewer-bookmarks").hasClass("d-none")&&!0===$("#pdfviewer-notes").hasClass("d-none")&&!0===$("#pdfviewer-results").hasClass("d-none")&&this.showThumbs()}hideLeft(){$(".pdfviewer-left").addClass("d-none"),$(window).trigger("resize.PdfMainView"),store.save("il.leftPanel",$(".pdfviewer-left").is(":visible"))}showThumbs(e){let t="object"==typeof e?e.data.object:this;$("#pdfviewer-thumbs").removeClass("d-none"),$("#pdfviewer-bookmarks").addClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").addClass("d-none"),t.redrawNoteLine(),t.redrawSnippetLine();$(".pdfviewer-thumb > img").each(function(){"200px"!==this.style.width&&(this.style.width="200px",this.style.height=200/this.getAttribute("width")*this.getAttribute("height")+"px")})}showBookmarks(e){let t="object"==typeof e?e.data.object:this;if(1===$("#pdfviewer-bookmarks :text").length)return $("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-bookmarks").removeClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").addClass("d-none"),t.redrawNoteLine(),t.redrawSnippetLine(),!1;$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/bookmarks?id="+$("body").data("id")})).done(function(e){$("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").addClass("d-none"),$("#pdfviewer-bookmarks").removeClass("d-none").html(e.html),$("#pdfviewer-bookmarks :text").filterable({targets:"#pdfviewer-bookmarks a"}).val(""),t.redrawNoteLine(),t.redrawSnippetLine()})}clickBookmark(e){e.preventDefault(),e.data.object.scrollToPage($(this).data("page"))}nightMode(){$("#pdfviewer-pages > .pdfviewer-right > .pdfviewer-page").toggleClass("img-night-mode img-light-mode");let e=$("#pdfviewer-pages > .pdfviewer-right > .pdfviewer-page:first").hasClass("img-night-mode");e?imageFilter.nightMode():imageFilter.lightMode(),store.save("il.nightMode",e)}toggleTextLayer(e){let t=e.data.object,i=t.page;0===$("#pdfviewer-pages").find(".pdfviewer-text").length?(t.clearHighlights(e),t.clearNotes(e),void 0===t.selectable&&(t.selectable=new Selectable({lasso:{backgroundColor:"transparent"},lassoSelect:"sequential",appendTo:"#pdfviewer-pages",maxSelectable:1e3})),t.selectable.off("end"),t.selectable.on("end",t.copyText),t.getBoxes(i)):t.destroyTextLayer()}destroyTextLayer(){$("#pdfviewer-pages").find(".pdfviewer-text").remove(),"object"==typeof this.selectable&&(this.selectable.off("end",this.copyText),this.selectable.disable(),this.selectable.destroy(),this.selectable=void 0)}copyText(){let e="";if($(".pdfviewer-text").children(".ui-selected").each(function(){e=e+$(this).attr("data-text")+" "}),e=(e=e.replace(/(- )/g,"")).replace(/\s{2,}/g," "),""===(e=$.trim(e)))return!1;$('").appendTo("body"),$("#copy-text-container").select();try{document.execCommand("copy"),$("#copy-text-container").remove()}catch(e){return $.jGrowl("Copied to clipboard not supported by this browser."),!1}$.jGrowl('
'+e+"
",{header:"Copied to clipboard",theme:"bg-primary"}),this.clear()}getHighlights(){$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/highlights",data:{id:$("body").data("id")},async:!0})).done(function(e){$("#pdfviewer-pages").find(".pdfviewer-highlights").remove();let t="";"underlined"===store.load("il.highlightStyle")&&(t="underlined"),_.forEach(e.highlights,function(e,i){let a=$("#pdfviewer-pages").find(".pdfviewer-page").eq(i-1);$(e).addClass(t).insertAfter(a.children("img"))})})}showAnnotations(e){let t=e.data.object;0===$("#pdfviewer-pages").find(".pdfviewer-highlights").length&&t.getHighlights(),t.showNotes(e)}hideAnnotations(e){let t=e.data.object;t.clearHighlights(e),t.clearNotes(e)}addHighlights(e){let t=e.data.object,i=t.page;t.clearNotes(e),$(this).hasClass("highlight-blue")?(store.save("il.highlight","B"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-blue")):$(this).hasClass("highlight-yellow")?(store.save("il.highlight","Y"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-yellow")):$(this).hasClass("highlight-green")?(store.save("il.highlight","G"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-green")):$(this).hasClass("highlight-red")&&(store.save("il.highlight","R"),$("#pdfviewer-pages").find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}).addClass("cursor-marker-red")),0===$("#pdfviewer-pages").find(".pdfviewer-highlights").length&&t.getHighlights(),void 0===t.selectable&&(t.selectable=new Selectable({lasso:{backgroundColor:"transparent"},lassoSelect:"sequential",appendTo:"#pdfviewer-pages",maxSelectable:1e3})),t.selectable.off("end"),t.selectable.on("end",t.saveHighlights),0===$("#pdfviewer-pages").find(".pdfviewer-text").length&&t.getBoxes(i)}saveHighlights(e,t){let i,a=window.pdfmainview||views.pdfmain,o={},n=store.load("il.highlight");switch(n){case"R":i="red";break;case"G":i="green";break;case"B":i="blue";break;case"Y":i="yellow"}_.forEach(t,function(e,t){let a,n,s,r,l=$(e.node),d=l.parent().siblings(".pdfviewer-highlights"),c=l.attr("style").split(";");l.clone().removeClass("ui-selectable ui-selected").addClass(i).appendTo(d),_.forEach(c,function(e){let t=e.split(":");switch(t[0]){case"top":a=10*parseFloat(t[1].slice(0,-1));break;case"left":n=10*parseFloat(t[1].slice(0,-1));break;case"width":s=10*parseFloat(t[1].slice(0,-1));break;case"height":r=10*parseFloat(t[1].slice(0,-1))}}),o[t]={page:l.closest(".pdfviewer-page").data("page"),top:a,left:n,width:s,height:r,position:l.data("position"),text:l.attr("data-text")}}),"object"==typeof o[0]&&$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/savehighlights",data:{id:$("body").data("id"),color:n,boxes:JSON.stringify(o)},async:!0})).done(function(){a.getHighlights()})}clearHighlights(e){let t=e.data.object,i=$("#pdfviewer-pages");i.find(".pdfviewer-text").remove(),store.delete("il.highlight"),"object"==typeof t.selectable&&(t.selectable.off("end",t.saveHighlights),t.selectable.destroy(),t.selectable=void 0),i.find(".pdfviewer-page").removeClass(function(e,t){return(t.match(/(^|\s)cursor-\S+/g)||[]).join(" ")}),i.find(".pdfviewer-highlights").remove()}eraserInit(e){let t=e.data.object,i=$("#pdfviewer-pages");i.find(".pdfviewer-highlights").length>0&&(void 0===t.selectable&&(t.selectable=new Selectable({lasso:{backgroundColor:"transparent"},lassoSelect:"sequential",appendTo:"#pdfviewer-pages",maxSelectable:1e3})),t.selectable.off("end"),t.selectable.on("end",t.deleteHighlights),0===i.find(".pdfviewer-text").length&&t.getBoxes(t.page),i.find(".pdfviewer-page").addClass("cursor-eraser"))}deleteHighlights(e,t){let i=window.pdfmainview||views.pdfmain,a={};_.forEach(t,function(e,t){let i=$(e.node),o=i.parent().siblings(".pdfviewer-highlights"),n=i.data("position");o.children('[data-position="'+n+'"]').remove(),a[t]={page:i.closest(".pdfviewer-page").data("page"),position:n}}),"object"==typeof a[0]&&$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/deletehighlights",data:{id:$("body").data("id"),boxes:JSON.stringify(a)},async:!0})).done(function(){i.getHighlights()})}highlightStyle(){!0===$(this).prop("checked")?($("#pdfviewer-pages").find(".pdfviewer-highlights").addClass("underlined"),store.save("il.highlightStyle","underlined")):($("#pdfviewer-pages").find(".pdfviewer-highlights").removeClass("underlined"),store.save("il.highlightStyle","highlight"))}getLinks(){let e=new EventSource(IL_BASE_URL+"index.php/pdf/links?id="+$("body").data("id"));e.onmessage=function(t){if("CLOSE"===t.data||0===$("#pdfviewer-pages").length)e.close();else{let e=JSON.parse(t.data);_.forEach(e,function(e,t){$("#pdfviewer-pages").find(".pdfviewer-page").eq(t-1).append(e)})}}}getBoxes(e){let t=this;$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/boxes",data:{id:$("body").data("id"),page:e},async:!0})).done(function(e){$("#pdfviewer-pages").find(".pdfviewer-text").remove(),_.forEach(e.boxes,function(e,i){let a=$("#pdfviewer-pages").find(".pdfviewer-page").eq(i-1);a.append(e),t.selectable.add(a.children(".pdfviewer-text").children().get())})})}search(e){if(13!==e.which)return!1;let t,i=e.data.object,a=$(this),o=$(".pdfviewer-right > div:last-child").data("page"),n=$("#pdfviewer-results > .pdfviewer-no-results-container"),s=$("#pdfviewer-results > .pdfviewer-results-container"),r=$("#pdfviewer-search-progress"),l=$("#pdfviewer-pages");n.removeClass("d-none"),s.empty(),l.find(".pdfviewer-result-boxes").remove(),"object"==typeof i.sseSearch&&2!==i.sseSearch.readyState&&(i.sseSearch.close(),clearTimeout(t),r.addClass("d-none"),r.find("div").width("0%").attr("aria-value-now","0%")),t=setTimeout(function(){r.removeClass("d-none")},500),i.sseSearch=new EventSource(IL_BASE_URL+"index.php/pdf/search?id="+$("body").data("id")+"&query="+a.val()),i.sseSearch.onmessage=function(e){if("CLOSE"===e.data||0===l.length)i.sseSearch.close(),clearTimeout(t),r.addClass("d-none"),r.find("div").width("0%").attr("aria-value-now","0%");else{let t=JSON.parse(e.data);_.forEach(t.boxes,function(e,t){l.find(".pdfviewer-page").eq(t-1).children("img").after(e)}),_.forEach(t.snippets,function(e){$(e).appendTo("#pdfviewer-results > .pdfviewer-results-container"),!1===n.hasClass("d-none")&&n.addClass("d-none")});let i=Math.floor(Math.min(100,100*t.last_page/o));r.find("div").width(i+"%").attr("aria-value-now",i+"%"),0===s.find("a.bg-dark").length&&s.find("a").eq(0).trigger("click").focus()}},i.showResults(),!1===$(".navbar-toggler").is(":visible")&&i.showLeft()}showResults(e){let t="object"==typeof e?e.data.object:this;$("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-bookmarks").addClass("d-none"),$("#pdfviewer-notes").addClass("d-none"),$("#pdfviewer-results").removeClass("d-none"),t.redrawNoteLine(),t.redrawSnippetLine()}scrollToResult(e){let t=e.data.object;$("#pdfviewer-results .snippet").removeClass("bg-dark"),$(this).addClass("bg-dark");let i=$("#"+$(this).data("box"));t.drawSnippetLine($(this).data("box")),t.scrollToElement(i),$(".pdfviewer-result-boxes > div").removeClass("active"),i.addClass("active")}nextResult(){let e=$("#pdfviewer-results a.bg-dark").next();1===e.length?e.trigger("click"):$("#pdfviewer-results a").eq(0).trigger("click")}prevResult(){let e=$("#pdfviewer-results a.bg-dark").prev();1===e.length?e.trigger("click"):$("#pdfviewer-results a").last().trigger("click")}showNotes(e){let t=e.data.object;$("#pdfviewer-thumbs").addClass("d-none"),$("#pdfviewer-bookmarks").addClass("d-none"),$("#pdfviewer-notes").removeClass("d-none"),$("#pdfviewer-results").addClass("d-none"),t.redrawSnippetLine(),$.when(model.load({url:window.IL_BASE_URL+"index.php/pdf/notelist",data:{id:$("body").data("id")}})).done(function(e){$("#pdfviewer-notes").html(e.list),_.forEach(e.pages,function(e,t){let i=$("#pdfviewer-pages").find(".pdfviewer-page").eq(t-1);i.find(".pdfviewer-notes").remove(),i.append(e)}),$(".pdfnote").tooltip({animation:!1,template:''}).on("shown.bs.tooltip",function(){"function"==typeof window.MathJax.typeset&&window.MathJax.typeset(),$(this).tooltip("update")}),$("#pdfviewer-notes").on("click",".note-btn",function(){let e=$(this).data("id");t.scrollToElement($("#pdfnote-"+e)),$(".note-btn").removeClass("active"),$(this).addClass("active"),$(".pdfnote").tooltip("hide"),t.drawNoteLine(e)}),$(".pdfnote").on("click",function(){let e=$(this).data("id");$("#pdfviewer-notes .note-btn").removeClass("active"),$("#pdfviewer-notes").find('.note-btn[data-id="'+e+'"]').addClass("active"),t.drawNoteLine(e)}),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset()})}editNote(e){let t=$(this).parent();t.addClass("d-none"),t.next().removeClass("d-none")}saveNote(e){let t=e.data.object,i=$(this),a=i.find("textarea").val(),o=i.parent().data("id")||0,n=$("body").data("id");e.preventDefault(),$.when(model.save({url:i.attr("action"),data:i.serialize()+"&id="+n,async:!0})).done(function(){i.addClass("d-none"),""===$.trim(a)||0===o?t.showNotes(e):(i.prev().removeClass("d-none").find("button").eq(0).text(a),$("#pdfnote-"+o).attr("data-title",a).attr("data-original-title",a),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset())})}createNewNote(e){let t=e.data.object;!0===$(".pdfviewer-page").hasClass("cursor-cross")?t.clearNewNote():(t.clearHighlights(e),t.showNotes(e),t.showLeft(),$(".pdfviewer-page").addClass("cursor-cross"),$(".pdfviewer-page").on("click.createnote",".pdfviewer-notes",function(e){let i=Math.round(1e3*(e.pageX-$(this).offset().left)/$(this).width()),a=Math.round(1e3*(e.pageY-$(this).offset().top)/$(this).height()),o=$(this).closest(".pdfviewer-page").data("page"),n=$("#new-note-form");n.removeClass("d-none").find('[name="pg"]').val(o),n.find('[name="left"]').val(i),n.find('[name="top"]').val(a),$(".pdfnote.new").remove(),$('
').appendTo(this),t.clearNewNote()}))}clearNotes(e){e.data.object.clearNewNote(),$("#pdfviewer-notes").empty(),$("#pdfviewer-pages").find(".pdfviewer-notes").remove()}clearNewNote(){$(".pdfviewer-page").removeClass("cursor-cross"),$(".pdfviewer-page").off("click.createnote")}drawNoteLine(e){let t=$("#pdfnote-"+e),i=$("#pdfviewer-notes").find('.note-group[data-id="'+e+'"]'),a=t[0].getBoundingClientRect(),o=i[0].getBoundingClientRect(),n=o.right,s=Math.min(o.top+15,a.top),r=a.left-o.right,l=a.top-(o.top+15),d="";(null===i[0].offsetParent||s<50||l+s>$(window).height()||r<1)&&(d="d-none");let c="";l<0&&(c='transform="scale (-1, 1)" transform-origin="center"',l=Math.abs(l)),0===l&&(l=1);let h=`\n \n \n `;$("#note-line").remove(),t.parent().prepend(h)}redrawNoteLine(){let e=$("#note-line");1===e.length&&this.drawNoteLine(e.attr("data-note-id"))}drawSnippetLine(e){let t=$("#"+e),i=$(".pdfviewer-results-container").find('[data-box="'+e+'"]'),a=t[0].getBoundingClientRect(),o=i[0].getBoundingClientRect(),n=o.right,s=Math.min(o.top+20,a.top),r=a.left-o.right,l=a.top-(o.top+20),d="";(null===i[0].offsetParent||s<50||l+s>$(window).height()||r<1)&&(d="d-none");let c="";l<0&&(c='transform="scale (-1, 1)" transform-origin="center"',l=Math.abs(l)),0===l&&(l=1);let h=`\n \n \n `;$("#snippet-line").remove(),t.parent().prepend(h)}redrawSnippetLine(){let e=$("#snippet-line");1===e.length&&this.drawSnippetLine(e.attr("data-snippet-id"))}openLink(e){let t=e.data.object,i=$(this).data("href");"number"==typeof i?t.scrollToPage(i):window.open(i)}}views.pdfmain=new PdfMainView;class PdfManageView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){$("#upload-form").uploadable(),$("#delete-pdf").confirmable({submit:function(){let e=$("body").data("id");$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/delete",data:{id:e}})).done(function(){B.history.loadUrl()})}}),$("#reindex-pdf").confirmable({submit:function(){let e=$("body").data("id");$.when(model.save({url:window.IL_BASE_URL+"index.php/pdf/extract",data:{id:e}})).done(function(){B.history.loadUrl()})}}),$("#ocr-pdf").confirmable({submit:function(){let e=$("#ocr-form");$.when(model.save({url:e.attr("action"),data:e.serialize()})).done(function(){B.history.loadUrl()})}}),$("body").off("submit.pdfmanage").on("submit.pdfmanage","#ocr-form",function(e){e.preventDefault()}),"object"==typeof itemview&&(itemview.clickTitle(),itemview.changeTitleLink())}}views.pdfmanage=new PdfManageView;class ImportWizardView extends View{constructor(){super(),this.parent="#content-col"}}views.importwizard=new ImportWizardView;class ImportUidView extends View{constructor(){super(),this.parent="#content-col",this.inputType="",this.events={"click #fetch-record":"fetch","input #uid":"uidResolve","keydown #uid":"preventSubmit"}}afterRender(e){formStyle.init(),$("#upload-form").uploadable(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}uidResolve(e){let t=$.trim($(this).val());if(!0===/^10\.\d{4}/.test(t))$("#new-uid-type").val("DOI");else if(!0===/^http/i.test(t)){let e=new URL(t).pathname.substr(1);!0===/^10\.\d{4}/.test(e)&&($(this).val(e),$("#new-uid-type").val("DOI"))}else!0===/^pmid:/i.test(t)?$("#new-uid-type").val("PMID"):!0===/^ieee:/i.test(t)?$("#new-uid-type").val("IEEE"):!0===/^arxiv:/i.test(t)?$("#new-uid-type").val("ARXIV"):!0===/^[0-9]{4}.{14}[A-Z]/.test(t)?$("#new-uid-type").val("NASAADS"):!0===/^pmc.*|pmcid:/i.test(t)?$("#new-uid-type").val("PMCID"):!0===/^OL/.test(t)?$("#new-uid-type").val("OL"):!0===/^[A-Z]{2}\d+/.test(t)?$("#new-uid-type").val("PAT"):!0===/^[SP]\d/.test(t)?$("#new-uid-type").val("DIRECT"):!0===/^ISBN:\s?\d/.test(t)?$("#new-uid-type").val("ISBN"):$("#new-uid-type").val("");$("#select-type").collapse("show")}fetch(e){let t=$.trim($("#uid").val());switch($("#new-uid-type").val()){case"DOI":$.when(model.load({url:window.IL_BASE_URL+"index.php/crossref/fetch",data:{uid:t}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))}).fail(function(e){404===e.status&&$("#uid-message").removeClass("d-none").html("No record found. Try another UID.")});break;case"PMID":let e=t.replace(/\D/g,"");$.when(model.load({url:"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id="+e,cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/pubmed/format",data:{xml:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"PMCID":let i=$.trim(t.replace(/pmcid:/gi,""));$.when(model.load({url:"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&retmode=xml&id="+i,cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/pmc/format",data:{xml:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"ISBN":let a=$.trim(t.replace(/isbn:/gi,""));$.when(model.load({url:"https://openlibrary.org/api/books?bibkeys=ISBN:"+a+"&jscmd=data&format=json",cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/ol/convert",data:{json:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"OL":let o=$.trim(t.replace(/isbn:/gi,""));$.when(model.load({url:"https://openlibrary.org/api/books?bibkeys=OLID:"+o+"&jscmd=data&format=json",cors:!0,dataType:"text"})).done(function(e){$.when(model.save({url:window.IL_BASE_URL+"index.php/ol/convert",data:{json:e}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})});break;case"IEEE":let n=t.replace(/ieee:\s?/i,"");$.when(model.load({url:window.IL_BASE_URL+"index.php/ieee/fetch",data:{uid:n}})).done(function(e){let t=e.items[0];$(".import-wizard-uid").html('Record found:
'+t.title+"
"),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none")});break;case"ARXIV":let s=t.replace(/arxiv:\s?/i,"");$.when(model.load({url:arxiv.url+s,cors:!0,dataType:"xml"})).done(function(e){let t=$(e).find("entry"),i=t.children("title").text();$(".import-wizard-uid").html('Record found:
'+i+"
"),$("#metadata").val(arxiv.metadata($(e))),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none")}).fail(function(e){400===e.status&&$("#uid-message").removeClass("d-none").html("No record found. Try another UID.")});break;case"NASAADS":$.when(model.load({url:window.IL_BASE_URL+"index.php/nasa/fetch",data:{uid:t}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))});break;case"PAT":let r=t.replace(/patent:\s?/i,"");$.when(model.load({url:window.IL_BASE_URL+"index.php/patents/fetch",data:{uid:r}})).done(function(e){let t=e.items[0]||[];void 0===t.title?$("#uid-message").removeClass("d-none").html("No record found. Try another UID."):($(".import-wizard-uid").html('Record found:
'+t.title+"
"),$(".uploadable-url").val(t.urls[1]||""),$("#metadata").val(JSON.stringify(t)),$("#fetch-record").addClass("d-none"),$("#upload-form").find(":submit").removeClass("d-none"),$("#phase-2").removeClass("d-none"))})}}preventSubmit(e){13===e.which&&(e.preventDefault(),e.data.object.fetch())}}views.importuid=new ImportUidView;class ImportFileView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){formStyle.init(),$("#upload-form").uploadable(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}}views.importfile=new ImportFileView;class ImportTextView extends View{constructor(){super(),this.parent="#content-col"}afterRender(e){formStyle.init(),$("#upload-form").uploadable(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}}views.importtext=new ImportTextView;class ImportManualView extends View{constructor(e){super(),this.parent="#content-col",this.editmain=e}afterRender(e){formStyle.init(),$("#upload-form").uploadable({pdftitles:function(e,t){$("#extracted-titles").empty(),t.titles.length>0&&$("#title").val(t.titles.pop())},change:function(e,t){$("#title").val(t.name.substr(0,t.name.lastIndexOf(".")))},clear:function(e){$("#title").val("")}}),this.editmain.uploadFormWidgets(),$("#tag-filter").filterable({complete:function(){$("#content-col .label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),$(".tag-table").find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}}views.importmanual=new ImportManualView(views.editmain);class ExternalMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .search-form":"search","click .delete-search":"deleteSearch","click .edit-search":"loadForm"}}afterRender(e){formStyle.init(),$(".clone-button").clonable({target:"#search-row"}),$(this.parent).find("form").saveable()}search(e){e.preventDefault(),$(this).saveable("save");let t=$(this).serialize();router.navigate($(this).attr("action")+"?"+t,{trigger:!0})}deleteSearch(e){let t=$(this);$.when(model.save({url:t.data("url"),data:{id:t.data("id")}})).done(function(){B.history.loadUrl()})}loadForm(){let e=$(this).closest(".list-group-item").find("a").attr("href"),t=new URL("http://foo.bar/"+e.substr(1)).searchParams.entries(),i=[];for(let e of t){const[t,a]=e;""!==a&&i.push({name:t,value:a})}let a=$("#content-col").find("form");a.saveable("saveParams",i),a.saveable("load")}}views.ieeemain=new ExternalMainView,views.arxivmain=new ExternalMainView,views.crossrefmain=new ExternalMainView,views.pubmedmain=new ExternalMainView,views.pmcmain=new ExternalMainView,views.nasamain=new ExternalMainView,views.patentsmain=new ExternalMainView,views.sciencedirectmain=new ExternalMainView,views.scopusmain=new ExternalMainView;class ExternalSearchView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .add-pdf-btn":"makeUploadable","click button":"makeUploadable"}}afterRender(e){formStyle.init(),$(window).off("resize.ExternalSearchView").on("resize.ExternalSearchView",function(){views.itemsmain.itemsHeight()}),views.itemsmain.itemsHeight(),$("#content-col .tag-filter").filterable({complete:function(){let e=$(this).closest(".collapse"),t=$(this).closest(".collapse").find("table");e.find(".label-text").each(function(){$(this).hasClass("d-none")?$(this).parent().parent().addClass("d-none"):$(this).parent().parent().removeClass("d-none")}),t.find("tr").each(function(){$(this).find(".label-text").length-$(this).find(".label-text.d-none").length==0?$(this).addClass("d-none"):$(this).removeClass("d-none")})}})}makeUploadable(){$(this).closest("form").uploadable()}}views.ieeesearch=new ExternalSearchView,views.arxivsearch=new ExternalSearchView,views.crossrefsearch=new ExternalSearchView,views.pubmedsearch=new ExternalSearchView,views.pmcsearch=new ExternalSearchView,views.nasasearch=new ExternalSearchView;class GlobalSettingsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #settings-form":"submitForm"}}afterRender(e){formStyle.init()}submitForm(e){e.preventDefault();let t=$(this),i=$.trim($("#wpad-url").val());!0===$("#connection-url").prop("checked")&&""!==i?$.getScript(i,function(){let e=FindProxyForURL("","www.crossref.org"),i="",a=e.split(";");_.forEach(a,function(e){if(0===_.trim(e).indexOf("PROXY"))return i=e.substr(6),$("#proxy-pac").val(i),!1}),$.when(model.save({url:t.attr("action"),data:t.serialize()}))}).fail(function(){$.jGrowl("Unable to fetch the PAC/WPAD file.",{header:"Error",theme:"bg-danger"})}):$.when(model.save({url:t.attr("action"),data:t.serialize()}))}}views.globalsettingsmain=new GlobalSettingsMainView;class UsersMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"click .update-user":"updateUser","click #create-user":"createUser"}}afterRender(e){$(".reset-password").confirmable({submit:this.resetPassword})}updateUser(){let e=$(this).closest("tr"),t=e.find(".email").val();""!==$.trim(t)?$.when(model.save({url:window.IL_BASE_URL+"index.php/users/update",data:{user:{username:e.find(".username").text(),first_name:e.find(".first-name").val(),last_name:e.find(".last-name").val(),email:t,permissions:e.find(".permissions").val(),status:e.find(".status").val()}}})).done(function(){B.history.loadUrl()}):$.jGrowl("Email is required.",{header:"Info",theme:"bg-primary"})}createUser(){let e=$(this).closest("tr"),t=e.find(".email").val();""!==$.trim(t)?$.when(model.save({url:window.IL_BASE_URL+"index.php/users/create",data:{user:{username:e.find(".username").val(),first_name:e.find(".first-name").val(),last_name:e.find(".last-name").val(),email:t,permissions:e.find(".permissions").val()}}})).done(function(e){"string"==typeof e.password&&$.jGrowl(e.password,{sticky:!0,theme:"bg-dark text-light"}),B.history.loadUrl()}):$.jGrowl("Email is required.",{header:"Info",theme:"bg-primary"})}resetPassword(){let e=$(this).closest("tr"),t=e.find(".email").val();""!==$.trim(t)?$.when(model.save({url:window.IL_BASE_URL+"index.php/users/reset",data:{user:{username:e.find(".username").text(),email:t}}})).done(function(e){"string"==typeof e.password&&$.jGrowl(e.password,{sticky:!0,theme:"bg-dark"})}):$.jGrowl("User's email is required to reset password.",{header:"Info",theme:"bg-primary"})}}views.usersmain=new UsersMainView;class DetailsMainView extends View{constructor(){super(),this.parent="#content-col"}}views.detailsmain=new DetailsMainView;class LogsMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit .form-chart":"submitForm","submit #form-list":"drawTable"}}afterRender(e){formStyle.init(),chart.draw("chart-opens",_.keys(e.opens),null,_.values(e.opens)),chart.draw("chart-pages",_.keys(e.pages),null,_.values(e.pages)),chart.draw("chart-downloads",_.keys(e.downloads),null,_.values(e.downloads)),window.tables["table-logs"]=$("#table-logs").DataTable({deferRender:!0,order:[[2,"desc"],[0,"asc"]]})}submitForm(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action"),data:t.serialize()})).done(function(e){void 0!==e.opens?chart.draw("chart-opens",_.keys(e.opens),null,_.values(e.opens)):void 0!==e.pages?chart.draw("chart-pages",_.keys(e.pages),null,_.values(e.pages)):void 0!==e.downloads&&chart.draw("chart-downloads",_.keys(e.downloads),null,_.values(e.downloads))})}drawTable(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action"),data:t.serialize()})).done(function(e){window.tables["table-logs"].clear().rows.add(e).draw()})}}views.logsmain=new LogsMainView;class CitationMainView extends View{constructor(){super(),this.parent="#content-col",this.events={"submit #form-new-csl":"submitForm"}}afterRender(e){window.tables["table-csl"]=$("#table-csl").DataTable({deferRender:!0,data:e.styles,columnDefs:[{orderable:!1,targets:2}]}),$("#modal-csl").off("shown.bs.modal").on("shown.bs.modal",function(e){$("#modal-csl").find(".modal-title").text($(e.relatedTarget).attr("data-name")),$.when(model.load({url:window.IL_BASE_URL+"index.php/citation/get",data:{id:$(e.relatedTarget).attr("data-id")}})).done(function(e){$("#modal-csl").find("code").html(e.csl)})})}submitForm(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){t[0].reset()})}}views.citationmain=new CitationMainView;class MainView{constructor(){sidebar.init(),""!==location.hash&&"#"!==location.hash||1!==$("#side-menu").length||router.navigate("dashboard/main",{trigger:!0,replace:!0}),$("#signin-form").on("submit",function(e){e.preventDefault();let t=$(this),i=new URL(window.location.href).searchParams.get("ref");""!==$.trim(t.find('[name="username"]').val())&&""!==$.trim(t.find('[name="password"]').val())&&$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(e){if(void 0===e.info)if("string"==typeof i){let e=window.atob(i);new URL(e).hostname===location.hostname?location.replace(e):location.replace(IL_BASE_URL+"index.php/#dashboard/main")}else location.replace(IL_BASE_URL+"index.php/#dashboard/main")})}),$("#migrate-form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action")+"?"+t.serialize()})).done(function(e){void 0===e.info&&location.replace(window.IL_BASE_URL)})}),$("#sign-out").on("click",function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/authentication/signout"})).done(function(){location.assign(window.IL_BASE_URL)})}),$(".modal-content").draggable({containment:"document",handle:".modal-header"}),$("#keyboard-toggle").on("click",function(){keyboard.init()}),$("#content-col").on("click","#open-settings",function(){""===$.trim($("#modal-settings").find(".modal-body").html())&&$.when(model.load({url:window.IL_BASE_URL+"index.php/settings/display"})).done(function(e){$("#modal-settings").find(".modal-body").html(e.html),formStyle.init()})}),$("#modal-settings .modal-footer button").eq(0).on("click",function(e){$("#modal-settings form").trigger("submit")}),$("#modal-settings").on("submit","form",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()}),$("#modal-settings").modal("hide")}),searchlist.init()}}class MigrationView{constructor(){$("#migrate-form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.load({url:t.attr("action")+"?"+t.serialize()})).done(function(e){void 0===e.info&&location.replace(window.IL_BASE_URL)})})}}class RegistrationView{constructor(){$("#signup-form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(e){void 0===e.info&&location.assign(window.IL_BASE_URL)})})}}class ResetpasswordView{constructor(){$("form").on("submit",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(e){$(".container-fluid").html(e.html)})}),$("body").on("click","#new-password",function(){let e=window.getSelection(),t=document.createRange();t.selectNodeContents($("#new-password")[0]),e.removeAllRanges(),e.addRange(t)})}}class ItemView{constructor(){sidebar.init();let e="string"==typeof store.load("il.itemReferrer")?store.load("il.itemReferrer"):window.IL_BASE_URL+"#items/main";$("#item-back-link").attr("href",e);let t=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",t).data("id",t),$("#id-hidden").val(t),$("a.add-id-link").each(function(){let e=$(this).attr("href").split("id=");$(this).attr("href",e[0]+"id="+t)}),$("#keyboard-toggle").on("click",function(){keyboard.init()}),$("#sign-out").on("click",function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/authentication/signout"})).done(function(){location.assign(window.IL_BASE_URL)})});let i=sessionStore.load("il.idList");if(null===i||i.length<2)$("#left-item-list").addClass("d-none");else{let e=$("#left-item-list .left-item-link").detach(),a=e.attr("href");i.forEach(function(i){let o=i.id===t?"bg-darker-10":"";e.clone().addClass(o).attr("href",a.replace("{ID}",i.id)).attr("data-id",i.id).html(i.title).appendTo("#left-item-list")}),e=void 0,$("#left-item-list").removeClass("d-none").hide().fadeIn()}}clickTitle(){let e=$("#left-item-list"),t=$("#left-item-list .left-item-link.bg-darker-10");if(0===t.length)return e.addClass("d-none"),void sessionStore.delete("il.idList");if(e.hasClass("d-none"))return;let i=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("#left-item-list .left-item-link").each(function(){$(this).removeClass("bg-darker-10"),$(this).attr("data-id")===i&&$(this).addClass("bg-darker-10")});let a=t.position().top,o=e.scrollTop(),n=t[0].getBoundingClientRect(),s=e[0].getBoundingClientRect();(n.top<10||s.bottom-n.bottom<10)&&e.animate({scrollTop:o+a-$(window).height()/3},250),$("a.add-id-link").each(function(){let e=$(this).attr("href").split("id=");$(this).attr("href",e[0]+"id="+i)}),$("body").attr("data-id",i).data("id",i),1===$("#id-hidden").length&&$("#id-hidden").val()!==i&&$.when(model.load({url:window.IL_BASE_URL+"index.php/notes/user",data:{id:i}})).done(function(e){$("#notes-ta").val(e.user.note),$("#id-hidden").val(i),null!==window.tinymce.activeEditor&&!0===window.tinymce.activeEditor.initialized&&window.tinymce.activeEditor.load()})}changeTitleLink(){if($("#left-item-list").hasClass("d-none"))return;let e="#"+new URL("http://foo.bar/"+location.hash.substring(1)).pathname.substring(1);$("#left-item-list .left-item-link").each(function(){$(this).attr("href",e+"?id="+$(this).attr("data-id"))})}}class ProjectView{constructor(){sidebar.init();let e=new URL("http://foo.bar/"+location.hash.substring(1)).searchParams.get("id")||"";$("body").attr("data-id",e).data("id",e),$("a.add-id-link").each(function(){let t=$(this).attr("href").split("id=");$(this).attr("href",t[0]+"id="+e)}),$("#id-hidden").val(e),$("#content-col").on("click",".open-notes",{object:this},this.openNotes),$("#keyboard-toggle").on("click",function(){keyboard.init()}),$("#content-col").on("click","#open-settings",function(){""===$.trim($("#modal-settings").find(".modal-body").html())&&$.when(model.load({url:window.IL_BASE_URL+"index.php/settings/display"})).done(function(e){$("#modal-settings").find(".modal-body").html(e.html),formStyle.init()})}),$("#modal-settings .modal-footer button").eq(0).on("click",function(e){$("#modal-settings form").trigger("submit")}),$("#modal-settings").on("submit","form",function(e){e.preventDefault();let t=$(this);$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){B.history.loadUrl()}),$("#modal-settings").modal("hide")}),$("#sign-out").on("click",function(){$.when(model.save({url:window.IL_BASE_URL+"index.php/authentication/signout"})).done(function(){location.assign(window.IL_BASE_URL)})}),searchlist.init()}openNotes(e){null!==window.tinymce.activeEditor&&!0===window.tinymce.activeEditor.initialized?$("#notes-window").removeClass("d-none"):e.data.object.loadNotes()}loadNotes(){let e=this,t=$("body").data("id");$.when(model.load({url:window.IL_BASE_URL+"index.php/project/usernotes",data:{id:t}})).done(function(t){$("#notes-ta").val(t.user.note),e.initNotes()})}initNotes(){window.tinymce.init({theme:"silver",selector:"#notes-ta",content_css:window.IL_BASE_URL+"css/style.css",resize:"both",min_width:300,min_height:300,menubar:!1,plugins:"importcss save lists advlist link image code fullscreen table searchreplace",toolbar1:"save undo redo fullscreen code | formatselect link unlink image table searchreplace",toolbar2:"bold italic underline strikethrough subscript superscript removeformat | forecolor backcolor | outdent indent bullist numlist",save_onsavecallback:function(e){let t=$("#note-form");$.when(model.save({url:t.attr("action"),data:t.serialize()})).done(function(){$("#user-note").html(e.getContent()),"function"==typeof window.MathJax.typeset&&window.MathJax.typeset()})},image_description:!1,relative_urls:!1,remove_script_host:!1,image_dimensions:!1,image_class_list:[{title:"Auto width",value:"mce-img-fluid"}]}).then(function(){let e=$("#notes-window");e.removeClass("d-none"),e.position({my:"left bottom",at:"left bottom",of:"#content-col"}),$(window).off("resize.notes").on("resize.notes",function(){$("#notes-window").position({my:"left bottom",at:"left bottom",of:"#content-col"})}),e.draggable({handle:".card-header",containment:"body"}),e.find(".close").off("click.notes").on("click.notes",function(){$("#notes-window").addClass("d-none")})})}}$(function(){B.history.start(),$("body").on("click","a",function(){let e=$(this).attr("href");return e.indexOf("//")>0||0===e.indexOf("mailto")||0===e.indexOf("data")?(!0===/\/item#/.test(e)&&store.save("il.itemReferrer",location.href),!0):"#"!==e&&""!==e&&void router.navigate(e,{trigger:!0})}),$("body").on("click","#abort-request",function(){model.abort()}),$(document).on("keydown.hotkeys",null,"a",function(){$(".navigation-left").trigger("click")}),$(document).on("keydown.hotkeys",null,"w",function(){$(".navigation-left").trigger("click")}),$(document).on("keydown.hotkeys",null,"d",function(){$(".navigation-right").trigger("click")}),$(document).on("keydown.hotkeys",null,"s",function(){$(".navigation-right").trigger("click")}),$(document).on("keydown.hotkeys",null,"esc",function(){1===$("#pdfviewer-menu").length&&"object"==typeof views.pdfmain&&(views.pdfmain.destroyCropper(),views.pdfmain.destroyTextLayer(),views.pdfmain.clearNewNote(),$("#pdfviewer-highlight-menu .highlight-cancel").click()),1===$("#pdfviewer-menu").length&&"object"==typeof window.pdfmainview&&(window.pdfmainview.destroyCropper(),window.pdfmainview.destroyTextLayer(),window.pdfmainview.clearNewNote(),$("#pdfviewer-highlight-menu .highlight-cancel").click())}),$(document).on("keydown.hotkeys",null,"h",function(){1===$("#pdfviewer-menu").length&&($(".left-container, #pdfviewer-menu").toggleClass("d-none"),$(window).trigger("resize.PdfMainView"))})}); \ No newline at end of file