PageSourceSearch

https://www.nestlehealthscience.com.hk/themes/custom/nhsc_master/js/site-scripts.js?tmh1r4

js nestlehealthscience.com.hk collected 2026-10-06 07:59:42 UTC 19,524 bytes, 496 lines download raw bytes

1(function (jQuery) {
2    Drupal.behaviors.nestlemasters = {
3        attach: function (context, settings) {
4
5        //Expand button
6           var maxheight=359;
7           var showText = jQuery('.more').html();
8           var hideText = jQuery('.less').html();
9
10            jQuery('.paragraph-expand').each(function () {
11                var text = jQuery(this);
12                if (text.height() > maxheight){
13                    text.css({ 'overflow': 'hidden','height': maxheight + 'px' });
14
15                    var link = jQuery('<a href="#">' + showText + '</a>');
16                    var linkDiv = jQuery('<div></div>');
17                    linkDiv.append(link);
18                    jQuery(this).after(linkDiv);
19
20                    link.click(function (event) {
21                    event.preventDefault();
22                    if (text.height() > maxheight) {
23                        jQuery(this).html(showText);
24                        text.css('height', maxheight + 'px');
25                    } else {
26                        jQuery(this).html(hideText);
27                        text.css('height', 'auto');
28                    }
29                    });
30                }
31            });
32
33
34            //Expand button if on mobile
35
36            jQuery('.paragraph--type--nhsc-mobile-expand .field--name-field-nhsc-column-link').each(function(){
37                jQuery(this).click(function(e){
38                    e.preventDefault();
39                    jQuery(this).prev('.field--name-field-nhsc-column-text').slideToggle();
40                });
41
42            });
43
44             // and and remove class to hcp label
45            function changeHcpColor (){
46                if(jQuery('.header-switcher-padding .switch input').prop("checked")){
47
48                    jQuery('.header--container-activate').addClass('green-label');
49                    console.log("Checkbox is checked.");
50                } else {
51                    jQuery('.header--container-activate').removeClass('green-label');
52                    console.log("Checkbox is notchecked.");
53                }
54            }
55
56            changeHcpColor ();
57
58            jQuery('input#hcp-site-switcher').on('change', function(){
59                 changeHcpColor ();
60            });
61
62            //Radio Btn MCWCP
63            jQuery(".btn-continue a").attr("disabled", true);
64
65                jQuery(".radio-btn").change(function() {
66
67                    jQuery(".radio-btn").closest('.radio').removeClass("btn-wrapper");
68
69                    if(jQuery(this).is(":checked")){
70
71                        jQuery(this).closest('.radio').addClass("btn-wrapper");
72
73                        jQuery(".btn-continue a").attr("disabled", false);
74
75                        var url = jQuery(this).data("link");
76
77                        jQuery(".btn-continue a").attr("href", url);
78                        console.log(url);
79
80                    }
81
82                    else {
83
84                        jQuery(".btn-continue a").attr("disabled", true);
85
86                       }
87
88                 });
89
90                //  if(jQuery(".sticky-wrapper")){
91                //     jQuery( "#floating-icons, .feature-section, footer" ).hide();
92                //  }
93
94                 if(jQuery(".step-1")) {
95                    jQuery('<style type="text/css">.block-cerebral-palsy-block{margin-top:0}</style>').appendTo("body");
96                 }
97                 else {
98                    jQuery('<style type="text/css">.block-cerebral-palsy-block{margin-top:-15px}</style>').appendTo("body");
99                }
100
101
102             // remove toggle for subscribe button
103            jQuery(".block-we-megamenu-blocksubscribe > .region-we-mega-menu #menu-toggle").remove();
104            IsTouchDevice = function() {
105                if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
106                    return true;
107                }
108                return false;
109            };
110
111
112
113          jQuery('.bef-exposed-form input[type="radio"]').click(function(){
114            var itemName = jQuery(this).attr('name');
115            var itemValue = jQuery(this).val();
116            var item = "edit-"+ itemName + "-" + itemValue.toLowerCase() + ""
117            item = item.replace(/_/g, '-');
118
119            if (jQuery(this).is(':checked'))
120            {
121              jQuery(document).ajaxStop(function() {
122                var itemId = document.querySelectorAll("[id^=" + CSS.escape(item) + "]");
123                jQuery('input[name=' + itemName + ']:radio').parent().removeClass('active');
124                jQuery(itemId).parent().addClass('active');
125              });
126            }
127          });
128
129          jQuery('.bef-exposed-form input[type="checkbox"]').click(function(){
130            if(jQuery(this).is(':checked')) {
131              jQuery(this).parent().addClass('active');
132            } else {
133              jQuery(this).parent().removeClass('active');
134            }
135          });
136
137          var jQuerycheckboxes = jQuery('.bef-exposed-form input[type="checkbox"]');
138
139          jQuerycheckboxes.change(function(){
140                var countCheckedCheckboxes = jQuerycheckboxes.filter(':checked').length;
141                jQuery('#filterCount').text(countCheckedCheckboxes);
142                if (jQuerycheckboxes.filter(':checked').length > 0) {
143                    jQuery('#filterCount').removeClass('hidden');
144                } else {
145                    jQuery('#filterCount').addClass('hidden');
146                }
147            });
148
149          jQuery('.action-submit .form-submit').click(function(){
150              jQuery(document).ajaxStop(function() {
151                  var countCheckedCheckboxes = jQuerycheckboxes.filter(':checked').length;
152                  jQuery('#filterCount').text(countCheckedCheckboxes);
153                  if (jQuerycheckboxes.filter(':checked').length > 0) {
154                      jQuery('#filterCount').removeClass('hidden');
155                  } else {
156                      jQuery('#filterCount').addClass('hidden');
157                  }
158
159                  jQuery('.bef-exposed-form input[type="checkbox"]').each(function(i) {
160                      if(jQuery(this).is(':checked')) {
161                          jQuery(this).parent().addClass('active');
162                      } else {
163                          jQuery(this).parent().removeClass('active');
164                      }
165                  })
166              });
167          });
168
169          jQuery('.action-reset .form-submit').click(function(){
170            jQuery(document).ajaxStop(function() {
171                jQuery('#filterCount').addClass('hidden');
172                jQuery('#filterCount').empty();
173            });
174        });
175
176          // -- Toggle tabs with select list -- //
177          jQuery('#tabsSelectList').on('change', function (e) {
178            jQuery('#selectListTabs li a').eq(jQuery(this).val()).tab('show');
179          });
180
181          // jQuery(document).ready( function () {
182          //   jQuery('body').bind('ajaxSuccess', function(data, status, xhr) {
183          //     alert('Ajax Success');
184          //   });
185          // });
186
187        //   jQuery( ".progress-step" ).first().addClass( "last-step" );
188          jQuery(".progress-step:only-child").addClass("last-step" );
189
190            jQuery('#views-exposed-form-articles-articles-listing-page label[name="topic"]').click(function(){
191                jQuery("input[id^='edit-tag-all']").prop("checked", true);
192                jQuery("form#views-exposed-form-articles-articles-listing-page").trigger('submit');
193
194            });
195
196            jQuery('#views-exposed-form-articles-articles-listing-page input[name="tag"]').click(function(){
197                jQuery("input[id^='edit-topic-all']").prop("checked", true);
198                jQuery("form#views-exposed-form-articles-articles-listing-page").trigger('submit');
199
200            });
201
202          //Submenu
203
204            // -- This makes the submenu dropdown menu appear on mouse over -- //
205            if (window.matchMedia('(min-width: 1200px)').matches) {
206                jQuery(".region-subheader .menu li.expanded").hover(
207                    function(){
208                        jQuery(this).addClass("open");
209                            },function(){
210                        jQuery(this).removeClass("open");
211                    }
212                );
213            }
214
215            //Add extra margin if submenu is on page
216            if (jQuery('.region-subheader').length) {
217                // jQuery('.feature-section').css('margin-top','90px');
218            }
219
220
221            jQuery('.region-we-mega-menu .subscribe .we-mega-menu-li').click(function(e){
222                jQuery('.region-we-mega-menu .subscribe .we-mega-menu-li').removeClass('active');
223                jQuery(this).addClass('active');
224                e.stopPropagation()
225              }
226            );
227
228            jQuery(document).on("click", function(e) {
229                if(jQuery('.region-we-mega-menu .subscribe .we-mega-menu-li').hasClass('active')){
230                    if (jQuery(e.target).is(".subscribe .we-mega-menu-submenu") === false) {
231                        jQuery(".region-we-mega-menu .subscribe .we-mega-menu-li").removeClass("active");
232                    }
233                }
234            });
235
236          //Remove hover
237          jQuery(".block-we-megamenu-blockmain").hover(function(){
238            jQuery(".region-we-mega-menu .subscribe .we-mega-menu-li").removeClass("active");
239          });
240
241          jQuery(document).ready(function() {
242              jQuery("#edit-contact-topic > .form-item-contact-topic input[name=contact_topic]").each(function(){
243                var jQuerythis = jQuery(this);
244                var itemValue = jQuerythis.val();
245                jQuerythis.closest(".form-item-contact-topic").addClass(itemValue);
246                  if (jQuerythis.is(':checked')) {
247                      jQuery(this).parent().addClass('active');
248                  }
249              });
250
251              jQuery(".section-wizard li.active-trail").prevAll().addClass("active-trail");
252
253              jQuery('#views-exposed-form-articles-articles-listing-page input[type="radio"]').each(function(i) {
254                  if(jQuery(this).is(':checked')) {
255                      jQuery(this).parent().addClass('active');
256                  } else {
257                      jQuery(this).parent().removeClass('active');
258                  }
259              });
260
261          });
262
263            jQuery('.nhsc_contact_us .form-type-radio label').click(function(){
264                jQuery('.nhsc_contact_us .form-type-radio label').removeClass('active');
265                jQuery(this).addClass('active');
266                // if (jQuery(this).is(':checked'))
267                // {
268                //     jQuery('#webform-submission-contact-us-add-form input[type="radio"]').parent().removeClass('active');
269                //     jQuery(this).parent().addClass('active');
270                // }
271            });
272
273            jQuery('#menu-mobile-toggle').click(function(){
274                jQuery(this).toggleClass('active');
275                jQuery('#menu-mobile-panel').toggleClass('open');
276            });
277
278            //Health Management Listing page blocks start
279            var minTop = 40;
280
281            var colorpanel = '.color-panel';
282            var textwrapper = '.text-wrapper';
283            var mcpb_1 = 'mcpb_1';
284
285            jQuery(".MedicalConditionPushBlock")
286            // Mouse enter event
287                .mouseenter(function() {
288                    jQuery(this).find(colorpanel).stop().animate({
289                        height: jQuery(this).height() + 'px'
290                    });
291                    jQuery(this).find(textwrapper).stop().animate({
292                        top: minTop + 'px'
293                    });
294                    jQuery(this).toggleClass(mcpb_1);
295                })
296                // Mouse leave event
297                .mouseleave(function() {
298                    var s_push = jQuery(this).height();
299                    var s_title = jQuery(this).find(".title").height();
300                    var t = s_push - s_title - 30;
301                    jQuery(this).find(colorpanel).stop().animate({
302                        height: '10px'
303                    });
304                    jQuery(this).find(textwrapper).stop().animate({
305                        top: t + 'px'
306                    });
307                    jQuery(this).toggleClass(mcpb_1);
308                })
309                // Click leave event
310                .click(function () {
311                    if (jQuery(this).hasClass(mcpb_1)) {
312                        var s_push = jQuery(this).height();
313                        var s_title = jQuery(this).find(".title").height();
314                        var t = s_push - s_title - 30;
315
316                        jQuery(this).find(colorpanel).stop().animate({
317                            height: '10px'
318                        });
319                        jQuery(this).find(textwrapper).stop().animate({
320                            top: t + 'px'
321                        });
322                        jQuery(this).toggleClass(mcpb_1);
323                    } else {
324                        jQuery(this).find(colorpanel).stop().animate({
325                            height: jQuery(this).height() + 'px'
326                        });
327                        jQuery(this).find(textwrapper).stop().animate({
328                            top: minTop + 'px'
329                        });
330                        jQuery(this).toggleClass(mcpb_1);
331                    }
332                });
333            // jQuery(".MedicalConditionPushBlock").on("mouseenter mouseleave click", MedicalConditionPushBlockEffect);
334
335            //Basic page expand to full width if no block on the side
336            if (!(jQuery('.view-nhsc-master-text-slider-new-view').html() || '').trim().length ) {
337                jQuery('#left-col').removeClass('col-xs-12 col-sm-8 col-md-8 col-lg-8 ').addClass('col-xs-12 col-sm-12 col-md-12 col-lg-12 ');
338            }
339
340            // Country Switcher
341            jQuery('#block-country-switcher .country-switcher-toggle').off("click").on("click", function(){
342                jQuery('body').toggleClass('country-switcher-open');
343            });
344
345            jQuery('#block-country-switcher .region h3').off("click").on("click", function(){
346                if (jQuery(this).parent('.region').hasClass('open')) {
347                    jQuery(this).parent('.region').removeClass('open');
348                } else {
349                    jQuery('#block-country-switcher .region').removeClass('open');
350                    jQuery(this).parent('.region').addClass('open');
351                }
352            });
353
354            // -- Change data-style -- //
355            jQuery('[data-style]').each(function(){
356                var style = jQuery(this).attr('data-style');
357                jQuery(this).attr('style', style);
358            });
359
360            // Article Filter Dropdown
361            jQuery("#articleFilterDropdown .form-item label div").click(function () {
362                var text = jQuery(this).text();
363
364                jQuery(document).ajaxComplete(function (event, data) {
365                    jQuery("#articleFilterButton span").text(text);
366                  });
367
368            });
369
370            // DSU Engage Form - Radio button active state
371            jQuery('.dsu-engage-form input[type="radio"]').each(function() {
372                var $radio = jQuery(this);
373                var $label = $radio.closest('label');
374                
375                // Set initial active state
376                if ($radio.is(':checked')) {
377                    $label.addClass('active');
378                }
379                
380                // Toggle active on click/change
381                $radio.off('change.dsu-active').on('change.dsu-active', function() {
382                    var name = jQuery(this).attr('name');
383                    // Remove active from all labels in this radio group
384                    jQuery('.dsu-engage-form input[name="' + name + '"]').closest('label').removeClass('active');
385                    // Add active to the checked one
386                    if (jQuery(this).is(':checked')) {
387                        jQuery(this).closest('label').addClass('active');
388                    }
389                });
390            });
391
392        }
393
394    };
395
396})(jQuery, Drupal, drupalSettings);
397
398//Accordion
399function toggleme(divID,buttonID) {
400    var style = document.getElementById(divID).style.display;
401    if(style == 'none'){
402            jQuery('#'+divID).slideDown("slow");
403            jQuery('#'+buttonID).addClass('faq-active');
404
405            if (jQuery(window).width() >= 1000) {
406                jQuery('.paragraph--type--nhsc-comparison-table').each(function(){
407                    var heights = jQuery("div.equal-row").map(function ()
408                    {
409                        return jQuery(this).height();
410                    }).get();
411                    highestBox = Math.max.apply(null, heights);
412
413                    jQuery('.equal-row', this).height(highestBox);
414
415                });
416            }
417
418    } else{
419            jQuery('#'+divID).slideUp("slow");
420            jQuery('#'+buttonID).removeClass('faq-active');
421    }
422}
423
424//Health Management Listing page blocks start
425MedicalConditionPushBlockEffect = function(event) {
426    var _elm = event.currentTarget;
427    var minTop = 40;
428    var s_push = jQuery(_elm).height();
429    var s_title = jQuery(_elm).find(".title").height();
430    var t = s_push - s_title - 30;
431    if (!IsTouchDevice() && event.type == "mouseenter") {
432        jQuery(_elm).find(".color-panel").stop().animate({
433            height: jQuery(".MedicalConditionPushBlock").height() + 'px'
434        });
435        jQuery(_elm).find(".text-wrapper").stop().animate({
436            top: minTop + 'px'
437        });
438        jQuery(_elm).toggleClass("mcpb_1");
439    } else if (!IsTouchDevice() && event.type == "mouseleave") {
440        jQuery(_elm).find(".color-panel").stop().animate({
441            height: '10px'
442        });
443        jQuery(_elm).find(".text-wrapper").stop().animate({
444            top: t + 'px'
445        });
446        jQuery(_elm).toggleClass("mcpb_1");
447    } else if (IsTouchDevice() && event.type == "click") {
448        if (jQuery(_elm).hasClass("mcpb_1")) {
449            jQuery(_elm).find(".color-panel").stop().animate({
450                height: '10px'
451            });
452            jQuery(_elm).find(".text-wrapper").stop().animate({
453                top: t + 'px'
454            });
455            jQuery(_elm).toggleClass("mcpb_1");
456        } else {
457            jQuery(_elm).find(".color-panel").stop().animate({
458                height: jQuery(".MedicalConditionPushBlock").height() + 'px'
459            });
460            jQuery(_elm).find(".text-wrapper").stop().animate({
461                top: minTop + 'px'
462            });
463            jQuery(_elm).toggleClass("mcpb_1");
464        }
465    }
466
467};
468
469
470jQuery(window).on('load',function() {
471
472    jQuery(".MedicalConditionPushBlock").each(function() {
473
474        var s_push = jQuery(this).height();
475        var s_title = jQuery(this).find(".title").height();
476        var t = s_push - s_title - 30;
477
478        jQuery(this).find(".text-wrapper").css({
479            top: t + 'px'
480        });
481
482        jQuery(this).find(".text-wrapper").css('visibility', 'visible');
483
484    });
485
486});
487
488//Health Management Listing page blocks ends
489
490/*var maxHeight = 0;
491
492jQuery(".we-mega-menu-submenu-inner").each(function(){
493    if (jQuery(this).height() > maxHeight) { maxHeight = jQuery(this).height(); }
494});
495
496jQuery(".we-mega-menu-submenu-inner").height(maxHeight);*/

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.