PageSourceSearch

https://juliettebaily.fr/javascript?26.11.18.1&1658418016

js juliettebaily.fr collected 2026-10-06 18:40:23 UTC 14,300 bytes, 666 lines download raw bytes

1/**
2 * Hyperion
3 */
4
5var Design = {
6
7	data: {
8		init_start: false,
9		inspector_open: false,
10		vertical_margin: window.vertical_margin ? window.vertical_margin : 500,
11		mobile_breakpoint: 600,
12		use_mobile_design: true,
13		use_mobile_menu: true,
14		mobile_active: false,
15		click_event: "click"
16	},
17
18
19	init: function(){
20
21		var container_padding = parseInt($('.container').css("padding-bottom"));
22		var footer_height = $('.site_footer').outerHeight(true);
23
24		// Reset navigation if Sets and Projects are
25		if ( Cargo.Model.DisplayOptions.get("use_set_links") && Cargo.Model.DisplayOptions.get("projects_in_text_nav") ) {
26			Cargo.Collection.Navigation.url = Cargo.API.GetNavigationCargoPath(0, 9999);
27			Cargo.Collection.Navigation.fetch({reset: true});
28		}
29
30		if ( container_padding < footer_height ){
31			$('.container').css("padding-bottom", footer_height + "px" );
32		}
33
34
35	},
36
37
38	mobileInit: function(){
39
40		$('.navigation_toggle').bind("click.mobile dblclick.mobile", function(e){
41			if ( e.type == Design.data.click_event ){
42				Design.toggleNav();
43			}
44		});
45
46
47
48		$(window).bind("scroll.mobile", function(){
49
50			Design.toggleNav(true);
51
52		});
53
54		if ( Cargo.Helper.GetCurrentPageType() ){
55			Design.setVerticalMargin();
56		}
57
58	},
59
60	mobileUnbind: function(){
61		$('.navigation_toggle').unbind("click.mobile dblclick.mobile");
62		$('body').unbind("click.mobile");
63		$('body').unbind("scroll.mobile");
64
65		if ( Cargo.Helper.isIOS() ){
66			$('body').css("cursor", "")
67		}
68
69		if ( Cargo.Helper.GetCurrentPageType() ){
70			Design.setVerticalMargin();
71		}
72
73	},
74
75	toggleNav: function(closeNav){
76
77		if ( $('.navigation_toggle').is(".active") || closeNav ){
78
79			$(".navigation, .navigation_toggle").removeClass("active");
80
81			$('body').unbind("click.mobile");
82
83		} else {
84
85			$(".navigation, .navigation_toggle").addClass("active");
86
87			if ( Cargo.Helper.isIOS() ){
88				$('body').css("cursor", "pointer")
89			}
90
91			$('body').bind( "click.mobile", function(e){
92
93				var touchtarget = $(e.target);
94
95				if ( !touchtarget.is('.navigation, .navigation *, .mobile_site_header, .mobile_site_header *') ) {
96
97					Design.toggleNav(true);
98
99				}
100
101			});
102
103		}
104
105	},
106
107	calcBreakpoint: function(){
108
109		// if we have a breakpoint from custom html, return
110		if ( window.mobile_breakpoint) {
111			Design.data.mobile_breakpoint = window.mobile_breakpoint;
112			return;
113		}
114
115		// if no thumbnails, then we keep the default and return
116		if (  $('#thumbnails .thumbnail').length == 0 ){
117			return;
118		}
119
120		var thumb_width = Cargo.Model.DisplayOptions.get("thumb_size").w;
121
122		var test_thumb, test_thumb_img, index, two_col_width, margins_padding;
123
124		test_thumb = $('#thumbnails .thumbnail').first();
125		test_thumb_img = test_thumb.find(".thumb_image img")
126
127		// if thumb width is undefined, then measure thumbs
128		if ( thumb_width == "*" ){
129
130			if ( $('#thumbnails .thumbnail').length > 1 ){
131
132				two_col_width = parseInt(test_thumb_img.attr("width")) + parseInt($('#thumbnails .thumbnail .thumb_image img').eq(1).attr("width"));
133
134			} else {
135
136				two_col_width = parseInt(test_thumb_img.attr("width"))*2;
137
138			}
139
140			thumb_width = two_col_width / 2;
141
142		} else {
143
144			// make sure that thumb_width is set to integer
145			thumb_width = parseInt(thumb_width);
146			two_col_width = thumb_width * 2;
147		}
148
149		// get padding & margin from first thumb
150		margins_padding =  (test_thumb.outerWidth(true) - test_thumb.width())*2;
151
152		// get padding & margin from index
153		index = $('#thumbnails');
154
155		// get padding & margin from .container
156		container = $('body > .container');
157
158		if ( thumb_width > 500){
159
160			// Use single thumb for very large thumbnails
161			Design.data.mobile_breakpoint = (index.outerWidth(true) - index.width() ) + (container.outerWidth(true) - container.width() ) + thumb_width + margins_padding;
162
163		} else {
164
165			Design.data.mobile_breakpoint = (index.outerWidth(true) - index.width() ) + (container.outerWidth(true) - container.width() ) + two_col_width + margins_padding;
166
167		}
168
169
170	},
171
172
173	testBreakpoint: function(){
174
175		var pages_num
176		if ( Cargo.View.hasOwnProperty("Navigation")){
177			pages_num = Cargo.View.Navigation.collection.length;
178		} else {
179			pages_num = Cargo.Collection.Pages.length;
180		}
181
182		var usable_width = $(window).width()
183
184		var mobile_breakpoint = window.mobile_breakpoint || Design.data.mobile_breakpoint || 600;
185
186		if ( (usable_width < mobile_breakpoint || screen.width < mobile_breakpoint) && Design.data.use_mobile_design ) {
187			$('body').addClass("mobile");
188
189			// bind on first resize
190			if ( !Design.data.mobile_active && Design.data.use_mobile_menu && pages_num > 0 ){
191
192				$('body').addClass("mobile_menu");
193				Design.mobileInit();
194				Design.data.mobile_active = true;
195
196			}
197
198			if ( pages_num < 1){
199
200				$('body').removeClass("mobile_menu");
201				Design.mobileUnbind();
202				Design.data.mobile_active = false;
203
204			}
205
206		} else {
207			$('body').removeClass("mobile");
208			Design.toggleNav(true);
209
210			// unbind on first resize
211			if ( Design.data.mobile_active && Design.data.use_mobile_menu ){
212				$('body').removeClass("mobile_menu");
213
214				Design.mobileUnbind();
215				Design.data.mobile_active = false;
216			}
217
218		}
219
220	},
221
222	scroll: {
223
224		indexPosition : 0,
225
226		defaultScroll : function() {
227			// Configured on setup
228		},
229
230		project : function() {
231
232			// Set the data if we were on an index page
233			if ( !$('body').is('[data-pagetype]') ) {
234
235				this.indexPosition = $(window).scrollTop();
236
237			}
238
239			$(window).scrollTop(0);
240
241		},
242
243		index : function() {
244
245			$(window).scrollTop(this.indexPosition);
246
247		},
248
249		setup : function() {
250
251			var self = this;
252
253			// Set the default scroll event
254			this.defaultScroll = Cargo.Helper.ScrollToTop;
255
256			// Reset helper methods
257			Cargo.Helper.ScrollToTop = function() {
258
259				// Only scroll if project/page is open
260				if ( Cargo.Helper.GetCurrentPageType() ){
261
262					Design.scroll.defaultScroll();
263
264				}
265
266				// Close mobile nav if on Phone
267				if( Design.data.mobile_active){
268
269					Design.toggleNav(true);
270
271				}
272			};
273
274		}
275
276	},
277
278
279	keybindings: function() {
280
281		// Remove previous bindings
282		Cargo.Core.KeyboardShortcut.Remove("Escape");
283		Cargo.Core.KeyboardShortcut.Remove("Left");
284		Cargo.Core.KeyboardShortcut.Remove("Right");
285
286		Cargo.Core.KeyboardShortcut.Add("Left", 37, function() {
287			Action.Project.Prev();
288			return false;
289		});
290
291		Cargo.Core.KeyboardShortcut.Add("Right", 39, function() {
292			Action.Project.Next();
293			return false;
294		});
295
296		Cargo.Core.KeyboardShortcut.Add("Escape", 27, function() {
297
298			// Don't go to index if lightbox is open
299			if ( lightbox.isActive ){
300
301				return;
302
303			} else {
304				Action.Project.Index();
305				return;
306			}
307
308		});
309
310	},
311
312	formatThumbnails: function() {
313
314		var thumbs = $("#thumbnails .thumbnail[data-formatted!='true']");
315
316
317
318		thumbs.each(function(i) {
319
320			if ($(this).find(".thumb_image img").attr("src") == "/_gfx/thumb_custom.gif") {
321				$(this).addClass("default_thumb");
322				$(this).css("max-width", "320px");
323			}
324
325
326
327			$('.thumb_info_wrapper', this).bind("click.thumb_info dblclick.thumb_info", function(e){
328
329				if ( !$(e.target).is('a') && e.type == Design.data.click_event ){
330
331				    Cargo.Event.trigger("add_history", $(this).closest('.thumbnail').find('a[rel="history"]').attr("href"));
332
333				}
334
335			});
336
337		});
338
339		if ( Cargo.Model.DisplayOptions.get("randomize_thumbs") ){
340			thumbs.shuffle();
341		}
342
343		$("#thumbnails .thumbnail[data-formatted!='true']").attr("data-formatted", "true").css("visibility", "visible");
344
345
346	},
347
348	setVerticalMargin: function(){
349		var vertical_margin,
350			top_element
351
352		if ( window.vertical_margin ){
353
354			vertical_margin = window.vertical_margin;
355
356		} else {
357
358			// set vertical margin
359			top_element = Cargo.View.ProjectDetail.$el.find(".project_content > *").first();
360
361			if ( top_element.is('.slideshow') ){
362
363				vertical_margin = top_element.find('.slideshow_container').first().offset().top;
364
365			} else {
366
367				vertical_margin = Cargo.View.ProjectDetail.$el.find('.project_content').offset().top;
368			}
369
370			if ( Cargo.View.ProjectDetail.$el.find('.project_content > *').not('img, iframe, div, video').length > 1){
371				vertical_margin = vertical_margin + 120;
372			}
373
374			Cargo.Plugins.elementResizer.setOptions({
375				forceVerticalMargin: vertical_margin
376			});
377
378		}
379
380
381		if ( Design.data.vertical_margin !== vertical_margin ){
382			Design.data.vertical_margin = vertical_margin
383			Cargo.Plugins.elementResizer.refresh();
384		}
385	},
386
387
388	formatNavigation: function() {
389
390		if ( Cargo.Model.DisplayOptions.get("use_set_links") ) {
391
392			if ( Cargo.Model.DisplayOptions.get("projects_in_text_nav") === false ) {
393				$('.set_link').addClass('no_projects');
394			}
395
396			$(".set_link").each(function(i){
397
398				if ( $(this).prev().not(".set_wrapper, .set_link.no_projects").length > 0 ) {
399					$(this).addClass("first")
400				}
401
402				if ( $(this).next().not(".set_link").length > 0 ) {
403					$(this).addClass("last")
404				}
405
406			})
407
408		}
409
410	}
411
412};
413
414/**
415 * Events
416 */
417
418$(function() {
419
420
421	// prevent double-running of init function
422	if ( Design.data.init_start ){
423		return
424	}
425	Design.data.init_start = true;
426	$('body').css('visibility', 'hidden');
427	Design.keybindings();
428
429	Design.data.use_mobile_design = window.use_mobile_design !== undefined ? window.use_mobile_design : Cargo.Model.DisplayOptions.get("use_mobile_mode");
430	Design.data.use_mobile_menu = window.use_mobile_menu !== undefined ? window.use_mobile_menu : Cargo.Model.DisplayOptions.get("use_mobile_menu");
431
432
433
434	Design.calcBreakpoint();
435
436	Design.testBreakpoint();
437	Design.scroll.setup();
438	Design.init();
439	Design.formatNavigation();
440
441	if ( !Cargo.Helper.IsSearch() ) {
442
443		Design.formatThumbnails();
444
445	}
446
447	$('body').css('visibility', 'visible');
448
449
450	Cargo.Event.on("show_index_complete", function(pid) {
451
452		Design.scroll.index();
453
454	});
455
456});
457
458resizeTimeout = null;
459
460$(window).resize(function(){
461
462	Design.testBreakpoint();
463
464	if ( Cargo.Helper.isMobile() ){
465		clearTimeout(resizeTimeout);
466		resizeTimeout = setTimeout(function(){
467			Cargo.Plugins.elementResizer.refresh();
468		}, 250)
469	}
470
471});
472
473
474Cargo.Event.on("slideshow_on", function(el, obj) {
475
476	$(el).find('.slideshow_thumbnails').addClass("clear");
477
478	$('.slideshow .video_component').each(function(){
479
480		$(this).css({
481			width: $('object', this).attr("width") + "px",
482			height: $('object', this).attr("height") + "px",
483			"data-elementresizer-child": "data-elementresizer-child",
484		});
485
486	});
487
488
489	Cargo.Plugins.elementResizer.refresh();
490
491	// Add classes for slideshow if nav is active
492	if ( Cargo.Model.DisplayOptions.get("slide_text_nav").enabled ) {
493
494		if ( Cargo.Model.DisplayOptions.get("slide_nav_position") == "top" ){
495
496			el.addClass("slideshow_navigation_on_top");
497
498		} else {
499
500			el.addClass("slideshow_navigation_on_bottom");
501
502		}
503
504	}
505
506});
507
508Cargo.Event.on("pagination_complete", function() {
509
510	Design.formatThumbnails();
511
512});
513
514Cargo.Event.on("fullscreen_destroy_hotkeys", function() {
515
516	Design.keybindings();
517
518});
519
520
521Cargo.Event.on("project_load_start", function(pid) {
522
523
524	Design.scroll.project();
525
526});
527
528Cargo.Event.on("element_resizer_init", function(plugin) {
529	plugin.setOptions({
530	    minimumHeight: 25,
531	    centerElements: Cargo.Model.DisplayOptions.get("center_images"),
532		adjustElementsToWindowHeight: Cargo.Model.DisplayOptions.get("scale_images"),
533		forceVerticalMargin: Design.data.vertical_margin
534	});
535});
536
537
538
539Cargo.Event.on("project_load_complete", function(pid) {
540
541
542	if ( (Cargo.Model.DisplayOptions.get("thumbs_below_pages") && Cargo.Helper.GetCurrentPageType() == "page") ){
543		$('.project_nav_wrapper').addClass("hidden");
544	} else {
545		$('.project_nav_wrapper').removeClass("hidden");
546	}
547
548	if ( Design.data.mobile_active ){
549		Design.toggleNav(true);
550	}
551
552	if ( Cargo.View.ProjectDetail !== undefined ) {
553
554		var imgs,
555			randomImgIndex,
556			bgColorString
557
558		// setup background color
559	    if ( $('#site_bg_color', Cargo.View.ProjectDetail.$el).length > 0 ){
560		    bgColorString = "body { background-color: " + Cargo.Model.Project.GetBgColor() + "}";
561			$('#site_bg_color', Cargo.View.ProjectDetail.$el).text(bgColorString);
562	    }
563
564		// Remove active state on Set link if thumbnails are hidden
565		if ( (Cargo.Helper.GetCurrentPageType() =="page" && !Cargo.Model.DisplayOptions.get("thumbs_below_pages") && Cargo.Helper.IsOnSet()) ||	$('.splash', Cargo.View.ProjectDetail.$el).length > 0) {
566
567			$('.set_link.active').removeClass("active");
568
569		}
570
571		Design.setVerticalMargin();
572
573
574		// setup splash page
575
576		if ( $('.splash', Cargo.View.ProjectDetail.$el).length > 0){
577
578			$('#thumbnails').hide();
579			Cargo.View.ProjectDetail.$el.find('.entry').hide();
580			Cargo.View.ProjectDetail.$el.find(".splash img").hide();
581
582			// select random image in the splash
583			$('.splash', Cargo.View.ProjectDetail.$el).each(function(){
584
585				Cargo.View.ProjectDetail.$el.append($(this));
586
587
588				if ( $(this).is('a') && !$(this)[0].attributes.href ) {
589
590					$(this).css("cursor", "pointer").attr("rel", "show_index");
591
592				};
593
594				imgs = $('img', this);
595
596				randomImgIndex = Math.floor( Math.random() * imgs.length );
597
598				$(this).css("background-image", "url(" + imgs.eq( randomImgIndex ).attr("src_o") + ")");
599
600			});
601
602		}
603
604
605	}
606
607});
608
609Cargo.Event.on("navigation_reset", function() {
610	Design.testBreakpoint();
611    Design.formatNavigation();
612});
613
614Cargo.Event.on("reseed_project_complete", function(){
615	Design.testBreakpoint();
616	Design.formatThumbnails();
617});
618
619Cargo.Event.on("project_collection_reset", function() {
620	Design.testBreakpoint();
621	Design.formatThumbnails();
622});
623
624// Re-trigger start page active state after nav is reloaded
625Cargo.Event.on("navigation_reset project_load_complete", function(){
626    if ( $('body').is('.start_project') || Cargo.Helper.IsOnStartProject() ) {
627        $('#menu_' + Cargo.Helper.GetStartProjectId() ).addClass("active");
628    }
629});
630
631
632Cargo.Event.on("inspector_open", function() {
633	Design.data.inspector_open = true;
634	Design.data.click_event = "dblclick";
635});
636
637
638/**
639 * Shuffling
640 * http://css-tricks.com/snippets/jquery/shuffle-dom-elements/
641 */
642
643(function($){
644
645	$.fn.shuffle = function() {
646
647		var allElems = this.get(),
648			getRandom = function(max) {
649				return Math.floor(Math.random() * max);
650			},
651			shuffled = $.map(allElems, function(){
652				var random = getRandom(allElems.length),
653					randEl = $(allElems[random]).clone(true)[0];
654				allElems.splice(random, 1);
655				return randEl;
656			});
657
658		this.each(function(i){
659			$(this).replaceWith($(shuffled[i]));
660		});
661
662		return $(shuffled);
663
664	};
665
666})(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.