PageSourceSearch

https://www.cliffordchance.com/etc/designs/cc2014/jquery/people.js

js cliffordchance.com collected 2026-09-24 15:30:36 UTC 11,485 bytes, 293 lines download raw bytes

1// JavaScript Document
2
3$(document).ready( function() {
4
5	// ======================================================================
6	// Initially position the contacts
7	// ======================================================================
8
9	// Loop over all the horizontal carriers
10	$('section.section_aside_contacts_container section.section_aside_contacts_hcarrier').each( function(i) {
11
12		// These carriers will need a dynamically assigned id that corresponds to the thumbnail carrier
13		
14		$(this).children('article.article_aside_contact').each( function(ii) {
15
16			$(this).css('left', ii * 390 + 'px');
17		
18		});
19		
20	});
21	
22	// And show the main contact container if there is only one
23	if ($('section.section_aside_contacts_container section.section_aside_contacts_hcarrier').children('#section_aside_contacts_list').length > 0) {
24		// $('.section_aside_contacts_container').css({'display': 'block'});
25		// $('section.section_aside_contacts_container').slideUp();
26	}
27	
28	
29	
30	/* 
31	
32	// And hide all the thumbs we don't need
33	$('aside#aside_main section#section_aside_contacts_list section.section_aside_contacts_list_hcarrier').not(':first-child').slideUp();
34	
35	
36	// Equalise the sizes of each thumbnail
37	var nBiggestThumb = 0;
38	
39	$('article.article_aside_contact_small').each( function() {
40		if ($(this).height() > nBiggestThumb) {
41			nBiggestThumb = $(this).height();
42		}
43	});
44
45	$('article.article_aside_contact_small').css('min-height', nBiggestThumb + 'px');
46	
47	*/
48
49	// Equalise the sizes of each thumbnail
50	equaliseHeights($('article.article_aside_contact_small'));
51	
52	//var nBiggestContact = 0;
53
54    $('article.article_aside_contact').each( function() {
55        if ($(this).height() > 170 && $(this).is(':first-child')) {
56        	$( this ).parent().height($(this).height()+20) ;
57		}
58	});
59
60	//$('section.section_aside_contacts_hcarrier').css('min-height', (nBiggestContact + 20) + 'px'); 
61	
62	
63	
64	// ======================================================================
65	// Add click functionality to the thumbnail contacts
66	// ======================================================================
67	
68	$('.section_aside_contacts_list_hcarrier').on('click', 'a.a_people_thumb', function(e) {
69		
70		// $('.section_aside_contacts_container').animate({ 'height': '180px' }, 500);
71		var href = $(this).attr('href');
72		
73		$('.section_aside_contacts_container').slideDown();
74		
75		var thisButton = $(this);
76		var nThisIteration = $(this).data('thisiteration');
77		var nParentParentIteration = $(this).parent().parent().data('thisiteration');
78		var prevParent = $( this ).parents().eq(3).find('section.section_aside_contacts_hcarrier');
79        var prevArticleNo = nThisIteration+1;
80
81        prevParent.height(prevParent.find('article:nth-of-type('+prevArticleNo+')').height()+20) ;
82		
83		// The thumbnail carrier will need a dynamically assigned id that corresponds with the main contact carrier 
84		
85//		$('section.section_aside_contacts_container section.section_aside_contacts_hcarrier').each( function(i) {
86//			if (nParentParentIteration == $(this).data('thisiteration')) {
87        $(this).parent().parent().parent().parent().children().children(".section_aside_contacts_hcarrier").stop().animate({
88            'margin-left': ((nThisIteration * -390)) + 'px'
89        }, 500);
90//			}
91//		});
92		
93		if ($(window).width() > 999) {
94			$('body').animate({ scrollTop: '400px' }, 500);
95		}
96		setTimeout(function() {
97            window.location.href = href;
98        }, 300);
99		e.preventDefault();
100		
101	});
102	
103	// -------------------------------------------------------------------------------------
104	// Initial state of global media contacts pod
105	// -------------------------------------------------------------------------------------
106	
107	$('.gmc_preselection').trigger('click');
108	
109	// -------------------------------------------------------------------------------------
110    // Analytics tracking for global media contact
111    // -------------------------------------------------------------------------------------
112        function getActiveContactName() {
113        console.log('[Analytics Contact] Function getActiveContactName() triggered.');
114
115        // ========================================================================
116        // STEP 1: Check for Global Media Contact component (Carousel Pre-selection)
117        // ========================================================================
118        console.log('[Analytics Contact] Step 1: Checking Global Media Contact component...');
119        var $activeThumb = $('.a_people_thumb.gmc_preselection');
120        var index = -1;
121        
122        if ($activeThumb.length) {
123            index = parseInt($activeThumb.data('thisiteration'), 10);
124            console.log('[Analytics Contact] Step 1: Pre-selected thumb found. Index:', index);
125        } else {
126            // FALLBACK: Calculate which contact is actually in the viewport
127            var $carrier = $('.section_aside_contacts_globalmedia .section_aside_contacts_hcarrier').first();
128            if ($carrier.length) {
129                var marginLeft = parseInt($carrier.css('margin-left'), 10) || 0;
130                index = Math.abs(Math.round(marginLeft / 390));
131                console.log('[Analytics Contact] Step 1: No thumb pre-selected. Calculated viewport index:', index);
132            }
133        }
134        
135        if (isNaN(index) || index < 0) {
136            index = 0;
137        }
138        
139        var $contacts = $('.section_aside_contacts_globalmedia .section_aside_contacts_hcarrier .article_aside_contact');
140        var $contact = $contacts.eq(index);
141
142        if ($contact.length) {
143            var gmcName = $.trim($contact.find('h3.pageColour_text').first().text());
144            if (gmcName) {
145                console.log('[Analytics Contact] Step 1 SUCCESS. Returning Name:', gmcName);
146                return gmcName; 
147            }
148        } else {
149            console.log('[Analytics Contact] Step 1 FAILED: Global Media Contact component not found or empty.');
150        }
151        
152        // ========================================================================
153        // STEP 2: Check News Detail Component Fields (via HTL data attributes)
154        // ========================================================================
155        console.log('[Analytics Contact] Step 2: Checking News Detail Data attributes...');
156        var $newsDetailData = $('#newsDetailContactData');
157        
158        if ($newsDetailData.length) {
159            var detailName = $.trim($newsDetailData.data('contact-name'));
160            
161            if (detailName) {
162                console.log('[Analytics Contact] Step 2 SUCCESS. Returning Name:', detailName);
163                return detailName;
164            } else {
165                console.log('[Analytics Contact] Step 2 FAILED: Hidden element found, but data-contact-name is empty.');
166            }
167        } else {
168            console.log('[Analytics Contact] Step 2 FAILED: #newsDetailContactData element not found on page.');
169        }
170
171        // ========================================================================
172        // STEP 3: Check News Content for "Press contact" string
173        // ========================================================================
174        console.log('[Analytics Contact] Step 3: Checking News Content paragraphs for "Press contact: " string...');
175        var extractedName = null;
176        
177        // Loop through paragraphs in the news detail section
178        $('.newsdetail p').each(function() {
179            var pText = $(this).text();
180            
181            // Look for "press contact" (case-insensitive)
182            if (pText.toLowerCase().indexOf('press contact') !== -1) {
183                console.log('[Analytics Contact] Step 3: Found string match in paragraph:', pText);
184                
185                // Split the text at "press contact" (handles optional colons and spaces)
186                var parts = pText.split(/press contact\s*:?/i);
187                
188                if (parts.length > 1 && parts[1]) {
189                    extractedName = $.trim(parts[1]);
190                    console.log('[Analytics Contact] Step 3: Extracted raw name:', extractedName);
191                    return false; // Break the jQuery .each() loop
192                }
193            }
194        });
195
196        if (extractedName) {
197            console.log('[Analytics Contact] Step 3 SUCCESS. Returning Name:', extractedName);
198            return extractedName; 
199        } else {
200            console.log('[Analytics Contact] Step 3 FAILED: String not found in content.');
201        }
202
203        // ========================================================================
204        // ALL STEPS FAILED
205        // ========================================================================
206        console.warn('[Analytics Contact] All 3 steps failed. Returning null.');
207        return null;
208    }
209
210	function trackContactWithRetry(attempt) {
211
212        window.CC_ANALYTICS_DEBUG = true;
213        var maxAttempts = 10;
214        var retryDelay = 500;
215       
216        try {
217            var contactName = getActiveContactName();
218            if (contactName && typeof globalMediaContactView === 'function') {
219                if (window.CC_ANALYTICS_DEBUG) {
220                    console.log('Global Media Contact found: "' + contactName + '" on attempt: ' + attempt + ' (approx. ' + (attempt * retryDelay) + 'ms)');
221                }
222                globalMediaContactView(contactName);
223                return;
224            }
225           
226            if (attempt < maxAttempts) {
227                setTimeout(function() {
228                    trackContactWithRetry(attempt + 1);
229                }, retryDelay);
230            } else {
231                if (window.CC_ANALYTICS_DEBUG) {
232                    console.warn('Global Media Contact not found after ' + maxAttempts + ' attempts.');
233                }
234            }
235        } catch (e) {
236            if (window.CC_ANALYTICS_DEBUG) {
237                console.error('Error tracking visible contact:', e);
238            }
239        }
240    }
241 
242    setTimeout(function () {
243        trackContactWithRetry(1);
244    }, 500);
245
246	// -------------------------------------------------------------------------------------
247	// Add a "View more people..." button under the first contact
248	// -------------------------------------------------------------------------------------
249
250$('.expertssimple').each(function () {
251
252    var $component = $(this);
253    var $showMore = $component.find('p.p_show_more_people');
254    var $contactsList = $component.find('#section_aside_contacts_list');
255    var $container = $component.find('.section_aside_contacts_container');
256
257    $showMore.hide();
258
259    if (
260        $contactsList.length > 0 &&
261        $contactsList.children('.section_aside_contacts_list_hcarrier').length >= 1 &&
262        !$container.hasClass('section_aside_contacts_globalmedia')
263    ) {
264        $showMore.show();
265        $contactsList.hide();
266    }
267
268    $showMore.find('a').off('click').on('click', function (e) {
269
270        e.preventDefault();
271
272        $contactsList.slideToggle();
273
274        $container
275            .children('.section_aside_contacts_hcarrier')
276            .stop()
277            .animate({
278                'margin-left': '0px'
279            }, 500);
280
281        // Optional: Toggle link text
282     //   var $link = $(this);
283
284     //   if ($contactsList.is(':visible')) {
285     //       $link.text('See less');
286     //   } else {
287     //       $link.text('See more');
288     //   }
289    });
290});
291	
292	
293});

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.