# HG changeset patch # User Katia Saurfelt # Date 1247131024 -7200 # Node ID 923111e6ab333af5b2949a5794c1bf8b9b6bbfdd # Parent 6db26d081c3771c25403368d75586302fc1f16d6 do nothing if the clicked facet has facetValueDisabled class; do not move facet when cubicweb:idx == 0 diff -r 6db26d081c37 -r 923111e6ab33 web/data/cubicweb.formfilter.js --- a/web/data/cubicweb.formfilter.js Thu Jul 09 09:42:44 2009 +0200 +++ b/web/data/cubicweb.formfilter.js Thu Jul 09 11:17:04 2009 +0200 @@ -126,6 +126,9 @@ }); facet.find('div.facetCheckBox').click(function () { var $this = jQuery(this); + if ($this.hasClass('facetValueDisabled')){ + return + } if ($this.hasClass('facetValueSelected')) { $this.removeClass('facetValueSelected'); $this.find('img').each(function (i){ @@ -139,16 +142,19 @@ } }); var index = parseInt($this.attr('cubicweb:idx')); - var shift = jQuery.grep(facet.find('.facetValueSelected'), function (n) { - var nindex = parseInt(n.getAttribute('cubicweb:idx')); - return nindex > index; - }).length; - index += shift; - var parent = this.parentNode; - var $insertAfter = jQuery(parent).find('.facetCheckBox:nth('+index+')'); - if ( ! ($insertAfter.length == 1 && shift == 0) ) { - // only rearrange element if necessary - $insertAfter.after(this); + // we dont need to move the element when cubicweb:idx == 0 + if (index > 0){ + var shift = jQuery.grep(facet.find('.facetValueSelected'), function (n) { + var nindex = parseInt(n.getAttribute('cubicweb:idx')); + return nindex > index; + }).length; + index += shift; + var parent = this.parentNode; + var $insertAfter = jQuery(parent).find('.facetCheckBox:nth('+index+')'); + if ( ! ($insertAfter.length == 1 && shift == 0) ) { + // only rearrange element if necessary + $insertAfter.after(this); + } } } else { var lastSelected = facet.find('.facetValueSelected:last');