{"version":3,"file":"vote-helpful.abc25e.js","mappings":"2zBAAgC,IAEXA,EAAW,WAG3B,O,EAFD,SAAAA,K,4FAAcC,CAAA,KAAAD,GACVE,KAAKC,eACT,G,EAAC,EAAAC,IAAA,gBAAAC,MAED,WACI,IAAMC,EAAKC,EAAE,kBAAkBC,KAAK,MAChCC,EAAOC,EAAAA,EAAQC,IAAI,qBAADC,OAAsBN,IAEtCO,EAAUN,EAAE,eAAeO,GAAG,SAAS,WAIzC,IAAIC,EAHJF,EAAQG,YAAY,UACpBC,EAAUD,YAAY,UAGT,QAATP,GAEAM,GAAQ,EACRN,EAAO,OAEPI,EAAQK,SAAS,UACjBT,EAAO,OAEXF,EAAEY,KAAK,CACHC,IAAK,oCACLC,OAAQ,OACRb,KAAM,CACFF,GAAAA,EACAS,MAAAA,IAGZ,IACME,EAAYV,EAAE,iBAAiBO,GAAG,SAAS,WAI7C,IAAIC,EAHJF,EAAQG,YAAY,UACpBC,EAAUD,YAAY,UAGT,OAATP,GACAM,GAAQ,EACRN,EAAO,OAEPQ,EAAUC,SAAS,UACnBT,EAAO,MAEXF,EAAEY,KAAK,CACHC,IAAK,sCACLC,OAAQ,OACRb,KAAM,CACFF,GAAAA,EACAS,MAAAA,IAGZ,IAGIN,IAASF,EAAEe,cAAcb,KACZ,QAATA,EACAI,EAAQK,SAAS,UAEjBD,EAAUC,SAAS,UAG/B,M,6EAAC,CA7D2B,E","sources":["webpack://cloroxpro-ca/./js/src/components/vote-helpful.js"],"sourcesContent":["import Cookies from 'js-cookie';\n\nexport default class VoteHelpful {\n constructor() {\n this.initListeners();\n }\n\n initListeners() {\n const id = $('.js-post-block').data('id');\n let vote = Cookies.get(`blog_helpful_vote_${id}`);\n\n const $upVote = $('.js-up-vote').on('click', () => {\n $upVote.removeClass('active');\n $downVote.removeClass('active');\n\n let clear;\n if (vote === 'yes') {\n // clear vote\n clear = true;\n vote = null;\n } else {\n $upVote.addClass('active');\n vote = 'yes';\n }\n $.ajax({\n url: '/wp-json/cloroxpro/v1/blog/upvote',\n method: 'POST',\n data: {\n id,\n clear,\n },\n });\n });\n const $downVote = $('.js-down-vote').on('click', () => {\n $upVote.removeClass('active');\n $downVote.removeClass('active');\n\n let clear;\n if (vote === 'no') {\n clear = true;\n vote = null;\n } else {\n $downVote.addClass('active');\n vote = 'no';\n }\n $.ajax({\n url: '/wp-json/cloroxpro/v1/blog/downvote',\n method: 'POST',\n data: {\n id,\n clear,\n },\n });\n });\n\n // set initial state\n if (vote && !$.isEmptyObject(vote)) {\n if (vote === 'yes') {\n $upVote.addClass('active');\n } else {\n $downVote.addClass('active');\n }\n }\n }\n}\n"],"names":["VoteHelpful","_classCallCheck","this","initListeners","key","value","id","$","data","vote","Cookies","get","concat","$upVote","on","clear","removeClass","$downVote","addClass","ajax","url","method","isEmptyObject"],"sourceRoot":""}