{"version":3,"sources":["webpack:///./node_modules/ui-core/widgets/export-citations/js/export-citations.js"],"names":["exportCitation","$toggle","$","$target","$wrapper","$multiToggle","dois","$trigger","response","selectCiteStyle","responseFormat","citationLimited","citationLimitNumber","loadingAdditionalInfo","init","control","url","params","dataType","document","on","this","resetPopup","collectDois","toString","loadCiteProc","getWarningMessage","message","performServerSideAjax","ajax","data","async","success","setContent","content","downloadCiteProc","$el","doisArray","multiDois","hasClass","each","$this","doiValue","attr","val","push","find","selectedFormat","targetCustomCSLFIle","empty","closest","addClass","parent","css","loadingText","html","setParams","targetFile","format","prop","$modal","text","removeClass","removeAttr","warning","downloadContainer","downloadData","is","length","test","downloadMultiText","additionalDownloadDataFormat","contentType","encodeURIComponent","fileName","suffix","UX"],"mappings":"4EAAA,IACQA,IAAiB,CACjBC,QAASC,EAAE,oBACXC,QAASD,EAAE,iBACXE,SAAU,KACVC,aAAcH,EAAE,iCAChBI,KAAM,KACNC,SAAU,KACVC,SAAU,KACVC,gBAAiB,KACjBC,eAAgB,GAChBC,iBAAiB,EACjBC,oBAAqB,EACrBC,sBAAuB,GAEvBC,KAAM,SAANA,OACId,EAAee,WAGnBA,QAAS,SAATA,QAAmBC,EAAKC,EAAQC,GAC5BhB,EAAEiB,UAAUC,GAAG,QAAS,mCAAmC,WACvDpB,EAAeO,SAAWL,EAAEmB,MAC5BrB,EAAesB,WAAWtB,EAAeO,UACzCP,EAAeM,KAAON,EAAeuB,YAAYvB,EAAeO,UAAUiB,WAC1ExB,EAAeyB,aAAazB,EAAeC,YAG/CC,EAAEiB,UAAUC,GAAG,SAAU,oBAAoB,WACzCpB,EAAeyB,aAAavB,EAAEmB,WAGtCK,kBAAmB,SAAnBA,kBAA6BC,GACzB,OAAOA,GAEXC,sBAAuB,SAAvBA,sBAAiCZ,EAAKC,EAAQR,GAC1CP,EAAE2B,KAAK,CACHb,IAAKA,EACLc,KAAMb,EACNc,OAAO,EACPC,QAAS,SAATA,QAAmBxB,GACfR,EAAeQ,S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Bc,KAAKJ,EAAkBV,UAC5CW,EAAeD,EAAkBJ,SAIrCI,EAAkBG,OAAS,GAAG,CAC9B,IAAIE,EAAoB,GACxBL,EAAkBzB,MAAK,WACnB,IAAIC,EAAQvC,EAAEmB,MAEV,qBAAqBgD,KAAK5B,EAAMc,QAChCe,GAAqB7B,EAAMoB,OAAS,OAEpCS,GAAqB7B,EAAMc,OAAS,UAG5CW,EAAeI,EAIvBJ,EAAelE,EAAeuE,6BAA6BL,GAE3D9B,EAAIO,KACA,OACA,QACI3C,EAAeU,eAAeV,EAAeS,iBAAiB+D,YAC9D,kBACAC,mBAAmBP,IAE3B9B,EAAIO,KACA,WACA3C,EAAeU,eAAeV,EAAeS,iBAAiBiE,SAC1D,IACA1E,EAAeU,eAAeV,EAAeS,iBAAiBkE,SAG1EJ,6BAA8B,SAA9BA,6BAAwCL,GACpC,OAAOA,IAIfU,GAAG5E,eAAiBA","file":"js/exportCitation-e15ef75e23a4b6159262.js","sourcesContent":["(function () {\n var exportCitation = {\n $toggle: $('#citation-format'),\n $target: $('.csl-response'),\n $wrapper: null,\n $multiToggle: $('.issue-Item__checkbox:checked'), // overwrite its value based on product html structure\n dois: null,\n $trigger: null,\n response: null,\n selectCiteStyle: null,\n responseFormat: {},\n citationLimited: false,\n citationLimitNumber: 0,\n loadingAdditionalInfo: '',\n\n init: function () {\n exportCitation.control();\n },\n\n control: function (url, params, dataType) {\n $(document).on('click', '[data-target=\"#exportCitation\"]', function () {\n exportCitation.$trigger = $(this);\n exportCitation.resetPopup(exportCitation.$trigger);\n exportCitation.dois = exportCitation.collectDois(exportCitation.$trigger).toString();\n exportCitation.loadCiteProc(exportCitation.$toggle);\n });\n\n $(document).on('change', '#citation-format', function () {\n exportCitation.loadCiteProc($(this));\n });\n },\n getWarningMessage: function (message) {\n return message;\n },\n performServerSideAjax: function (url, params, selectCiteStyle) {\n $.ajax({\n url: url,\n data: params,\n async: true,\n success: function (response) {\n exportCitation.response = response;\n exportCitation.responseFormat[selectCiteStyle] = exportCitation.response;\n exportCitation.setContent(exportCitation.responseFormat[selectCiteStyle].content);\n exportCitation.downloadCiteProc();\n },\n });\n },\n collectDois: function ($el) {\n var doisArray = [];\n var multiDois = false;\n if ($el.hasClass('export-citation')) {\n multiDois = true;\n }\n\n if (multiDois) {\n exportCitation.$multiToggle = $('.issue-Item__checkbox:checked');\n exportCitation.$multiToggle.each(function () {\n const $this = $(this);\n const doiValue = $this.attr('name') === 'doi' ? $this.val() : $this.attr('name');\n doisArray.push(doiValue);\n });\n } else {\n $el.find('[name=\"doiVal\"]').each(function () {\n doisArray.push($(this).val());\n });\n }\n\n return doisArray;\n },\n loadCiteProc: function ($el) {\n exportCitation.selectCiteStyle = $el.val();\n const selectedFormat = $('[value=' + exportCitation.selectCiteStyle + ']').data('format'),\n targetCustomCSLFIle = 'custom-' + exportCitation.selectCiteStyle;\n $('#export-warning').empty();\n exportCitation.$wrapper = $el.closest('.csl-wrapper');\n exportCitation.$target = exportCitation.$wrapper.find('.csl-response');\n\n if (exportCitation.selectCiteStyle) {\n exportCitation.$wrapper\n .find('.copy__btn, .download__btn')\n .addClass('disabled')\n .parent('li')\n .css('cursor', '');\n exportCitation.$wrapper.find('#citation-format').attr('disabled', 'disabled');\n //add spinner\n const loadingText = 'Loading ' + exportCitation.loadingAdditionalInfo + '... ';\n exportCitation.$target.html('' + loadingText + '');\n\n const action_server = '/action/exportCiteProcCitation';\n // var action_server = '/specs/ux3/widgets/export-citations/js/dummy-csl-metaData.json'; // dummy for UX3 testing\n //var action_server = '/specs/products/acm/widgets/export-citations/js/dummy-csl-metaData.json'; // dummy for ACM testing\n\n const params = exportCitation.setParams(targetCustomCSLFIle, selectedFormat);\n\n if (typeof exportCitation.responseFormat[exportCitation.selectCiteStyle] !== 'undefined') {\n exportCitation.setContent(exportCitation.responseFormat[exportCitation.selectCiteStyle].content);\n exportCitation.downloadCiteProc();\n } else {\n exportCitation.performServerSideAjax(action_server, params, exportCitation.selectCiteStyle);\n }\n\n exportCitation.$wrapper.find('[name=\"dois\"]').val(exportCitation.dois);\n exportCitation.$wrapper.find('[name=\"format\"]').val(selectedFormat);\n }\n },\n setParams: function (targetCustomCSLFIle, selectedFormat) {\n return {dois: exportCitation.dois, targetFile: targetCustomCSLFIle, format: selectedFormat};\n },\n resetPopup: function ($el) {\n exportCitation.$target.html('');\n exportCitation.responseFormat = {};\n exportCitation.$toggle.prop('selectedIndex', 0);\n const $modal = $($el.attr('data-target'));\n $modal.find('.copy__btn, .download__btn').addClass('disabled').parent('li').css('cursor', '');\n $modal.find('#citation-format').attr('disabled', 'disabled');\n },\n\n setContent: function (content) {\n exportCitation.$target.html(content);\n exportCitation.$wrapper.find('[name=\"content\"]').val(exportCitation.$target.text());\n exportCitation.$wrapper\n .find('.copy__btn, .download__btn')\n .removeClass('disabled')\n .parent('li')\n .css('cursor', 'pointer');\n exportCitation.$wrapper.find('#citation-format').removeAttr('disabled');\n if (exportCitation.responseFormat[exportCitation.selectCiteStyle].warning) {\n exportCitation.$wrapper\n .find('#export-warning')\n .html(\n exportCitation.getWarningMessage(\n exportCitation.responseFormat[exportCitation.selectCiteStyle].warning\n )\n );\n }\n },\n downloadCiteProc: function () {\n let $el = $('.download__btn'),\n downloadContainer = exportCitation.$target,\n downloadData = '';\n\n if (downloadContainer.is('.csl-response')) {\n if (exportCitation.$target.find('.csl-right-inline').length) {\n downloadContainer = exportCitation.$target.find('.csl-right-inline');\n downloadData = downloadContainer.html();\n\n if (/<\\/?[a-z][\\s\\S]*>/i.test(downloadContainer.html())) {\n downloadData = downloadContainer.text();\n }\n } else if (exportCitation.$target.find('.csl-entry').length) {\n downloadContainer = exportCitation.$target.find('.csl-entry');\n downloadData = downloadContainer.html();\n if (/<\\/?[a-z][\\s\\S]*>/i.test(downloadContainer.html())) {\n downloadData = downloadContainer.text();\n }\n }\n\n if (downloadContainer.length > 1) {\n let downloadMultiText = '';\n downloadContainer.each(function () {\n let $this = $(this);\n\n if (/<\\/?[a-z][\\s\\S]*>/i.test($this.html())) {\n downloadMultiText += $this.text() + '\\n\\n';\n } else {\n downloadMultiText += $this.html() + '\\n\\n';\n }\n });\n downloadData = downloadMultiText;\n }\n }\n\n downloadData = exportCitation.additionalDownloadDataFormat(downloadData);\n\n $el.attr(\n 'href',\n 'data:' +\n exportCitation.responseFormat[exportCitation.selectCiteStyle].contentType +\n ';charset=utf-8,' +\n encodeURIComponent(downloadData)\n );\n $el.attr(\n 'download',\n exportCitation.responseFormat[exportCitation.selectCiteStyle].fileName +\n '.' +\n exportCitation.responseFormat[exportCitation.selectCiteStyle].suffix\n );\n },\n additionalDownloadDataFormat: function (downloadData) {\n return downloadData;\n },\n };\n\n UX.exportCitation = exportCitation; // add to global namespace\n})();\n"],"sourceRoot":""}