1(function(jQuery) { 2 3 jQuery.fn.zffParams = function(options) { 4 5 var url; 6 7 function init($obj) { 8 var defaults = { 9 'module' : 'front', 10 } 11 var settings = $.extend({}, defaults, options); 12 url = window.location.href; 13 $obj.find('.filter.form-control').on('keypress', function (e) { 14 e.stopImmediatePropagation(); 15 if( e.which == 13 ) { 16 17 var datas = $obj.find(':input'); 18 var name = $(this).attr('name'); 19 var value = $(this).val(); 20 if(settings.module == 'front') { 21 addQueryParam(name,value); 22 }else { 23 addQueryParams(datas); 24 } 25 window.location.href = url; 26 } 27 }); 28 $obj.find('.sorting.sortable, .sorting_asc.sortable, .sorting_desc.sortable').on('click', function (e) { 29 e.stopImmediatePropagation(); 30 var valueColumn = $(this).attr('data-column'); 31 var valueOrder = $(this).attr('data-order'); 32 addQueryParam('zfTableColumn',valueColumn); 33 addQueryParam('zfTableOrder',valueOrder); 34 window.location.href = url; 35 }); 36 37 $obj.find('.itemPerPage.form-control').on('change', function(e){ 38 e.stopImmediatePropagation(); 39 addQueryParam('zfTableItemPerPage', $(this).val()); 40 window.location.href = url; 41 }); 42 43 44 $obj.find('input[type="text"]').each(function(index,input){ 45 if($(input).val() !== ''){ 46 $(input).after("<span \n\ 47 style='color: #707070;cursor: pointer;right: 8px;position: absolute;top: 10px;' \n\ 48 class='glyphicon glyphicon-remove-circle remove-text' \n\ 49 data-input="+$(input).prop('name')+"></span>" 50 ); 51 $(input).parent().css({ 52 "position": "relative", 53 }); 54 } 55 }); 56 $obj.find('.remove-text').on('click',function(e){ 57 e.preventDefault(); 58 removeQueryParam(jQuery(this).data('input')); 59 jQuery(this).hide(); 60 window.location.href = url; 61 }); 62 $obj.find('select.filter').on('change',function(e){ 63 e.preventDefault(); 64 // TEXV2-5180 : une liste a choix multiple ne recharge PAS a chaque clic â on choisit 65 // plusieurs valeurs puis on valide avec « Filtrer ». Les listes simples des autres 66 // listings gardent le rechargement immediat. 67 if($(this).hasClass('zf-filter-multi')) { 68 return; 69 } 70 if(settings.module == 'front') { 71 addQueryParam($(this).attr('name'), $(this).val()); 72 }else { 73 var datas = $obj.find(':input'); 74 addQueryParams(datas); 75 } 76 window.location.href = url; 77 }); 78 // TEXV2-5180 : « Filtrer » applique d'un coup tout le bandeau (listes multiples, champs 79 // texte et cases « Exclure »). La touche Entree d'un champ texte fait la meme chose. 80 $obj.find('.zf-filter-apply').on('click',function(e){ 81 e.preventDefault(); 82 addQueryParams($obj.find(':input')); 83 window.location.href = url; 84 }); 85 // TEXV2-5203 : « Export » part exactement des MÃMES filtres que « Filtrer » â même 86 // collecte, même URL, seule la destination change. L'export ne peut donc pas porter 87 // d'autres filtres que la liste affichée. Le téléchargement lui-même est l'affaire du 88 // listing (listing-cards.js), qui écoute cet évènement : ici on ne fabrique que l'URL. 89 $obj.find('.zf-filter-export').on('click',function(e){ 90 e.preventDefault(); 91 addQueryParams($obj.find(':input')); 92 var query = url.indexOf('?') >= 0 ? url.substring(url.indexOf('?')) : ''; 93 $(this).trigger('zff:export', [$(this).data('url') + query]); 94 }); 95 $obj.find('.zt-range').on('click',function(e){ 96 e.preventDefault(); 97 if(settings.module == 'front') { 98 $(this).prev().find('.filter').each(function(){ 99 if($(this).val() != '') { 100 addQueryParam($(this).attr('name'), $(this).val()); 101 } 102 }); 103 }else { 104 var datas = $obj.find(':input'); 105 addQueryParams(datas); 106 window.location.href = url; 107 } 108 109 }); 110 } 111 112 this.removeQueryParam = removeQueryParam = function(key) { 113 114 var urlSplit = url.split('?'); 115 var params = (urlSplit[1]) ? urlSplit[1] : null; 116 var urlClean = urlSplit[0].split('#')[0]; 117 var urlReturn = urlClean; 118 if (params != null) { 119 params = params.split('&'); 120 var separator = '?'; 121 var useNew = false;
122 params.forEach(function (param) { 123 var dataParam = param.split('='); 124 if (dataParam[0] == key) { 125 } else { 126 urlReturn = urlReturn + separator + dataParam[0] + '=' + dataParam[1]; 127 separator = '&'; 128 } 129 130 }); 131 } 132 url = urlReturn; 133 } 134 this.reset = reset = function(){ 135 url = url.split('?')[0]; 136 } 137 this.reload = reload = function(){ 138 window.location.href = url; 139 } 140 this.addQueryParams = addQueryParams = function(datas) { 141 var urlSplit = url.split('?'); 142 var urlClean = urlSplit[0].split('#')[0]; 143 var separator = '?'; 144 var urlReturn = urlClean; 145 var filtersUnauthorirized = ['zfTablePage', 'zfTableOrder', 'zfTableItemPerPage', 'count']; 146 datas.each(function(){ 147 var name = $(this).attr('name'); 148 var value = $(this).val(); 149 // TEXV2-5180 : une case a cocher (drapeau « Exclure » des filtres) porte sa valeur 150 // meme decochee â sans cette garde, le filtre serait toujours inverse. 151 if($(this).is(':checkbox, :radio') && !$(this).is(':checked')) { 152 return; 153 } 154 // TEXV2-5180 : une liste a choix multiple renvoie un tableau, et null quand rien 155 // n'est selectionne (sans quoi l'URL recevait la chaine « null »). 156 if($.isArray(value)) { 157 value = value.join(','); 158 } 159 if(value == null) { 160 value = ''; 161 } 162 if(value != '' && name != null && filtersUnauthorirized.indexOf(name) == -1) { 163 urlReturn = urlReturn + separator + name + '=' + value; 164 separator = '&'; 165 } 166 }); 167 // TEXV2-5215 : un bandeau validé SANS aucun filtre doit rester distinguable d'une 168 // arrivee nue. Sans ce marqueur, les filtres memorises par l'utilisateur (TEXV2-5180) 169 // se reappliquent cote serveur et plus rien ne peut etre efface. 170 if(urlReturn.indexOf('zff_') == -1) { 171 urlReturn = urlReturn + separator + 'zff_clear=1'; 172 } 173 url = urlReturn; 174 } 175 this.addQueryParam = addQueryParam = function(newKey, newValue) { 176 var urlSplit = url.split('?'); 177 var params = (urlSplit[1]) ? urlSplit[1] : null; 178 var urlClean = urlSplit[0].split('#')[0]; 179 180 if (params == null) { 181 url = urlClean + '?' + newKey + '=' + newValue; 182 } else { 183 params = params.split('&'); 184 var separator = '?'; 185 var useNew = false; 186 var urlReturn = urlClean; 187 params.forEach(function (param) { 188 var dataParam = param.split('='); 189 if (dataParam[0] == 'zfTablePage') { 190 dataParam[1] = 1; 191 } 192 if(dataParam[1] != '') { 193 if (dataParam[0] == newKey) { 194 if(newValue != '') { 195 urlReturn = urlReturn + separator + newKey + '=' + newValue 196 useNew = true; 197 separator = '&'; 198 } 199 } else { 200 urlReturn = urlReturn + separator + dataParam[0] + '=' + dataParam[1]; 201 separator = '&'; 202 } 203 } 204 }); 205 if (!useNew) { 206 if(newValue != '') { 207 urlReturn = urlReturn + separator + newKey + '=' + newValue; 208 } 209 } 210 url = urlReturn; 211 } 212 } 213 214 this.setUrl = function(page){ 215 var position = url.indexOf(page); 216 if(position == -1) { 217 var urlSplit = url.split('?'); 218 var urlRetourn = urlSplit[0] + page; 219 urlRetourn = urlRetourn.replace(/\/\//g,"/"); 220 if(urlRetourn.indexOf("http://") === -1) { 221 urlRetourn = urlRetourn.replace('http:/',"http://"); 222 } 223 if(urlRetourn.indexOf("https://") === -1) { 224 urlRetourn = urlRetourn.replace('https:/', "https://"); 225 } 226 url = urlRetourn; 227 } 228 } 229 230 return this.each(function() { 231 var $this = jQuery( this ); 232 init($this); 233 }); 234 }; 235})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.