{"version":3,"file":"reviewfilter.min.js","sources":["https:\/\/udl.id\/blocks\/edwiserratingreview\/amd\/src\/reviewfilter.js"],"sourcesContent":["\/* eslint-disable no-alert *\/\n\/* eslint-disable no-console *\/\n\/* eslint-disable no-unused-vars *\/\ndefine(['jquery', 'core\/ajax', 'core\/notification', 'core\/templates'], function ($, Ajax, Notification) {\n\n var SELECTORS = {\n REVIEWDATA: '.reviewdata',\n SHOWMOREREVIEWBTN: '.showmorereviewsbtn',\n COURSEID: '#courseId',\n REVIEWSELECTOR: '.reviewselector',\n SHOWMOREREVIEWCLASS: '#showmorereviewclass',\n };\n\n var getreviewdata = function (rates) {\n Ajax.call([{\n methodname: 'block_edwiserratingreview_show_review',\n args: { rating: rates, startlimit: 0, lastlimit: 5, contextid: M.cfg.contextid },\n done: function (data) {\n var result = \"No Reviews found\";\n if (data !== '') {\n result = data;\n }\n\n $(SELECTORS.REVIEWDATA).empty().append(result);\n\n if ($(SELECTORS.REVIEWDATA).children('li.review-card').length == 5) {\n var showmorereviewbuttontext = M.util.get_string('showmorereview', 'block_edwiserratingreview');\n \/\/ eslint-disable-next-line max-len\n var showmorereviebtn = `Show More Review<\/a>`;\n $(SELECTORS.SHOWMOREREVIEWCLASS).empty().append(showmorereviebtn);\n setbuttonurl(rates);\n }else{\n $(SELECTORS.SHOWMOREREVIEWCLASS).empty().append('');\n }\n },\n fail: function () {\n console.log(Notification.exception);\n }\n }]);\n\n };\n\n var setbuttonurl = function (rating) {\n var url = M.cfg.wwwroot + '\/blocks\/edwiserratingreview\/view.php?filter=' +rating+'&contextid=' + M.cfg.contextid;\n $(SELECTORS.SHOWMOREREVIEWBTN).attr('href', url);\n };\n\n const loadReviews = () => {\n var rating = $('.reviewselector option:selected').attr('value');\n getreviewdata(rating);\n };\n\n return {\n init: function () {\n $(document).ready(function () {\n\n loadReviews();\n\n $(document).on(\"change\", SELECTORS.REVIEWSELECTOR, function () {\n loadReviews();\n });\n });\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","SELECTORS","setbuttonurl","rating","url","M","cfg","wwwroot","contextid","attr","loadReviews","rates","call","methodname","args","startlimit","lastlimit","done","data","result","empty","append","children","length","util","get_string","fail","console","log","exception","init","document","ready","on"],"mappings":"AAGAA,gDAAO,CAAC,SAAU,YAAa,oBAAqB,mBAAmB,SAAUC,EAAGC,KAAMC,kBAElFC,qBACY,cADZA,4BAEmB,sBAFnBA,yBAIgB,kBAJhBA,8BAKqB,uBAgCrBC,aAAe,SAAUC,YACrBC,IAAMC,EAAEC,IAAIC,QAAU,+CAAgDJ,OAAO,cAAgBE,EAAEC,IAAIE,UACvGV,EAAEG,6BAA6BQ,KAAK,OAAQL,YAG1CM,YAAc,SAlCUC,MAmCtBR,OAASL,EAAE,mCAAmCW,KAAK,SAnC7BE,MAoCZR,OAnCdJ,KAAKa,KAAK,CAAC,CACPC,WAAY,wCACZC,KAAM,CAAEX,OAAQQ,MAAOI,WAAY,EAAGC,UAAW,EAAGR,UAAWH,EAAEC,IAAIE,WACrES,KAAM,SAAUC,UACRC,OAAS,mBACA,KAATD,OACAC,OAASD,MAGbpB,EAAEG,sBAAsBmB,QAAQC,OAAOF,QAE0B,GAA7DrB,EAAEG,sBAAsBqB,SAAS,kBAAkBC,QACpBlB,EAAEmB,KAAKC,WAAW,iBAAkB,6BAGnE3B,EAAEG,+BAA+BmB,QAAQC,oHACzCnB,aAAaS,QAEbb,EAAEG,+BAA+BmB,QAAQC,OAAO,KAGxDK,KAAM,WACFC,QAAQC,IAAI5B,aAAa6B,sBAgB9B,CACHC,KAAM,WACFhC,EAAEiC,UAAUC,OAAM,WAEdtB,cAEAZ,EAAEiC,UAAUE,GAAG,SAAUhC,0BAA0B,WAC\/CS"}