equal
deleted
inserted
replaced
102 } |
102 } |
103 |
103 |
104 |
104 |
105 var SELECTED_IMG = baseuri()+"data/black-check.png"; |
105 var SELECTED_IMG = baseuri()+"data/black-check.png"; |
106 var UNSELECTED_IMG = baseuri()+"data/no-check-no-border.png"; |
106 var UNSELECTED_IMG = baseuri()+"data/no-check-no-border.png"; |
|
107 var UNSELECTED_BORDER_IMG = baseuri()+"data/black-unchecked.png"; |
107 |
108 |
108 function initFacetBoxEvents(root) { |
109 function initFacetBoxEvents(root) { |
109 // facetargs : (divid, vid, paginate, extraargs) |
110 // facetargs : (divid, vid, paginate, extraargs) |
110 root = root || document; |
111 root = root || document; |
111 jQuery(root).find('form').each(function () { |
112 jQuery(root).find('form').each(function () { |
114 // may changes and we must send its value when the callback is |
115 // may changes and we must send its value when the callback is |
115 // called, not when the page is initialized |
116 // called, not when the page is initialized |
116 var facetargs = form.attr('cubicweb:facetargs'); |
117 var facetargs = form.attr('cubicweb:facetargs'); |
117 if (facetargs !== undefined) { |
118 if (facetargs !== undefined) { |
118 form.submit(function() { |
119 form.submit(function() { |
119 buildRQL.apply(null, evalJSON(form.attr('cubicweb:facetargs'))); |
120 buildRQL.apply(null, evalJSON(form.attr('cubicweb:facetargs'))); |
120 return false; |
121 return false; |
121 }); |
122 }); |
122 form.find('div.facet').each(function() { |
123 form.find('div.facet').each(function() { |
123 var facet = jQuery(this); |
124 var facet = jQuery(this); |
124 facet.find('div.facetCheckBox').each(function (i) { |
125 facet.find('div.facetCheckBox').each(function (i) { |
126 }); |
127 }); |
127 facet.find('div.facetCheckBox').click(function () { |
128 facet.find('div.facetCheckBox').click(function () { |
128 var $this = jQuery(this); |
129 var $this = jQuery(this); |
129 if ($this.hasClass('facetValueSelected')) { |
130 if ($this.hasClass('facetValueSelected')) { |
130 $this.removeClass('facetValueSelected'); |
131 $this.removeClass('facetValueSelected'); |
131 $this.find('img').attr('src', UNSELECTED_IMG); |
132 $this.find('img').each(function (i){ |
|
133 if (this.getAttribute('cubicweb:unselimg')){ |
|
134 this.setAttribute('src', UNSELECTED_BORDER_IMG); |
|
135 } |
|
136 else{ |
|
137 this.setAttribute('src', UNSELECTED_IMG); |
|
138 } |
|
139 }); |
132 var index = parseInt($this.attr('cubicweb:idx')); |
140 var index = parseInt($this.attr('cubicweb:idx')); |
133 var shift = jQuery.grep(facet.find('.facetValueSelected'), function (n) { |
141 var shift = jQuery.grep(facet.find('.facetValueSelected'), function (n) { |
134 var nindex = parseInt(n.getAttribute('cubicweb:idx')); |
142 var nindex = parseInt(n.getAttribute('cubicweb:idx')); |
135 return nindex > index; |
143 return nindex > index; |
136 }).length; |
144 }).length; |
146 jQuery(parent).prepend(this); |
154 jQuery(parent).prepend(this); |
147 } |
155 } |
148 jQuery(this).addClass('facetValueSelected'); |
156 jQuery(this).addClass('facetValueSelected'); |
149 jQuery(this).find('img').attr('src', SELECTED_IMG); |
157 jQuery(this).find('img').attr('src', SELECTED_IMG); |
150 } |
158 } |
151 buildRQL.apply(null, evalJSON(form.attr('cubicweb:facetargs'))); |
159 buildRQL.apply(null, evalJSON(form.attr('cubicweb:facetargs'))); |
152 facet.find('.facetBody').animate({scrollTop: 0}, ''); |
160 facet.find('.facetBody').animate({scrollTop: 0}, ''); |
153 }); |
161 }); |
154 facet.find('select.facetOperator').change(function() { |
162 facet.find('select.facetOperator').change(function() { |
155 var nbselected = facet.find('div.facetValueSelected').length; |
163 var nbselected = facet.find('div.facetValueSelected').length; |
156 if (nbselected >= 2) { |
164 if (nbselected >= 2) { |