-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery-ptlinked_plugin.js
2905 lines (2702 loc) · 169 KB
/
jquery-ptlinked_plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* PTLINKED Plugin - Exercise Program Library
* Customer: MDVIP
* Version: 1.0.9
* Author: Mike Frank (PTLINKED, LLC.) - [email protected]
*
* Table of Contents
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* 1.0 CATEGORY SLIDER METHODS
* 1.1 Load Category Items in Sliderbar / Mobile Menu
* 1.2 Render Category Items
* 1.3 Set a Page Request Value
* 1.4 Clear Category Slider Html
* 1.5 Initialize Category Slider Mechanics
* 2.0 FILTER DROP DOWN METHODS
* 2.1 Initialize the Filter Drop Down Block
* 2.2 Initialize Clear Filters Handlers
* 2.3 Clear the Filter DOM Containers
* 2.4 Clear all Selected Filters
* 2.5 Clear all filters and search click handler
* 2.6 Clear Filter Click Handler
* 2.7 Load the Filters
* 2.8 Render the Filter Components
* 2.9 Refresh the Conditions drop down filter
* 2.10 Refresh the Custom Subcategories drop down filter
* 2.11 Set the filters based on the loaded criteria
* 2.12 Load the Custom Category Filter Block
* 2.13 Add/Remove bubbles from filter breadcrumb
* 3.0 SEARCH / SEARCH BAR METHODS
* 3.1 Initialize the textual search bar
* 3.2 Request Exercise Programs
* 3.3 Request Search Results from API End-Point
* 3.4 Render the returned exercise programs
* 3.5 Open selected exercise program
* 3.6 Process the Load More
* 4.0 EXERCISE VIEWER METHODS
* 4.1 Clear/Reset Viewer
* 4.2 Load Exercise Program
* 4.3 Render the exercise Program
* 4.4 Initialize the thumbnail bar
* 4.5 Initialize video source
* 4.6 Vide Player Click Handler
* 4.7 Thumbnail Anchor handler
* 4.8 Initialize the Hor. scroll mechanices
* 4.9 Initialize the Viewer Toolbar
* 5.0 RENDER METHODS
* 5.1 Render the plugin sections
* 5.2 Build mobile search panel HTML
* 5.3 Build Category Slider HTML
* 5.4 Build Filter/Search Bar and Drop Downs HTML
* 5.5 Build the plugin containers
* 5.6 Build the mobile filter menu
* 5.7 Build the Exercise Program Viewer Container
* 6.0 UTILITY METHODS
* 6.1 Toggle the mobile filter menu
* 6.2 Calculate the Exercise Program Card Placeholders
* 6.3 Toggle the info box
* 6.4 Initialize the content scroll monitor
* 6.5 Get Bootstrap Device Size
* 6.6 Load Page Request Parameters
* 6.7 Register the user/plugin with the API
* 6.8 Process URL Query Variables
*/
;(function($) {
var pluginName = 'ptlinkedLibrary';
/**
* Plugin object constructor.
* Implements the Revealing Module Pattern.
*/
function Plugin(element, options) {
// References to DOM and jQuery versions of element.
var el = element;
var $el = $(element);
// Extend default options with those supplied by user.
options = $.extend({}, $.fn[pluginName].defaults, options);
var selected_category_filter = 0 ; // Selected category Filter
var selected_filters = {} ; // Selected Filters
var __filter_timer ; // Filter timer variable
var __filter_delay = 500 ; // The set delay before the filter menu is displayed
var __page_request_values = {} ; // Page URL Parameters Array
var __page_request_query_values = {} ;
var __use_url_to_load = false ; // Flag to use URL loading of search and filters *** REMOVE ***
var __append_results = false ; // Flag to either append results from server to the result list, or clear and display result list
var __scroll_more = true ; // Flag that toggles the scroll more mechanics
var __save_state_cookie = true ; // Flag to save the search state (filters, category, query) in a cookie
var __processing = false ; // Flag that ensures not multiple service calls will be made at the same time
var __use_vanity_url = true ; // Vanity URL Flag *** NEED TO REMOVE ***
var current_index = 0 ; // Current page index
var record_chunks = 25 ; // Number of records to return
var __exercise_program_id = 0 ; // Currently selected exercise program id to display in viewer
var __exercise_program_code = '' ; // Currently selected exercise program code to display in viewer
var __error_detected = false ;
var __bodyregion_info = {} ;
// **********************************************************************************
// 1.0 CATEGORY SLIDER METHODS
// **********************************************************************************
// 1.1 Load Category Items in Sliderbar / Mobile Menu
function loadCategories( ) {
var url = options["api_root_url"] + "/predesigned/bodyregions/html" ;
var s = getBootstrapDeviceSize( );
if( s ) {
url = options["api_root_url"] + "/predesigned/bodyregions/html2" ;
}
$.ajax({
type: "GET",
url: url,
crossDomain: true,
headers: { 'token-authorization-x': options["api_key"], 'ptlinked-uid-x': options["user_uid"], 'ptlinked-utype-x': options["user_type"] },
dataType: "json",
error: function( jqXHR, textStatus, errorThrown ) {
if( options["debug_mode"] ) {
console.log( "::::: Load Categories AJAX :::::" ) ;
console.log( "Request Error or Timeout" ) ;
console.log( "Status Code: " + jqXHR["status"] ) ;
console.log( "Status Msg: " + jqXHR["statusText"] ) ;
console.log( "Response Msg: " + jqXHR["responseText"] ) ;
console.log( "::::: ===== ===== ===== ===== :::::" ) ;
}
__error_detected = true ;
toggle_info_box( "predesigned--sys_error", "CAT" + jqXHR["status"] + " - " + jqXHR["statusText"] ) ;
},
success: function( data, textStatus, jqXHR ) {
var s = getBootstrapDeviceSize( ) ;
if( s ) {
var mbodyregion = $("#predesigned_filters--bodyregion-mobile") ;
$.each( data, function( index, value ) {
mbodyregion.append( value ) ;
});
var highlight_image = options["assets_cdn"] + "bodyregion_highlights/bodyregion--empty.png" ;
var title_label = "All Programs" ;
$(".ptlinked--m_bodyregion_highlight").find( "img" ).attr( "src", highlight_image ) ;
$(".ptlinked--m_bodyregion_highlight").find( ".highlight-label" ).html( title_label ) ;
$(".ptlinked--m_bodyregion_highlight").show( ) ;
mbodyregion.select2( ) ;
mbodyregion.unbind( "select2:select").on('select2:select', function(e){
var oid = $("#predesigned_filters--bodyregion-mobile").val( ) ;
var custom_cat = $("#predesigned_filters--bodyregion-mobile").find( ":selected" ).data( "customcat" ) ;
if( custom_cat > 0 ) {
oid = oid.replace( "c-", "" ) ;
}
var title = $("#predesigned_filters--bodyregion-mobile").find(":selected").data("title") ;
var type = $("#predesigned_filters--bodyregion-mobile").find(":selected").data("type") ;
var cur_c = __page_request_values["c"] ;
var cur_c1 = __page_request_values["c1"] ;
var cur_f1 = __page_request_values["f1"] ;
var cur_f4 = __page_request_values["f4"] ;
if( cur_c != oid || cur_c1 != custom_cat ) {
var arr_types = __bodyregion_info[oid]["types"] ;
$("#predesigned_filters--types-mobile").html( "" ) ;
$("#predesigned_filters--types-mobile").html( '<option selected="" value="0">Type</option>' ) ;
for( var i = 0 ; i < arr_types.length ; i ++ ) {
var tmp = '<option data-oid="'+arr_types[i]["type_id"]+'" data-filter_label="'+arr_types[i]["title"]+'" data-filter_type="type" value="'+arr_types[i]["type_id"]+'">'+arr_types[i]["title"]+'</option>' ;
$("#predesigned_filters--types-mobile").append( tmp ) ;
}
$("#predesigned_filters--types-mobile").select2( ) ;
if( oid == 0 ) { filter_breadcrumb( cur_c, '', 'bodyregion', 'remove' ) ; }
setPageRequestValue( "c", oid ) ;
setPageRequestValue( "c1", custom_cat ) ;
if( custom_cat > 0 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
if( cur_f1 > 0 ) { setPageRequestValue( "f1", 0 ) ; }
if( cur_f4 > 0 ) { setPageRequestValue( "f4", 0 ) ; }
$("#predesigned_filters--conditions-mobile").val( 0 ).trigger( "change" ) ;
$("#predesigned_filters--types-mobile").val( 0 ).trigger( "change" ) ;
var highlight_image = options["assets_cdn"] + "bodyregion_highlights/bodyregion--empty.png" ;
var title_label = title ;
$(".ptlinked--m_bodyregion_highlight").find( "img" ).attr( "src", highlight_image ) ;
$(".ptlinked--m_bodyregion_highlight").find( ".highlight-label" ).html( title_label ) ;
$(".ptlinked--m_bodyregion_highlight").show( ) ;
} else {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
if( cur_f4 > 0 ) { setPageRequestValue( "f4", 0 ) ; }
var __item_found = false ;
__bodyregion_info[oid]["types"].forEach( function(item, index, arr){
if( item["type_id"] == cur_f1 ) {
__item_found = true ;
}
});
if( !__item_found ){
// Remove BreadCrumb
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
if( cur_f1 > 0 ) { setPageRequestValue( "f1", 0 ) ; }
$("#predesigned_filters--types-mobile").val( 0 ).trigger( "change" ) ;
} else {
$("#predesigned_filters--types-mobile").val( __page_request_values["f1"] ).trigger( "change" ) ;
}
$("#predesigned_filters--conditions").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
// Update highlight and label
var highlight_image = options["assets_cdn"] + "bodyregion_highlights/" + $("#predesigned_filters--bodyregion-mobile").find( ":selected" ).data( "highlight" ) ;
var title_label = $("#predesigned_filters--bodyregion-mobile").find( ":selected" ).data( "title" ) ;
$(".ptlinked--m_bodyregion_highlight").find( "img" ).attr( "src", highlight_image ) ;
$(".ptlinked--m_bodyregion_highlight").find( ".highlight-label" ).html( title_label ) ;
$(".ptlinked--m_bodyregion_highlight").show( ) ;
}
filter_breadcrumb( oid, title, type, 'add' ) ;
current_index = 0 ;
requestPrograms( ) ;
// Auto Close Mobile filter panel
if( $(".mobile-filter-panel").hasClass( "opened" ) ) {
$(".mobile-filter-panel").removeClass( "opened" ) ;
}
// Display or hide clear all filters link
var clear = mbodyregion.parent( ).parent().find( ".mobile-filter--clear" ) ;
if( oid == 0 ) {
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
// Reset Body Highlight
var highlight_image = options["assets_cdn"] + "bodyregion_highlights/bodyregion--empty.png" ;
var title_label = "All Programs" ;
$(".ptlinked--m_bodyregion_highlight").find( "img" ).attr( "src", highlight_image ) ;
$(".ptlinked--m_bodyregion_highlight").find( ".highlight-label" ).html( title_label ) ;
$(".ptlinked--m_bodyregion_highlight").show( ) ;
} else {
if( !clear.hasClass( "active" ) ) { clear.addClass( "active" ) ; }
}
}
});
} else {
renderCategories( data ) ;
}
}
});
}
// 1.2 Render Category Items
function renderCategories( html ) {
var category_filter_container = $("ul.category-bubbles-list") ;
$.each( html, function( index, value ) {
category_filter_container.append( value ) ;
});
var selected_item = category_filter_container.find( "li[data-oid=" + selected_category_filter + "]" ) ;
if( !selected_item.hasClass( "active-filter" ) ) {
selected_item.addClass( "active-filter" ) ;
}
initCategoryScrollMechanics( ) ; // Initialize the Scroll Mechanics
$("ul.category-bubbles-list li").unbind( "hover" ).hover( function(event){
event.stopPropagation( ) ;
var $this = $(this) ;
__filter_timer = setTimeout( function(){
calc_dropdown_position( $this ) ;
}, __filter_delay ) ;
}, function(){
clearTimeout( __filter_timer ) ;
});
$("ul.category-bubbles-list li").unbind( "click" ).on( "click", function(){
var oid = $(this).data( "oid" ) ;
var custom_cat = $(this).data( "customcat" ) ;
var title = $(this).data( "title" ) ;
var type = $(this).data( "type" ) ;
var cur_c = __page_request_values["c"] ;
var cur_c1 = __page_request_values["c1"] ;
var cur_f1 = __page_request_values["f1"] ;
var cur_f4 = __page_request_values["f4"] ;
if( cur_c != oid || cur_c1 != custom_cat ) {
setPageRequestValue( "c", oid ) ;
setPageRequestValue( "c1", custom_cat ) ;
if( custom_cat > 0 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
if( cur_f1 > 0 ) { setPageRequestValue( "f1", 0 ) ; }
if( cur_f4 > 0 ) { setPageRequestValue( "f4", 0 ) ; }
$("#predesigned_filters--conditions").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
$("#predesigned_filters--types li").removeClass( "selected" ) ;
} else {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
if( cur_f4 > 0 ) { setPageRequestValue( "f4", 0 ) ; }
var __item_found = false ;
__bodyregion_info[oid]["types"].forEach( function(item, index, arr){
if( item["type_id"] == cur_f1 ) {
__item_found = true ;
}
});
if( !__item_found ){
// Remove BreadCrumb
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
if( cur_f1 > 0 ) { setPageRequestValue( "f1", 0 ) ; }
$("#predesigned_filters--types li").removeClass( "selected" ) ;
// Select View All element in the type list
$("ul.filter--item_list li[data-oid='0']").addClass( "selected" ) ;
}
$("#predesigned_filters--conditions").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
}
filter_breadcrumb( oid, title, type, 'add' ) ;
current_index = 0 ;
requestPrograms( ) ;
$("ul.category-bubbles-list li").removeClass( "active-filter" ) ;
$(this).addClass( "active-filter" ) ;
}
});
}
// 1.3 Set a Page Request Value
function setPageRequestValue( key,value ) {
__page_request_values[key] = value ;
}
// 1.4 Clear Category Slider Html
function clearCategories( ) {
$("ul.category-bubbles-list").html( "" ) ;
}
// 1.5 Initialize Category Slider Mechanics
function initCategoryScrollMechanics( ) {
var _root = $(".scroll-container") ;
var scrollIncrement = 400 ;
var scrollContainer = $(_root).find( "ul.category-bubbles-list" ) ;
var leftScrollArrow = $(".scroll-container").find( ".left-arrow" ) ;
var rightScrollArrow = $(".scroll-container").find( ".right-arrow" ) ;
var scrollPosition = scrollContainer.scrollLeft( ) ;
var totalScrollWidth = scrollContainer.get(0).scrollWidth ;
var farRightOffset = 0 ;
$(rightScrollArrow).click(function() {
event.preventDefault();
// if filter drop down is visible, hide it
$(".ptlinked--filter_dropdown").removeClass( "show" ).delay( 500 ).removeClass( "display" ) ;
scrollContainer.animate({
scrollLeft: "+="+scrollIncrement+"px"
}, "slow", function(){
// Animation Complete
var scrollPosition = scrollContainer.scrollLeft( ) ;
var totalScrollWidth = scrollContainer.get(0).scrollWidth ;
if( scrollPosition > 0 ) {
if( !$(leftScrollArrow).hasClass( "show-arrow" ) ) {
$(leftScrollArrow).addClass( "show-arrow" ) ;
}
if( scrollPosition % scrollIncrement > 0 ) {
if( $(rightScrollArrow).hasClass( "show-arrow" ) ) {
$(rightScrollArrow).removeClass( "show-arrow" ) ;
}
farRightOffset = scrollPosition % scrollIncrement ;
}
}
});
});
$(leftScrollArrow).click(function() {
event.preventDefault();
// if filter drop down is visible, hide it
$(".ptlinked--filter_dropdown").removeClass( "show" ).delay( 500 ).removeClass( "display" ) ;
scrollContainer.animate({
scrollLeft: "-="+( scrollIncrement + farRightOffset )+"px"
}, "slow", function(){
// Animation Complete
farRightOffset = 0 ;
var scrollPosition = scrollContainer.scrollLeft( ) ;
var totalScrollWidth = scrollContainer.get(0).scrollWidth ;
if( scrollPosition <= 0 ) {
if( $(leftScrollArrow).hasClass( "show-arrow" ) ) {
$(leftScrollArrow).removeClass( "show-arrow" ) ;
}
if( !$(rightScrollArrow).hasClass( "show-arrow" ) ) {
$(rightScrollArrow).addClass( "show-arrow" ) ;
}
} else if( scrollPosition < (totalScrollWidth - scrollIncrement ) ) {
if( !$(rightScrollArrow).hasClass( "show-arrow" ) ) {
$(rightScrollArrow).addClass( "show-arrow" ) ;
}
}
});
});
}
// **********************************************************************************
// 2.0 FILTER DROP DOWN METHODS
// **********************************************************************************
// 2.1 Initialize the Filter Drop Down Block
function initFilterDropDown( ) {
$(".card--grid_filter").unbind( "click" ).on( "click", function(){
var $gf = $("#grid-filter") ;
if( $gf.hasClass( "open" ) ) {
$gf.removeClass( "open" ) ;
} else {
$gf.addClass( "open" ) ;
}
});
}
// 2.2 Initialize Clear Filters Handlers
function initClearFilters( ) {
var require_clear_all = false ;
var require_clear_all_mobile = false ;
var _is_mobile = false ;
if( $(".mobile-filter-panel").css( "display" ) != "none" ) {
_is_mobile = true ;
}
if( ( typeof __page_request_values["f1"] !== 'undefined' ) && __page_request_values["f1"] > 0 ) {
require_clear_all = true ;
}
if( ( typeof __page_request_values["f4"] !== 'undefined' ) && __page_request_values["f4"] > 0 ) {
require_clear_all = true ;
}
if( ( typeof __page_request_values["c1"] !== 'undefined' ) && __page_request_values["c1"] > 1 ) {
require_clear_all = true ;
}
if( _is_mobile ) {
if( ( typeof __page_request_values["c"] !== 'undefined' ) && __page_request_values["c"] > 0 ) {
require_clear_all = true ;
}
}
var $grid_filter_clear = $(".card--grid_filter_clear") ;
var $m_grid_filter_clear = $(".mobile--grid_filter_clear") ;
if( require_clear_all ) {
if( !$grid_filter_clear.hasClass( "active" ) ) {
$grid_filter_clear.addClass( "active" ) ;
}
$grid_filter_clear.unbind( "click" ).on( "click", clearAllFilters ) ;
if( !$m_grid_filter_clear.hasClass( "active" ) ) {
$m_grid_filter_clear.addClass( "active" ) ;
}
$m_grid_filter_clear.unbind( "click" ).on( "click", clearAllFilters ) ;
if( !$("#ptl-mobile_filter_button").hasClass( "active" ) ) {
$("#ptl-mobile_filter_button").addClass( "active" ) ;
}
} else {
if( $grid_filter_clear.hasClass( "active" ) ) {
$grid_filter_clear.removeClass( "active" ) ;
}
$grid_filter_clear.unbind( "click" ) ;
if( $m_grid_filter_clear.hasClass( "active" ) ) {
$m_grid_filter_clear.removeClass( "active" ) ;
}
$m_grid_filter_clear.unbind( "click" ) ;
if( $("#ptl-mobile_filter_button").hasClass( "active" ) ) {
$("#ptl-mobile_filter_button").removeClass( "active" ) ;
}
}
}
// 2.3 Clear the Filter DOM Containers
function clearFilters( ) {
$("#predesigned_filters--types").html( "" ) ;
}
// 2.4 Clear all Selected Filters
function clearAllFilters( e ) {
if( $(".navbar-mobile--search_panel").css( "display" ) != "none" ) {
__page_request_values["c"] = 0 ;
__page_request_values["c1"] = 0 ;
}
if( __page_request_values["c1"] > 0 ) {
__page_request_values["c1"] = 1 ;
} else {
__page_request_values["c1"] = 0 ;
}
__page_request_values["f1"] = 0 ;
__page_request_values["f4"] = 0 ;
current_index = 0 ;
selected_filters = {
bodyregion: {},
type: {},
condition: {}
};
var _p = $(".predesigned--filter_crumbtrail") ;
var _p_m = $(".mobile-predesigned--filter_crumbtrail") ;
_p.html( "" ) ;
_p_m.html( "" ) ;
setFilters( ) ;
requestPrograms( ) ;
}
// 2.5 Clear all filters and search click handler
function clearAllSearchState( e ) {
predesigned_controller.clear_category_filters( ) ;
predesigned_controller.clear_filters( ) ;
predesigned_controller.load_body_regions( ) ;
predesigned_controller.load_filters( ) ;
$("#header-search").val( "" ) ;
$("#mheader-search").val( "" ) ;
if( $(".header-search-bar-clear").hasClass( "active" ) ) {
$(".header-search-bar-clear").removeClass( "active" ) ;
}
if( $(".card--grid_filter_clear").hasClass( "active" ) ) {
$(".card--grid_filter_clear").removeClass( "active" ) ;
}
if( $(".ptl-mobile_search_button").hasClass( "active" ) ) {
$(".ptl-mobile_search_button").removeClass( "active" ) ;
}
if( $(".mheader-search-bar-clear").hasClass( "active" ) ) {
$(".mheader-search-bar-clear").removeClass( "active" ) ;
}
$(".card--grid_filter_clear").unbind( "click" ) ;
// Reset all page request flags
__page_request_values["c"] = 0 ; // Selected Category
__page_request_values["c1"] = 0 ; // Is custom category
__page_request_values["v"] = "" ; // Search String
__page_request_values["f1"] = 0 ; // Type Filter
__page_request_values["f4"] = 0 ; // Condition Filter
//Cookies.remove('ptlinkedQueryState');
Cookies.remove('ptlinkedQueryState', { path: '/', domain: '.ptlinked.com', secure: true } ) ;
setFilters( ) ;
routeQuery( ) ;
}
// 2.6 Clear Filter Click Handler
function handleClearFilter( e ) {
var drop_down_id = $(this).parent( ).find( "select" ).attr( "id" ) ;
var param_f = $(this).parent( ).find( ".mobile-filter--value").data( "f" ) ;
if( drop_down_id == "predesigned_filters--subcategories-mobile" || drop_down_id == "predesigned_filters--subcategories" ) {
$("#" + drop_down_id).val( 1 ).trigger( "change" ) ;
} else {
$("#" + drop_down_id).val( 0 ).trigger( "change" ) ;
}
if( $(this).hasClass( "active" ) ) {
$(this).removeClass( "active" ) ;
}
__page_request_values[param_f] = 0 ;
if( param_f == 'c' ) {
__page_request_values['c1'] = 0 ;
} else if( param_f == 'c1' ) {
__page_request_values['c1'] = 1 ;
}
if( drop_down_id == "predesigned_filters--conditions-mobile" ) {
$("#predesigned_filters--types-mobile").val( 0 ).trigger( "change" ) ;
if( $("#predesigned_filters--types-mobile").parent().parent().find(".mobile-filter--clear").hasClass( "active" ) ) {
$("#predesigned_filters--types-mobile").parent().parent().find(".mobile-filter--clear").removeClass( "active" ) ;
}
__page_request_values["f1"] = 0 ;
} else if( drop_down_id == "predesigned_filters--types-mobile" ) {
$("#predesigned_filters--conditions-mobile").val( 0 ).trigger( "change" ) ;
if( $("#predesigned_filters--conditions-mobile").parent().parent().find(".mobile-filter--clear").hasClass( "active" ) ) {
$("#predesigned_filters--conditions-mobile").parent().parent().find(".mobile-filter--clear").removeClass( "active" ) ;
}
__page_request_values["f4"] = 0 ;
}
current_index = 0 ;
if( $(".mobile-filter-panel").hasClass( "opened" ) ) {
$(".mobile-filter-panel").removeClass( "opened" ) ;
}
requestPrograms( ) ;
}
// 2.7 Load the Filters
function loadFilters( ) {
var url = options["api_root_url"] + "/predesigned/filters/html" ;
var s = getBootstrapDeviceSize( );
if( s ) {
url = options["api_root_url"] + "/predesigned/filters/html2" ;
}
$.ajax({
type: "GET",
crossDomain: true,
headers: { 'token-authorization-x': options["api_key"], 'ptlinked-uid-x': options["user_uid"], 'ptlinked-utype-x': options["user_type"] },
url: url,
dataType: "json",
error: function( jqXHR, textStatus, errorThrown ) {
if( options["debug_mode"] ) {
console.log( "::::: Load Filters AJAX :::::" ) ;
console.log( "Request Error or Timeout" ) ;
console.log( "Status Code: " + jqXHR["status"] ) ;
console.log( "Status Msg: " + jqXHR["statusText"] ) ;
console.log( "Response Msg: " + jqXHR["responseText"] ) ;
console.log( "::::: ===== ===== ===== ===== :::::" ) ;
}
__error_detected = true ;
toggle_info_box( "predesigned--sys_error", "FIL" + jqXHR["status"] + " - " + jqXHR["statusText"] ) ;
},
success: function( data, textStatus, jqXHR ) {
renderFilters( data ) ;
}
});
}
// 2.7b Load the Filters
function loadFilterLookups( ) {
var url = options["api_root_url"] + "/predesigned/bodyregions/lookup" ;
$.ajax({
type: "GET",
crossDomain: true,
headers: { 'token-authorization-x': options["api_key"], 'ptlinked-uid-x': options["user_uid"], 'ptlinked-utype-x': options["user_type"] },
url: url,
dataType: "json",
error: function( jqXHR, textStatus, errorThrown ) {
if( options["debug_mode"] ) {
console.log( "::::: Load Filters AJAX :::::" ) ;
console.log( "Request Error or Timeout" ) ;
console.log( "Status Code: " + jqXHR["status"] ) ;
console.log( "Status Msg: " + jqXHR["statusText"] ) ;
console.log( "Response Msg: " + jqXHR["responseText"] ) ;
console.log( "::::: ===== ===== ===== ===== :::::" ) ;
}
__error_detected = true ;
toggle_info_box( "predesigned--sys_error", "FIL" + jqXHR["status"] + " - " + jqXHR["statusText"] ) ;
},
success: function( data, textStatus, jqXHR ) {
__bodyregion_info = data ;
}
});
}
// 2.8 Render the Filter Components
function renderFilters( html ) {
// Types
var types = $("ul.filter--item_list") ;
var mtypes = $("#predesigned_filters--types-mobile") ;
var $grid_filter = $("#grid-filter") ;
var $mobile_filter_menu = $(".mobile-filter-panel") ;
types.html( '<li data-oid="0" data-filter_label="View All" data-filter_type="type" class="selected"><span><i class="fa fa-angle-right mr-3 selection-hover"></i>View All</span></li>' ) ;
mtypes.html( "<option selected value='0'>Type</option>" ) ;
$.each( html["types"], function( index, value ) {
types.append( value ) ;
mtypes.append( value ) ;
});
var $types_li = $("ul.filter--item_list li") ;
mtypes.select2( ) ; // Mobile Filter Drop Down
$types_li.unbind( "click" ).on( "click", function(){
var oid = $(this).data( "oid" ) ;
var title = $(this).data( "filter_label" ) ;
var type = $(this).data( "filter_type" ) ;
var bodyregion_id = $("#selected_bodyregion_id").val( ) ;
var bodyregion_title = __bodyregion_info[bodyregion_id]["title"] ;
filter_breadcrumb( __page_request_values["c"], "", "bodyregion", 'remove' ) ;
$("ul.category-bubbles-list li").removeClass( "active-filter" ) ;
filter_breadcrumb( bodyregion_id, bodyregion_title, "bodyregion", 'add' ) ;
$("ul.category-bubbles-list li[data-oid='"+bodyregion_id+"'][data-customcat='0']").addClass( "active-filter" ) ;
__page_request_values["c"] = bodyregion_id ;
if( __page_request_values["c1"] > 0 ) {
__page_request_values["c1"] = 0 ;
}
if( typeof __page_request_values["f1"] !== "undefined" ) {
if( __page_request_values["f1"] != oid ) {
if( __page_request_values["f1"] == 1 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
$("#predesigned_filters--conditions").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
}
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'add' ) ;
}
__page_request_values["f1"] = oid ;
$types_li.removeClass( "selected" ) ;
$(this).addClass( "selected" ) ;
if( $grid_filter.hasClass( "open" ) ) {
$grid_filter.removeClass( "open" ) ;
}
current_index = 0 ;
requestPrograms( ) ;
} else {
if( __page_request_values["f1"] == 1 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
$("#predesigned_filters--conditions").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
}
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'remove' ) ;
}
__page_request_values["f1"] = 0 ;
$types_li.removeClass( "selected" ) ;
$("ul.filter--item_list li[data-oid='0']").addClass( "selected" ) ;
if( $grid_filter.hasClass( "open" ) ) {
$grid_filter.removeClass( "open" ) ;
}
current_index = 0 ;
requestPrograms( ) ;
}
} else {
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'add' ) ;
}
__page_request_values["f1"] = oid ;
$types_li.removeClass( "selected" ) ;
$(this).addClass( "selected" ) ;
if( $grid_filter.hasClass( "open" ) ) {
$grid_filter.removeClass( "open" ) ;
}
current_index = 0 ;
requestPrograms( ) ;
}
});
mtypes.unbind( "select2:select" ).on('select2:select', function(e){
var oid = $("#predesigned_filters--types-mobile").val( ) ;
var title = $("#predesigned_filters--types-mobile").find( ":selected" ).data( "filter_label" ) ;
var type = $("#predesigned_filters--types-mobile").find( ":selected" ).data( "filter_type" ) ;
var bodyregion_id = $("#predesigned_filters--bodyregion-mobile").val( ) ;
var bodyregion_title = __bodyregion_info[bodyregion_id]["title"] ;
//filter_breadcrumb( __page_request_values["c"], "", "bodyregion", 'remove' ) ;
//filter_breadcrumb( bodyregion_id, bodyregion_title, "bodyregion", 'add' ) ;
if( typeof __page_request_values["f1"] !== "undefined" ) {
if( __page_request_values["f1"] != oid ) {
if( __page_request_values["f1"] == 1 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
$("#predesigned_filters--conditions-mobile").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
}
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'add' ) ;
}
__page_request_values["f1"] = oid ;
current_index = 0 ;
requestPrograms( ) ;
// Close Filter Menu
if( $mobile_filter_menu.hasClass( "opened" ) ) {
$mobile_filter_menu.removeClass( "opened" ) ;
}
// Clear button
var clear = mtypes.parent( ).parent().find( ".mobile-filter--clear" ) ;
if( oid == 0 ) {
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
} else {
if( !clear.hasClass( "active" ) ) { clear.addClass( "active" ) ; }
}
} else {
if( __page_request_values["f1"] == 1 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
$("#predesigned_filters--conditions-mobile").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
}
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'remove' ) ;
}
__page_request_values["f1"] = 0 ;
current_index = 0 ;
requestPrograms( ) ;
// Close Filter Menu
if( $mobile_filter_menu.hasClass( "opened" ) ) {
$mobile_filter_menu.removeClass( "opened" ) ;
}
// Clear button
var clear = mtypes.parent( ).parent().find( ".mobile-filter--clear" ) ;
if( oid == 0 ) {
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
} else {
if( !clear.hasClass( "active" ) ) { clear.addClass( "active" ) ; }
}
}
} else {
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'add' ) ;
}
__page_request_values["f1"] = oid ;
current_index = 0 ;
requestPrograms( ) ;
// Close Filter Menu
if( $mobile_filter_menu.hasClass( "opened" ) ) {
$mobile_filter_menu.removeClass( "opened" ) ;
}
// Clear button
var clear = mtypes.parent( ).parent().find( ".mobile-filter--clear" ) ;
if( oid == 0 ) {
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
} else {
if( !clear.hasClass( "active" ) ) { clear.addClass( "active" ) ; }
}
}
});
// Initialize the click handler for the Clear Icons
$(".mobile-filter--clear").unbind( "click" ).on( "click", handleClearFilter ) ;
setFilters( ) ; // Set the newly loaded filters
}
/* 2.9 Refresh the Conditions drop down filter */
function refreshConditionFilters( conditions_data ) {
var conditions = $("#filter--condition_type") ;
var mconditions = $("#predesigned_filters--conditions-mobile") ;
var $grid_filter = $("#grid-filter") ;
var $mobile_filter_menu = $(".mobile-filter-panel")
if( typeof conditions_data == 'undefined' ) { $("#condition-filter").hide( ) ; conditions_data = false; }
else if( !conditions_data ) { $("#condition-filter").hide( ) ; }
else { $("#condition-filter").show( ) ; }
conditions.html( "<option selected value='0'>Filter by condition</option>" ) ;
mconditions.html( "<option selected value='0'>Condition</option>" ) ;
$.each( conditions_data, function( index, value ) {
conditions.append( value ) ;
mconditions.append( value ) ;
});
if( conditions_data.length < 1 || conditions_data == false ) {
$("#predesigned_filters--conditions-mobile").prop( "disabled", true ) ;
} else {
$("#predesigned_filters--conditions-mobile").prop( "disabled", false ) ;
}
conditions.select2( ) ;
mconditions.select2( ) ;
conditions.unbind( "select2:select" ).on('select2:select', function(e){
var oid = $("#filter--condition_type").val( ) ;
var title = $("#filter--condition_type").select2().find(":selected").data("title") ;
var type = $("#filter--condition_type").select2().find(":selected").data("type") ;
var bodyregion_id = $("#selected_bodyregion_id").val( ) ;
var bodyregion_title = $(".ptlinked--dropdown_bodyregion_highlight").find( ".highlight-label" ).html( ) ;
// Auto-select body region bubble
filter_breadcrumb( __page_request_values["c"], "", "bodyregion", 'remove' ) ;
$("ul.category-bubbles-list li").removeClass( "active-filter" ) ;
filter_breadcrumb( bodyregion_id, bodyregion_title, "bodyregion", 'add' ) ;
$("ul.category-bubbles-list li[data-oid='"+bodyregion_id+"'][data-customcat='0']").addClass( "active-filter" ) ;
__page_request_values["c"] = bodyregion_id ;
if( typeof __page_request_values["f4"] !== "undefined" ) {
if( __page_request_values["f4"] != oid ) {
if( $(".clear-condition-filters").hasClass( "hide" ) ) {
$(".clear-condition-filters").removeClass( "hide" ) ;
}
__page_request_values["f4"] = oid ;
filter_breadcrumb( oid, title, type, 'add' ) ;
// Make sure TYPE=Condition Specific
$("ul.filter--item_list li").removeClass( "selected" ) ;
$("ul.filter--item_list").find( "li[data-oid=1]" ).addClass( "selected" ) ;
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
__page_request_values["f1"] = 1 ;
//filter_breadcrumb( 1, "Condition Specific", "type", 'add' ) ;
if( $grid_filter.hasClass( "open" ) ) {
$grid_filter.removeClass( "open" ) ;
}
current_index = 0 ;
requestPrograms( ) ;
} else {
//__page_request_values["f4"] = 0 ;
// Make sure TYPE=Condition Specific
$("ul.filter--item_list li").removeClass( "selected" ) ;
if( __page_request_values["f4"] > 0 ) {
$("ul.filter--item_list").find( "li[data-oid=1]" ).addClass( "selected" ) ;
__page_request_values["f1"] = 1 ;
//filter_breadcrumb( 1, "Condition Specific", "type", 'add' ) ;
}
if( $grid_filter.hasClass( "open" ) ) {
$grid_filter.removeClass( "open" ) ;
}
current_index = 0 ;
requestPrograms( ) ;
}
} else {
__page_request_values["f4"] = oid ;
if( $(".clear-condition-filters").hasClass( "hide" ) ) {
$(".clear-condition-filters").removeClass( "hide" ) ;
}
filter_breadcrumb( oid, title, type, 'add' ) ;
// Make sure TYPE=Condition Specific
$("ul.filter--item_list li").removeClass( "selected" ) ;
$("ul.filter--item_list").find( "li[data-oid=1]" ).addClass( "selected" ) ;
__page_request_values["f1"] = 1 ;
//filter_breadcrumb( 1, "Condition Specific", "type", 'add' ) ;
if( $grid_filter.hasClass( "open" ) ) {
$grid_filter.removeClass( "open" ) ;
}
current_index = 0 ;
requestPrograms( ) ;
}
});
mconditions.unbind( "select2:select" ).on('select2:select', function(e){
var oid = $("#predesigned_filters--conditions-mobile").val( ) ;
var title = $("#predesigned_filters--conditions-mobile").select2().find(":selected").data("title") ;
var type = $("#predesigned_filters--conditions-mobile").select2().find(":selected").data("type") ;
var bodyregion_id = $("#predesigned_filters--bodyregion-mobile").val( ) ;
var bodyregion_title = __bodyregion_info[bodyregion_id]["title"] ;
if( typeof __page_request_values["f4"] !== "undefined" ) {
if( __page_request_values["f4"] != oid ) {
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'add' ) ;
}
__page_request_values["f4"] = oid ;
filter_breadcrumb( __page_request_values["f1"], "", "type", 'remove' ) ;
__page_request_values["f1"] = 1 ; // Set Type to Condition Specific
$("#predesigned_filters--types-mobile").val( 0 ).trigger( "change" ) ;
current_index = 0 ;
requestPrograms( ) ;
// Close Filter Menu
if( $mobile_filter_menu.hasClass( "opened" ) ) {
$mobile_filter_menu.removeClass( "opened" ) ;
}
// Clear button
var clear = mconditions.parent( ).parent().find( ".mobile-filter--clear" ) ;
if( oid == 0 ) {
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
} else {
if( !clear.hasClass( "active" ) ) { clear.addClass( "active" ) ; }
}
// Types Clear button
var clear = $("#predesigned_filters--types-mobile").parent().parent().find( ".mobile-filter--clear" ) ;
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
} else {
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'add' ) ;
}
__page_request_values["f4"] = 0 ;
__page_request_values["f1"] = 1 ; // Set Type to Condition Specific
$("#predesigned_filters--types-mobile").val( 0 ).trigger( "change" ) ;
current_index = 0 ;
requestPrograms( ) ;
// Close Filter Menu
if( $mobile_filter_menu.hasClass( "opened" ) ) {
$mobile_filter_menu.removeClass( "opened" ) ;
}
// Clear button
var clear = mconditions.parent( ).parent().find( ".mobile-filter--clear" ) ;
if( oid == 0 ) {
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
} else {
if( !clear.hasClass( "active" ) ) { clear.addClass( "active" ) ; }
}
// Types Clear button
var clear = $("#predesigned_filters--types-mobile").parent().parent().find( ".mobile-filter--clear" ) ;
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
}
} else {
if( oid == 0 ) {
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
} else {
filter_breadcrumb( oid, title, type, 'add' ) ;
}
__page_request_values["f4"] = oid ;
filter_breadcrumb( oid, title, type, 'add' ) ;
__page_request_values["f1"] = 1 ; // Set Type to Condition Specific
current_index = 0 ;
requestPrograms( ) ;
// Close Filter Menu
if( $mobile_filter_menu.hasClass( "opened" ) ) {
$mobile_filter_menu.removeClass( "opened" ) ;
}
// Clear button
var clear = mconditions.parent( ).parent().find( ".mobile-filter--clear" ) ;
if( oid == 0 ) {
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
} else {
if( !clear.hasClass( "active" ) ) { clear.addClass( "active" ) ; }
}
// Types Clear button
var clear = $("#predesigned_filters--types-mobile").parent().parent().find( ".mobile-filter--clear" ) ;
if( clear.hasClass( "active" ) ) { clear.removeClass( "active" ) ; }
}
});
$(".clear-condition-filters").unbind( "click" ).on( "click", function(){
filter_breadcrumb( __page_request_values["f4"], "", "condition", 'remove' ) ;
$("#predesigned_filters--conditions").val( 0 ).trigger( "change" ) ;
__page_request_values["f4"] = 0 ;
__page_request_values["f1"] = 0 ;
$("ul.filter--item_list li").removeClass( "selected" ) ;
$("ul.filter--item_list").find( "li[data-oid=0]" ).addClass( "selected" ) ;
if( !$(".clear-condition-filters").hasClass( "hide" ) ) {
$(".clear-condition-filters").addClass( "hide" ) ;
}
if( $grid_filter.hasClass( "open" ) ) {
$grid_filter.removeClass( "open" ) ;
}
current_index = 0 ;
requestPrograms( ) ;
});
//$("#predesigned_filters--conditions").val( 0 ).trigger( "change" ) ;
if( ( typeof __page_request_values["f4"] !== 'undefined' ) && __page_request_values["f4"] > 0 ) {
$("#filter--condition_type").val( __page_request_values["f4"] ).trigger( "change" ) ;
}
$("#predesigned_filters--conditions-mobile").val( __page_request_values["f4"] ).trigger( "change" ) ;
if( __page_request_values["f4"] > 0 ) {
if( !$("#predesigned_filters--conditions-mobile").parent().parent().find( ".mobile-filter--clear" ).hasClass( "active" ) ) {
$("#predesigned_filters--conditions-mobile").parent().parent().find( ".mobile-filter--clear" ).addClass( "active" ) ;
}
} else {
if( $("#predesigned_filters--conditions-mobile").parent().parent().find( ".mobile-filter--clear" ).hasClass( "active" ) ) {
$("#predesigned_filters--conditions-mobile").parent().parent().find( ".mobile-filter--clear" ).removeClass( "active" ) ;
}
}
}
/* 2.10 Refresh the Custom Subcategories drop down filter */
function refreshSubcategoriesFilters( subcategories_data ) {
var subcategories = $("#predesigned_filters--subcategories") ;