1(function( $ ) { 2 'use strict'; 3 4 $(function() { 5 var $matching = $(); // filtering matching elements 6 7 /* 8 * Build Regular expression for filtering. 9 * It consider even the other group filter's regular expressions 10 */ 11 $.fn.buildMatching = function() { 12 var filter_text = $(this).val(); 13 var filter_type = $(this).data('filter-type'); 14 var filter_group = $(this).data('filter-group'); 15 var filter_selector = $(this).data('filter-selector'); 16 var container_selector = $(this).data('container-selector'); 17 var effect_selector = $(this).data('effect-selector'); 18 19 var $filter_object = $(this); 20 var $group_items = $(); 21 22 // if there's some text 23 if ( filter_text.length > 0 ) { 24 // check filter type 25 switch (filter_type) { 26 case 'startWithText': 27 filter_text = '^' + filter_text; 28 break; 29 case 'endWithText': 30 filter_text = filter_text + '$'; 31 break; 32 default: 33 } 34 } 35 // build regular expression 36 var reg_exp = new RegExp(filter_text, 'i'); 37 38 // for each filterable element 39 $(container_selector).find(filter_selector).each(function() { 40 // if not found 41 if ( $(this).text().search(reg_exp) < 0 ) { 42 // removes from matched list 43 $matching = $matching.not( $(this).closest(effect_selector) ); 44 } else { 45 // if found add to matched list 46 $matching = $matching.add( $(this).closest(effect_selector) ); 47 } 48 }); 49 50 // if there is a group 51 if (filter_group != '') { 52 // get all other filters into the same group 53 $(".wplcf-filter[data-filter-group='" + filter_group + "']").each( function () { 54 // if the object is not the current filter 55 if (! $filter_object.is($(this))) { 56 // add to group list 57 $group_items = $group_items.add( $(this) ); 58 } 59 }); 60 61 // if there are other filters in the same group 62 if ($group_items.length > 0) { 63 // for each filter into the group 64 $group_items.each(function() { 65 var group_filter_text = $(this).val(); 66 var group_filter_type = $(this).data('filter-type'); 67 var group_filter_selector = $(this).data('filter-selector'); 68 var group_container_selector = $(this).data('container-selector'); 69 var group_effect_selector = $(this).data('effect-selector'); 70 71 // if there's some text 72 if ( group_filter_text.length > 0 ) { 73 // check filter type 74 switch (group_filter_type) { 75 case 'startWithText': 76 group_filter_text = '^' + group_filter_text; 77 break; 78 case 'endWithText': 79 group_filter_text = group_filter_text + '$'; 80 break; 81 default: 82 } 83 } 84 // build regular expression 85 var reg_exp = new RegExp(group_filter_text, 'i'); 86 87 // for each filterable element 88 $(group_container_selector).find(group_filter_selector).each(function() { 89 // if not found 90 if ( $(this).text().search(reg_exp) < 0 ) { 91 // removes from matched list 92 $matching = $matching.not( $(this).closest(group_effect_selector) ); 93 } 94 }); 95 }); 96 } 97 } 98 }; 99 100 /* 101 * Initialize filter 102 */ 103 $('.wplcf-container .wplcf-filter').each(function() { 104 var container_selector = $(this).data('container-selector'); 105 var effect_selector = $(this).data('effect-selector'); 106 var filter_selector = $(this).data('filter-selector'); 107 var layout_type = $(this).data('layout-type'); 108 var uid = $(this).data('uid'); 109 110 // for each element to be filtered 111 $(container_selector).find(filter_selector).each( function() { 112 var $target = $(this); 113 114 // if the effect is to be applied on a different element 115 if (effect_selector != filter_selector) { 116 // get the effect element 117 $target = $(this).closest(effect_selector); 118 } 119 // create the order data to let MixItUp plugin to filter 120 $target.attr('data-wplcf-order-' + uid, $(this).text()); 121 }); 122 123 $(container_selector).find(effect_selector).addClass('wplcf-target'); 124 125 var miu_display = 'inline-block'; 126 if (layout_type == 'table') { 127 miu_display = 'table-row'; 128 } 129 130 $(container_selector).mixItUp({ 131 animation: { 132 duration: mixitup.duration, 133 effects: mixitup.effects, 134 easing: mixitup.ease, 135 animateChangeLayout: true, 136 animateResizeTargets: true, 137 }, 138 selectors: { 139 target: '.wplcf-target', 140 }, 141 layout: { 142 display: miu_display, 143 containerClass: layout_type, 144 }, 145 }); 146 }); 147 148 $('.wplcf-container-button .wplcf-filter').each(function() { 149 var container_selector = $(this).data('container-selector'); 150 var effect_selector = $(this).data('effect-selector'); 151 var filter_selector = $(this).data('filter-selector'); 152 var layout_type = $(this).data('layout-type'); 153 var uid = $(this).data('uid'); 154 155 // for each element to be filtered 156 $(container_selector).find(filter_selector).each( function() { 157 var $target = $(this); 158 159 // if the effect is to be applied on a different element 160 if (effect_selector != filter_selector) { 161 // get the effect element 162 $target = $(this).closest(effect_selector); 163 } 164 // create the order data to let MixItUp plugin to filter 165 //$target.attr('data-wplcf-order-' + uid, $(this).text()); 166 $target.addClass($(this).text()); 167 }); 168 169 $(container_selector).find(effect_selector).addClass('wplcf-target'); 170 171 var miu_display = 'inline-block'; 172 if (layout_type == 'table') { 173 miu_display = 'table-row'; 174 } 175 176 $(container_selector).mixItUp({ 177 animation: { 178 duration: mixitup.duration, 179 effects: mixitup.effects, 180 easing: mixitup.ease, 181 animateChangeLayout: true, 182 animateResizeTargets: true, 183 }, 184 selectors: { 185 target: '.wplcf-target', 186 filter: '.wplcf-filter li', 187 }, 188 layout: { 189 display: miu_display, 190 containerClass: layout_type, 191 }, 192 controls: { 193 activeClass: 'selected', 194 }, 195 }); 196 }); 197 198 /* 199 * Fired when user start to write into the filter box 200 */ 201 $('.wplcf-container .wplcf-filter').on('keyup', function(e) { 202 var filter_text = $(this).val(); 203 var container_selector = $(this).data('container-selector'); 204 205 // build matching elements 206 $(this).buildMatching(); 207 208 // filter all matching elements 209 $(container_selector).mixItUp('filter', $matching); 210 211 }); 212 213 /* 214 * Fired when user click on a filter button 215 */ 216 /* 217 $('.wplcf-container-button .wplcf-filter li').on('click', function(e) { 218 //console.log(this); 219 //var filter_text = $(this).data('filter'); 220 221 // build matching elements 222 //$(this).buildMatching(); 223 224 //var container_selector = $(this).data('container-selector'); 225 226 //$(this).addClass('selected'); 227 228 // filter all matching elements 229 //$(container_selector).mixItUp(); 230 231 232 }); 233*/ 234 235 /* 236 * Initialize filter buttons positions (not in CSS for IE compatibility) 237 */ 238 $('.wplcf-container, .wplcf-container-button').each(function() { 239 $(this).children('.wplcf-button').each(function( index, value) { 240 $(this).css('right', (index * 24) + 4); 241 }); 242 }); 243 244 /* 245 * Fired when user click the sort button 246 */ 247 $('.wplcf-container .wplcf-sort').on('click', function() { 248 var container_selector = $(this).data('container-selector'); 249 var sort_order = $(this).data('sort'); 250 var sort_icon = 'dashicons-arrow-up'; 251 var $current_filter = $(this).parent().find('.wplcf-filter'); 252 var filter_group = $current_filter.data('filter-group'); 253 254 var sort_array = sort_order.split(':'); 255 256 // check sorting "direction" 257 switch (sort_array[1]) { 258 case 'asc': 259 sort_order = sort_array[0] + ':desc'; 260 $(this).toggleClass('dashicons-arrow-up').toggleClass('dashicons-arrow-down'); 261 break; 262 case 'desc': 263 sort_order = sort_array[0] + ':asc'; 264 $(this).toggleClass('dashicons-arrow-up').toggleClass('dashicons-arrow-down'); 265 break; 266 default: 267 sort_order = sort_array[0] + ':asc'; 268 $(this).removeClass('dashicons-sort').addClass('dashicons-arrow-up'); 269 break; 270 } 271 272 273 // if theres a group 274 if (filter_group != '') { 275 276 // get all other filters into the same group 277 $(".wplcf-container .wplcf-filter[data-filter-group='" + filter_group + "']").each( function () { 278 // if the object is not the current filter 279 if (! $current_filter.is($(this))) { 280 // reset sorting options 281 var $sort_button = $(this).parent().children('.wplcf-sort'); 282 var temp_array = $sort_button.data('sort').split(':'); 283 $sort_button.data('sort', temp_array[0] + ':none'); 284 $sort_button.removeClass('dashicons-arrow-up dashicons-arrow-down').addClass('dashicons-sort'); 285 } 286 }); 287 } 288 289 $(container_selector).mixItUp('sort', sort_order); 290 $(this).data('sort', sort_order); 291 }); 292 293 /* 294 * Initialize presets list 295 */ 296 $('.wplcf-container .wplcf-presets-list').hide(); 297 298 /* 299 * Fired when user click the presets icon 300 */ 301 $('.wplcf-container .wplcf-presets').on('click', function() { 302 var presets_list = $(this).children('.wplcf-presets-list'); 303
304 if (presets_list.css('display') == 'none') { 305 presets_list.css('display', 'block'); 306 } else { 307 presets_list.css('display', 'none'); 308 } 309 }); 310 311 /* 312 * Fired when user click the presets item 313 */ 314 $('.wplcf-container .wplcf-presets-list li').on('click', function() { 315 var presets_value = $(this).text(); 316 var filter_box = $(this).closest('.wplcf-wrapper').find('.wplcf-filter'); 317 318 filter_box.val(presets_value); 319 filter_box.trigger('keyup'); 320 }); 321 322 /* 323 * Fired when user click on the toggle layout button 324 */ 325 $('.wplcf-container .wplcf-layout').on('click', function() { 326 var container_selector = $(this).data('container-selector'); 327 var layout = $(this).data('layout'); 328 329 $(this).toggleClass('dashicons-list-view').toggleClass('dashicons-grid-view'); 330 331 if( layout == 'list' ) { 332 $(this).data('layout', 'grid'); 333 $(container_selector).mixItUp('changeLayout', { 334 containerClass: 'grid', 335 }); 336 } else { 337 $(this).data('layout', 'list'); 338 $(container_selector).mixItUp('changeLayout', { 339 containerClass: 'list', 340 }); 341 } 342 }); 343 344 /* 345 * Fired when user click on the clear filter icon 346 */ 347 $('.wplcf-container .wplcf-clear').on('click', function() { 348 var $filter_object = $(this).parent().children('.wplcf-filter'); 349 350 console.log($filter_object); 351 352 var container_selector = $(this).data('container-selector'); 353 354 $filter_object.val(''); 355 356 $(container_selector).mixItUp('filter', 'all'); 357 }); 358 359 /* 360 * Fired when user click on the clear filter icon with multiple filters 361 */ 362 $('.wplcf-container .wplcf-group-clear').on('click', function() { 363 var $filter_object = $(this).parent().children('.wplcf-filter'); 364 365 $filter_object.val('').trigger('keyup'); 366 }); 367 368 /* 369 * Fired when user click on the clear all filters icon with multiple filter 370 */ 371 $('.wplcf-container .wplcf-group-all-clear').on('click', function() { 372 var $filter_object = $(this).parent().children('.wplcf-filter'); 373 var $group_items = $(); 374 375 //var container_selector = $(this).data('container-selector'); 376 var filter_group = $filter_object.data('filter-group'); 377 378 // get all other filters into the same group 379 $(".wplcf-filter[data-filter-group='" + filter_group + "']").each( function () { 380 // if the object is not the current filter 381 if (! $filter_object.is($(this))) { 382 // add to group list 383 $group_items = $group_items.add( $(this) ); 384 } 385 }); 386 $group_items.trigger('keyup'); 387 388 $(container_selector).mixItUp('filter', 'all'); 389 }); 390 391 }); 392})( 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.