PageSourceSearch

https://sbschool.org/js/frontend/portfolio-builder.js

js sbschool.org collected 2026-10-03 21:38:25 UTC 8,555 bytes, 276 lines download raw bytes

1// ----------
2// Email Link
3// ----------
4$("#email-link").click(function() {
5	showSoSimpleOverlay($("#share-product-email-modal").html());
6	$("input[name=your_name]").focus();
7	return false;
8});
9if($('.form-submitted').length) $("#email-link").click();
10
11
12// ----------------------------------
13// Checkbox Filters on Left Detection
14// ----------------------------------
15if($('#inspiration-gallery-list').length && $('#inspiration-gallery-list').hasClass('has-left-side-filters')) {
16	$('body').addClass('inspiration-gallery-has-left-side-filters');
17}
18
19
20// ------------
21// Masonry Grid
22// ------------
23if($('.masonry-grid').length) {
24	$.when(add_js(shared_root+'/js/jquery/jquery.masonry/masonry.pkgd.min.js')).done(function() {
25		$container = $("#inspiration-gallery-masonry");
26		$container.before('<p id="no-records" class="dn bmt tac">There are no items that match this search combination.</p>');
27
28		function init_masonry(first_time) {
29			$container.masonry({
30				"columnWidth"	: ".grid-sizer",
31				"itemSelector"	: ".masonry-item"+(!first_time?".visible":""),
32				"gutter" 		: ".gutter-sizer"
33			}).addClass('masonry-init');
34		}
35
36		// check/set hash
37		if(window.location.hash) {
38			var hash_val_arr = window.location.hash.replace("#","").split("&");
39			console.log(hash_val_arr);
40			for(i=0;i<hash_val_arr.length;i++) {
41				if(hash_val_arr[i]) {
42					if(hash_val_arr[i].indexOf("q=") == -1 && hash_val_arr[i].indexOf("sel[]=") == -1) continue;
43					if(hash_val_arr[i].indexOf("q=") != -1) {
44						var hash_val_q_arr = hash_val_arr[i].split("q=");
45						var hash_val_q = hash_val_q_arr[1];
46						if($('#inspiration-gallery-search-field-dropdowns-version').length) {
47							$('#inspiration-gallery-search-field-dropdowns-version').val(decodeURIComponent(hash_val_q));
48						}
49						
50					} else {
51						var hash_val_value_arr = hash_val_arr[i].split("sel[]=");
52						var hash_val_value = hash_val_value_arr[1];
53
54						$(".select-option-drop").each(function() {
55							var select_opt = $(this);
56							$(select_opt).find("option").each(function() {
57								if($(this).attr("value")==hash_val_value) {
58									$(select_opt).val(hash_val_value);
59								}
60							});
61						});
62					}
63				}
64			}
65		}
66
67		function updateWorkGrid() {
68			$('#no-records').hide();
69
70			selectedOpts = new Array();
71
72			var hash_val = "";
73			$(".select-option-drop").each(function() {
74				if($(this).val()) {
75					selectedOpts.push($(this).val());
76					hash_val += "&sel[]="+$(this).val();
77				}
78			});
79
80			var q = '';
81			if($('#inspiration-gallery-search-field-dropdowns-version').length && $('#inspiration-gallery-search-field-dropdowns-version').val().trim() != '') {
82				q = $('#inspiration-gallery-search-field-dropdowns-version').val().trim();
83				hash_val += "&q="+encodeURIComponent(q);
84			}
85
86			displayed_items_count = 0;
87			if(selectedOpts.length || q != '') {
88				$container.find(".masonry-item").each(function() {
89					hideItem = 0;
90					if(selectedOpts) {
91						for(i=0;i<selectedOpts.length;i++) {
92							if(!$(this).hasClass(selectedOpts[i])) hideItem = 1;
93						}
94					}
95
96					if(q && q != '') {
97						var item_title = $(this).find(".title").text().toLowerCase();
98						if(item_title.indexOf(q.toLowerCase()) == -1) {
99							hideItem = 1;
100						}
101					}
102
103					if(hideItem==1) {
104						$(this).removeClass("visible").hide();
105					} else {
106						displayed_items_count++;
107						$(this).stop(1,1).fadeIn(250,function() {
108							$(this).addClass("visible")
109						});
110					}
111				});
112			} else {
113				$container.find(".masonry-item").stop(1,1).fadeIn(250,function() {
114					$(this).addClass("visible");
115				});
116				displayed_items_count = $container.find(".masonry-item").length;
117			}
118
119			window.location.hash = hash_val;
120
121			if(displayed_items_count > 0) {
122				$('#no-records').hide();
123			} else {
124				$('#no-records').show();
125			}
126
127			if($container.hasClass('masonry-init')) {
128				$container.masonry();
129			} else {
130				init_masonry(1);
131			}
132		}
133
134		$(".select-option-drop").change(function() {
135			updateWorkGrid();
136			return false;
137		});
138
139		$container.waitForImages(function() {
140			if(!$container.hasClass('masonry-init')) {
141				updateWorkGrid();
142				$container.addClass('loaded');
143			} else {
144				$container.masonry('layout');				
145			}
146		});
147
148		$(window).load(function() {
149			if(!$container.hasClass('masonry-init')) {
150				updateWorkGrid();
151				$container.addClass('loaded');
152			} else {
153				$container.masonry('layout');				
154			}
155		});
156
157		setTimeout(function() {
158			if(!$container.hasClass('masonry-init')) {
159				updateWorkGrid();
160				$container.addClass('loaded');
161			} else {
162				$container.masonry('layout');	
163			}
164		},5000);
165
166		var inspirationGallerySearchFieldTimeout;
167		$('#inspiration-gallery-search-field-dropdowns-version').bind('keyup', function(e) {
168			clearTimeout(inspirationGallerySearchFieldTimeout);
169			inspirationGallerySearchFieldTimeout = setTimeout(function() {
170				updateWorkGrid();
171			},250);
172			e.preventDefault();
173			return false;
174		});
175
176		$('#inspiration-gallery-search-field-dropdowns-version').bind('keydown', function(e) {
177			if(e.keyCode == 13) {
178				e.preventDefault();
179				return false;
180			}
181		});
182	});
183}
184
185
186// ----------------------------------------
187// View All Categories/Filter Group Toggles
188// ----------------------------------------
189$("#inspiration-gallery-view-all-categories-link").click(function() {
190	if($(this).hasClass("selected")) {
191		$("#inspiration-gallery-categories-list-wrap").slideUp("fast");
192		$(this).removeClass("selected");
193	} else {
194		$("#inspiration-gallery-categories-list-wrap").slideDown("fast");
195		$(this).addClass("selected");
196	}
197	return false;
198});
199
200// search input handling
201$("#inspiration-gallery-search-field").bind('keyup',function(e) {
202	if($('#inspiration-gallery-right-side').length) {
203		if($(this).closest('label').length) {
204			if($(this).prop('checked')) {
205				$(this).closest('label').addClass('checked');
206			} else {
207				$(this).closest('label').removeClass('checked');
208			}
209		}
210
211		do_inspiration_gallery_load_ajax_request(1000);
212
213	} else {
214		$("#inspiration-gallery-filter-group-options").submit();
215	}
216});
217
218
219function do_inspiration_gallery_load_ajax_request(delay) {
220	clearTimeout(inspiration_gallery_form_submit_timeout);
221
222	if($('#ajax-loading-spinner-wrap').length) $('#ajax-loading-spinner-wrap').remove();
223	$('#inspiration-gallery-right-side').prepend('<div id="ajax-loading-spinner-wrap" class="ajax-loading-spinner-wrap"><div class="ajax-loading-spinner"></div></div>');
224
225	inspiration_gallery_form_submit_timeout = setTimeout(function() {
226		if(inspiration_gallery_load_ajax_request) inspiration_gallery_load_ajax_request.abort();
227
228		var form_url = '?'+$("#inspiration-gallery-filter-group-options").serialize();
229
230		inspiration_gallery_load_ajax_request = $.ajax({
231			type: "GET",
232			url: form_url+'&ajax=1',
233			success: function(html,textStatus) {
234				var contents = $(html).find("#inspiration-gallery-right-side").html();
235				$('#inspiration-gallery-right-side').html(contents);
236				$('.pager').each(function() {
237					var url = $(this).attr('href').replace('&ajax=1','');
238					$(this).attr('href',url);
239				});
240				$('body').trigger('inspiration-gallery-right-side-loaded');
241				history.pushState(null, null, form_url);
242			}
243		});
244	},delay);
245}
246
247// ajax handling for form submission
248var inspiration_gallery_form_submit_timeout;
249var inspiration_gallery_load_ajax_request;
250$(".inspiration-gallery-option").bind('change',function(e) {
251	if($('#inspiration-gallery-right-side').length) {
252		if($(this).closest('label').length) {
253			if($(this).prop('checked')) {
254				$(this).closest('label').addClass('checked');
255			} else {
256				$(this).closest('label').removeClass('checked');
257			}
258		}
259
260		do_inspiration_gallery_load_ajax_request(250);
261
262	} else {
263		$("#inspiration-gallery-filter-group-options").submit();
264	}
265});
266
267$(".inspiration-gallery-filter-group-toggle").click(function() {
268	if($(this).closest('.inspiration-gallery-filter-group').hasClass("closed")) {
269		$(this).next(".inspiration-gallery-filter-group-options-list").stop(1,1).slideDown("fast");
270		$(this).closest('.inspiration-gallery-filter-group').removeClass("closed");
271	} else {
272		$(this).next(".inspiration-gallery-filter-group-options-list").stop(1,1).slideUp("fast");
273		$(this).closest('.inspiration-gallery-filter-group').addClass("closed");
274	}
275	return false;
276});

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.