{"version":3,"sources":["../../../../../dev/j/v2/smb/pages/resources.js"],"names":["filterResources","visibleElements","$resource","each","type","$","this","data","tag","foundInFulltext","find","text","toLowerCase","indexOf","filterFulltextValue","filterTypeValue","filterTagValue","removeClass","addClass","$showMore","$emptyElement","avm","require","$filterType","$filterTag","$filterFulltext","types","Set","tags","add","attr","forEach","value","append","Option","on","val"],"mappings":"CAWA,WACC,YAmDA,SAASA,KACR,GAAIC,GAAkB,CACtBC,GAAUC,KAAK,WACd,GAAIC,GAAOC,EAAEC,MAAMC,KAAK,QACpBC,EAAMH,EAAEC,MAAMC,KAAK,OAEnBE,EACHJ,EAAEC,MAAMI,KAAK,eAAeC,OAAOC,cAAcC,QAAQC,EAAoBF,gBAAkB,GAE/FP,EAAEC,MAAMI,KAAK,cAAcC,OAAOC,cAAcC,QAAQC,EAAoBF,gBAAkB,CAE/F,KAAyB,QAApBG,GAA6BX,IAASW,KAAwC,QAAnBC,GAA4BR,IAAQQ,KAA2C,IAAvBF,GAA6BL,GAGpJ,MAFAR,SACAI,GAAEC,MAAMW,YAAY,SAIrBZ,GAAEC,MAAMY,SAAS,YAGlBC,EAAUD,SAAS,UACC,IAApBjB,EAAwBmB,EAAcH,YAAY,UAAYG,EAAcF,SAAS,UAtEtF,GAAIb,GAAIgB,IAAIC,QAAQ,QAEhBpB,EAAYG,EAAE,gBACjBkB,EAAclB,EAAE,eAChBmB,EAAanB,EAAE,cACfoB,EAAkBpB,EAAE,mBACpBc,EAAYd,EAAE,gCACde,EAAgBf,EAAE,sBAGfqB,EAAQ,GAAIC,KACfC,EAAO,GAAID,KACXZ,EAAkB,MAClBC,EAAiB,MACjBF,EAAsB,EAEvBZ,GAAUC,KAAK,WACduB,EAAMG,IAAIxB,EAAEC,MAAMwB,KAAK,cACvBF,EAAKC,IAAIxB,EAAEC,MAAMwB,KAAK,eAGvBJ,EAAMK,QAAQ,SAASC,GACtBT,EAAYU,OAAO,GAAIC,QAAOF,EAAOA,MAGtCJ,EAAKG,QAAQ,SAASC,GACrBR,EAAWS,OAAO,GAAIC,QAAOF,EAAOA,MAGrCT,EAAYY,GAAG,SAAU,WACxBpB,EAAkBV,EAAEC,MAAM8B,MAC1BpC,MAGDwB,EAAWW,GAAG,SAAU,WACvBnB,EAAiBX,EAAEC,MAAM8B,MACzBpC,MAGDyB,EAAgBU,GAAG,QAAS,WAC3BrB,EAAsBT,EAAEC,MAAM8B,MAC9BpC,MAGDmB,EAAUgB,GAAG,QAAS,WACrBnC,IACAK,EAAEC,MAAMY,SAAS","file":"resources.js","sourcesContent":["/**\n * Business Resources\n * @version 1.0.0\n * @author Erik Ondrus \n * @requires avast.cash\n */\n\n// todo:\n// fulltext search\n// url parameters\n\n(function() {\n\t'use strict';\n\n\tvar $ = avm.require('cash');\n\n\tvar $resource = $('.js-resource'),\n\t\t$filterType = $('#filterType'),\n\t\t$filterTag = $('#filterTag'),\n\t\t$filterFulltext = $('#filterFulltext'),\n\t\t$showMore = $('.js-show-more-resources .btn'),\n\t\t$emptyElement = $('.js-resource-empty');\n\n\n\tvar types = new Set(),\n\t\ttags = new Set(),\n\t\tfilterTypeValue = 'all',\n\t\tfilterTagValue = 'all',\n\t\tfilterFulltextValue = '';\n\n\t$resource.each(function() {\n\t\ttypes.add($(this).attr('data-type'));\n\t\ttags.add($(this).attr('data-tag'));\n\t});\n\n\ttypes.forEach(function(value) {\n\t\t$filterType.append(new Option(value, value));\n\t});\n\n\ttags.forEach(function(value) {\n\t\t$filterTag.append(new Option(value, value));\n\t});\n\n\t$filterType.on('change', function() {\n\t\tfilterTypeValue = $(this).val();\n\t\tfilterResources();\n\t});\n\n\t$filterTag.on('change', function() {\n\t\tfilterTagValue = $(this).val();\n\t\tfilterResources();\n\t});\n\n\t$filterFulltext.on('keyup', function() {\n\t\tfilterFulltextValue = $(this).val();\n\t\tfilterResources();\n\t});\n\n\t$showMore.on('click', function() {\n\t\tfilterResources();\n\t\t$(this).addClass('d-none');\n\t});\n\n\tfunction filterResources() {\n\t\tvar visibleElements = 0;\n\t\t$resource.each(function() {\n\t\t\tvar type = $(this).data('type');\n\t\t\tvar tag = $(this).data('tag');\n\n\t\t\tvar foundInFulltext = \n\t\t\t\t$(this).find('.card-title').text().toLowerCase().indexOf(filterFulltextValue.toLowerCase()) > -1 \n\t\t\t\t|| \n\t\t\t\t$(this).find('.card-text').text().toLowerCase().indexOf(filterFulltextValue.toLowerCase()) > -1;\n\n\t\t\tif ((filterTypeValue === 'all' || type === filterTypeValue) && (filterTagValue === 'all' || tag === filterTagValue) && (filterFulltextValue == '' || foundInFulltext)) {\n\t\t\t\tvisibleElements++;\n\t\t\t\t$(this).removeClass('d-none');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t$(this).addClass('d-none');\n\t\t});\n\n\t\t$showMore.addClass('d-none');\n\t\tvisibleElements === 0 ? $emptyElement.removeClass('d-none') : $emptyElement.addClass('d-none');\t\t\n\t}\n})();\n"]}