Skip to content

Instantly share code, notes, and snippets.

@vladimmi
Created December 11, 2015 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladimmi/15b3a85e3dad8b1795ea to your computer and use it in GitHub Desktop.
Save vladimmi/15b3a85e3dad8b1795ea to your computer and use it in GitHub Desktop.
JCSmartFilter.prototype.postHandler = function (result, fromCache)
{
var hrefFILTER, url, curProp;
var modef = BX('modef');
var modef_num = BX('modef_num');
console.log('post handler');
if (!!result && !!result.ITEMS)
{
for(var PID in result.ITEMS)
{
if (result.ITEMS.hasOwnProperty(PID))
{
this.updateItem(PID, result.ITEMS[PID]);
}
}
if (!!modef && !!modef_num)
{
modef_num.innerHTML = result.ELEMENT_COUNT;
hrefFILTER = BX.findChildren(modef, {tag: 'A'}, true);
if (result.FILTER_URL && hrefFILTER)
{
hrefFILTER[0].href = BX.util.htmlspecialcharsback(result.FILTER_URL);
}
if (result.FILTER_AJAX_URL && result.COMPONENT_CONTAINER_ID)
{
BX.unbindAll(hrefFILTER[0]);
BX.bind(hrefFILTER[0], 'click', function(e)
{
url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
return BX.PreventDefault(e);
});
}
if (result.INSTANT_RELOAD && result.COMPONENT_CONTAINER_ID)
{
url = BX.util.htmlspecialcharsback(result.FILTER_AJAX_URL);
BX.ajax.insertToNode(url, result.COMPONENT_CONTAINER_ID);
}
else
{
if (modef.style.display === 'none')
{
modef.style.display = 'inline-block';
}
if (this.viewMode == "VERTICAL")
{
curProp = BX.findChild(BX.findParent(this.curFilterinput, {'class':'bx-filter-parameters-box'}), {'class':'bx-filter-container-modef'}, true, false);
curProp.appendChild(modef);
}
if (result.SEF_SET_FILTER_URL)
{
this.bindUrlToButton('set_filter', result.SEF_SET_FILTER_URL);
}
}
}
}
if (this.sef)
{
var set_filter = BX('set_filter');
set_filter.disabled = false;
}
if (!fromCache && this.cacheKey !== '')
{
this.cache[this.cacheKey] = result;
}
this.cacheKey = '';
console.log('cache key cleared');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment