PageSourceSearch

https://www.nri.com/cn/Scripts/newTop.js?d=202007

js nri.com collected 2026-09-24 08:28:08 UTC 19,042 bytes, 526 lines download raw bytes

1$(function () {
2
3    //Check knowledge area has articles
4    var knowledgeArea = $("div.wrap-knowledgeInsight-inner");
5    var publicationArea = $("div.wrap-publishment");
6    if (knowledgeArea.length == 0 && publicationArea.length == 0) {
7        if ($("div.wrap-knowledgeInsight").length > 0) {
8            $("div.wrap-knowledgeInsight").remove();
9        }
10    }
11
12    // change Text Area format
13    function ChangeTextAreaFormat() {
14        var listTextArea = $(".top-text-area");
15        var isSP = $(window).width() < 768;
16        if (listTextArea.length > 0) {
17            listTextArea.each(function (i,v) {
18                var textId = $(v).attr("id");
19                switch (textId) {
20                    case "text-area-1":
21                        $(v).css("margin-top", isSP ? "40px" : "120px");
22                        break;
23                    case "text-area-2":
24                        $(v).css("margin-top", "140px");
25                        break;
26                    case "text-area-3":
27                        if ($("div.wrap-knowledgeInsight").length == 0) {
28                            $(v).css("margin-top", isSP ? "40px" : "140px");
29                        }
30                        $(v).css("margin-bottom", "120px");
31                        break;
32                    default:
33                }
34            });
35        }
36
37    }
38
39    // main slider
40    var mainSlider = $('.list-mainSlider'),
41        dotsPosition = 20;
42    function mainSliderAdapt() {
43        var d = new $.Deferred;
44        mainSlider.slick({
45            lazyLoad: 'ondemand',
46            dots: true,
47            autoplay: true,
48            autoplaySpeed: 6000,
49            speed: 1300,
50            pauseOnHover: false,
51            appendDots: $('.wrap-slick-dots'),
52            responsive: [
53                {
54                    breakpoint: 768,
55                    settings: {
56                        arrows: false
57                    }
58                }
59            ]
60        });
61        d.resolve();
62        return d.promise();
63    }
64
65    function mainSliderContentControll() {
66        $('.l-mainSlider-content').removeClass('is-transformed');
67        $('.slick-current').find('.l-mainSlider-content').addClass('is-transformed');
68    }
69
70    mainSlider.on('init afterChange', function () {
71        mainSliderContentControll();
72    });
73
74    $(window).on('load resize orientationchange', function () {
75        mainSliderContentControll();
76        //ChangeTextAreaFormat();
77    });
78
79    mainSliderAdapt().then(function () {
80        var slickDots = $('.wrap-slick-dots'),
81            slickDotsPosition = slickDots.offset().top,
82            mainSliderBottomPosition = mainSlider.offset().top + mainSlider.outerHeight();
83
84        if (fixedBritain[0]) {
85            dotsPosition += fixedBritainListFirstHeight;
86        }
87
88        if ($(window).height() <= mainSliderBottomPosition && $(window).scrollTop() <= mainSlider.offset().top) {
89            slickDots.css({
90                position: 'fixed',
91                top: $(window).outerHeight() - dotsPosition
92            });
93        } else {
94            slickDots.css({
95                position: 'relative',
96                top: 0
97            });
98        }
99
100        $(window).on('resize orientationchanged', function () {
101
102            mainSliderBottomPosition = mainSlider.offset().top + mainSlider.outerHeight();
103
104            if ($(window).height() <= mainSliderBottomPosition && $(window).scrollTop() <= mainSlider.offset().top) {
105                slickDots.css({
106                    position: 'fixed',
107                    top: $(window).outerHeight() - dotsPosition
108                });
109            } else {
110                slickDots.css({
111                    position: 'relative',
112                    top: 0
113                });
114            }
115        });
116
117
118        $(window).on('scroll', function () {
119            if ($(window).height() <= fixedBritainPosition) {
120
121                var pointObject;
122
123                if ($(window).scrollTop() >= mainSliderBottomPosition - $(window).height()) {
124                    slickDots.css({
125                        position: 'relative',
126                        top: 0
127                    });
128                } else {
129                    if ($(window).height() <= fixedBritainPosition && $(window).scrollTop() <= fixedBritainPosition - fixedBritain.outerHeight()) {
130                        slickDots.css({
131                            position: 'fixed',
132                            top: $(window).outerHeight() - dotsPosition
133                        });
134                    } else {
135                        slickDots.css({
136                            position: 'fixed',
137                            top: $(window).outerHeight() - dotsPosition
138                        });
139                    }
140                }
141            } else {
142                if ($(window).scrollTop() >= mainSliderBottomPosition - $(window).height()) {
143                    slickDots.css({
144                        position: 'relative',
145                        top: 0
146                    });
147                } else {
148                    slickDots.css({
149                        position: 'fixed',
150                        top: $(window).outerHeight() - dotsPosition
151                    });
152                }
153            }
154        });
155    });
156
157    // .list-news
158    borderColorChange('.list-news a');
159    //new slick sdd
160    function newSlickSDD(element) {
161
162        var _sdd = element,
163            _sddList = _sdd.find('li'),
164            _sddwrapDots = element.next().find('.wrap-ssd-slick-dots');
165
166        if (_sddList.length > 1) {
167            if (_sddList.length <= 3) {
168                _sdd.slick({
169                    lazyLoad: 'progressive',
170                    dots: true,
171                    arrows: false,
172                    centerMode: true,
173                    variableWidth: true,
174                    slidesToShow: 1,
175                    autoplay: true,
176                    autoplaySpeed: 6000,
177                    pauseOnHover: false,
178                    draggable: false,
179                    appendDots: _sddwrapDots,
180                    responsive: [
181                        {
182                            breakpoint: 1600,
183                            settings: {
184                                slidesToShow: 1,
185                                centerMode: false,
186                                centerPadding: '0'
187                            }
188                        }
189                    ]
190                });
191
192                _sdd.on('init', function () {
193                    _sdd.slick('slickSetOption', 'slidesToShow', 3, true);
194                });
195            } else {
196                _sdd.slick({
197                    lazyLoad: 'progressive',
198                    dots: true,
199                    arrows: false,
200                    centerMode: true,
201                    variableWidth: true,
202                    slidesToShow: 3,
203                    autoplay: true,
204                    autoplaySpeed: 6000,
205                    pauseOnHover: false,
206                    draggable: false,
207                    appendDots: _sddwrapDots,
208                    responsive: [
209                        {
210                            breakpoint: 1600,
211                            settings: {
212                                slidesToShow: 1,
213                                centerMode: false,
214                                centerPadding: '0'
215                            }
216                        }
217                    ]
218                });
219            }
220        } else {
221            _sdd.parent().css('text-align', 'center');
222        }
223
224        var slideDiscription = element.next().find('.wrap-sdd-content-inner').find('li');
225        _sdd.on('beforeChange', function (slick, currentSlide, nextSlide) {
226            _sdd.find('.slick-current').addClass('before-slide');
227            slideDiscription.fadeOut();
228        });
229        _sdd.on('afterChange', function (slick, currentSlide, nextSlide) {
230            var currentContent = _sdd.find('.slick-current').data('slide');
231            $('.slick-current').removeClass('before-slide');
232            _sdd.find('.before-slide').css({
233                opacity: 0.2
234            });
235            $('.' + currentContent).fadeIn();
236        });
237    }
238    // co-worker slider
239    newSlickSDD($('.list-co-creation'));
240
241    // relative Header Position
242    var header = $('#l-globalHeader');
243    relativeHeaderPosition(header);
244    $(window).on('load resize orientationchange', function () {
245        relativeHeaderPosition(header);
246    });
247
248    // britain Controll
249    if ($('.list-britain')[0]) {
250        $('.link-britain-close').on('click',
251            function () {
252                $(this).parent('li').remove();
253                if ($('.list-britain li').length == 0) {
254                    $('.list-britain').remove();
255                }
256            });
257    }
258    var fixedBritain = $('.list-fixed-britain'),
259        fixedBritainWidth,
260        fixedBritainPosition,
261        fixedBritainListFirstHeight;
262    function initialFixedBritainPosition() {
263        var d = new $.Deferred;
264        fixedBritainListFirstHeight = fixedBritain.find('li').first().outerHeight();
265        fixedBritainWidth = fixedBritain.outerWidth();
266        fixedBritainPosition = fixedBritain.offset().top;
267        d.resolve();
268        return d.promise();
269    }
270    function fixedBritainPositionControll() {
271        fixedBritainWidth = fixedBritain.outerWidth();
272        if ($(window).height() <= fixedBritainPosition) {
273            if ($(window).scrollTop() <= mainSlider.offset().top - fixedBritainListFirstHeight) {
274                fixedBritain.css({
275                    position: 'fixed',
276                    left: '50%',
277                    marginLeft: '-' + fixedBritainWidth / 2 + 'px',
278                    top: $(window).outerHeight() - fixedBritainListFirstHeight
279                });
280            } else {
281                fixedBritain.css({
282                    position: 'static',
283                    marginLeft: 'auto'
284                });
285            }
286        } else {
287            fixedBritain.css({
288                position: 'static',
289                marginLeft: 'auto'
290            });
291        }
292    }
293
294
295    afterTrasitionControll($('.ele-move-effect'));
296
297    resetHeight($('.ele-move-effect').parent()).then(function () {
298        afterTrasitionControll($('.ele-move-effect'));
299    });
300
301    $(window).on('load resize orientationchange', function () {
302        resetHeight($('.ele-move-effect').parent()).then(function () {
303            setTimeout(function () {
304                $('.ele-move-effect').each(function () {
305                    $(this).parent().css({
306                        'height': $(this).outerHeight()
307                    });
308                });
309            }, 310);
310        });
311    });
312
313    var wrapReport = $('.wrap-newsList'),
314        wrapEvent = $('.wrap-eventList'),
315        wrapListNriJournal = $('.wrap-nriJournal-animate'),
316        wrapCoCreation = $('.wrap-co-creation-animate'),
317        wrapKnowledgeInsight = $('.wrap-knowledgeInsight'),
318        wrapReportPosition = wrapReport.length == 0 ? 0 : wrapReport.offset().top,
319        wrapEventPosition = wrapEvent.length == 0 ? 0 : wrapEvent.offset().top,
320        wrapListNriJournalPosition = wrapListNriJournal.length == 0 ? 0 : wrapListNriJournal.offset().top,
321        wrapCoCreationPosition = wrapCoCreation.length == 0 ? 0 : wrapCoCreation.offset().top,
322        wrapKnowledgeInsightPosition = wrapKnowledgeInsight.length == 0 ? 0 : wrapKnowledgeInsight.offset().top;
323
324    function adaptContentHeight() {
325        var d = new $.Deferred();
326
327        $('.ele-move-effect').each(function () {
328            $(this).parent().css({
329                'height': $(this).outerHeight()
330            });
331        });
332
333        wrapReport.height($('.l-newsList').outerHeight());
334        wrapEvent.height($('.l-eventList').outerHeight());
335        wrapListNriJournal.height($('.wrap-nriJournal').outerHeight());
336        wrapCoCreation.height($('.wrap-co-creation').outerHeight());
337        wrapKnowledgeInsight.height($('.wrap-knowledgeInsight-scroll').outerHeight());
338        d.resolve();
339        return d.promise();
340    }
341
342    function scrollEffect() {
343        var windowHeight = $(window).outerHeight(),
344            scrollAmount = $(window).scrollTop();
345
346        if ($(window).width() < 768) {
347            scrollJudgePoint = wrapReportPosition - windowHeight / 2;
348
349            if (scrollAmount >= scrollJudgePoint && wrapReport.length > 0) {
350                $('.wrap-newsList-inner').css({
351                    bottom: 0,
352                    opacity: 1
353                });
354                scrollJudgePoint += wrapReport.height();
355            }
356
357            if (scrollAmount >= scrollJudgePoint && wrapEvent.length > 0) {
358                $('.wrap-eventList-inner').css({
359                    bottom: 0,
360                    opacity: 1
361                });
362                scrollJudgePoint += wrapEvent.height() + 100;
363            }
364
365            if (scrollAmount >= scrollJudgePoint && wrapListNriJournal.length > 0) {
366                $('.wrap-nriJounral-animate-inner').css({
367                    bottom: 0,
368                    opacity: 1
369                });
370                $('.wrap-nriJounral-animate-inner').on('transitionend', function () {
371                    $('.list-nriJounal').css({
372                        top: 0,
373                        opacity: 1
374                    });
375                });
376                scrollJudgePoint += wrapListNriJournal.height() + 50;
377            }
378
379            if (scrollAmount >= scrollJudgePoint && wrapCoCreation.length > 0) {
380                $('.wrap-co-creation-animate-inner').css({
381                    bottom: 0,
382                    opacity: 1
383                });
384                scrollJudgePoint += wrapCoCreation.height() + 100;
385            }
386
387            if (scrollAmount >= scrollJudgePoint) {
388                $('.wrap-knowledgeInsight-scroll').css({
389                    bottom: 0,
390                    opacity: 1
391                });
392            }
393
394            if (scrollAmount >= $('.wrap-knowledgeInsight-inner').offset().top - $(window).height() / 2) {
395                groupFadeHeight().then(function () {
396                    $('.list-knowledgeInsight').css({
397                        top: 0,
398                        opacity: 1
399                    });
400                });
401            }
402
403
404            if (scrollAmount >= $('.wrap-publishment').offset().top - $(window).height() / 2) {
405                groupFadeHeight().then(function () {
406                    $('.list-publishment').css({
407                        top: 0,
408                        opacity: 1
409                    });
410                });
411            }
412
413
414        } else {
415            var subPx = $(window).height() > 400 ? 100 : $(window).height() / 4;
416            scrollAmount += $(window).height() - subPx;
417            wrapReportPosition = wrapReport.length == 0 ? 0 : wrapReport.offset().top,
418                wrapEventPosition = wrapEvent.length == 0 ? 0 : wrapEvent.offset().top,
419                wrapListNriJournalPosition = wrapListNriJournal.length == 0 ? 0 : wrapListNriJournal.offset().top,
420                wrapCoCreationPosition = wrapCoCreation.length == 0 ? 0 : wrapCoCreation.offset().top,
421                wrapKnowledgeInsightPosition = wrapKnowledgeInsight.length == 0 ? 0 : wrapKnowledgeInsight.offset().top;
422            if ($(window).height() >= wrapReportPosition) {
423                $('.wrap-newsList-inner').css({
424                    bottom: 0,
425                    opacity: 1
426                });
427            }
428
429            if (scrollAmount >= wrapReportPosition - wrapReport.outerHeight()) {
430                $('.wrap-newsList-inner').css({
431                    bottom: 0,
432                    opacity: 1
433                });
434            }
435
436            if (scrollAmount >= wrapEventPosition - wrapEvent.outerHeight()) {
437                $('.wrap-eventList-inner').css({
438                    bottom: 0,
439                    opacity: 1
440                });
441            }
442
443            if (scrollAmount >= wrapListNriJournalPosition) {
444                $('.wrap-nriJounral-animate-inner').css({
445                    bottom: 0,
446                    opacity: 1
447                });
448                $('.wrap-nriJounral-animate-inner').on('transitionend', function () {
449                    $('.list-nriJounal').css({
450                        top: 0,
451                        opacity: 1
452                    });
453                });
454            }
455
456            if (scrollAmount >= wrapCoCreationPosition) {
457                $('.wrap-co-creation-animate-inner').css({
458                    bottom: 0,
459                    opacity: 1
460                });
461            }
462            if (scrollAmount >= wrapKnowledgeInsightPosition) {
463                $('.wrap-knowledgeInsight-scroll').css({
464                    bottom: 0,
465                    opacity: 1
466                });
467            }
468
469            if (scrollAmount - $(window).height() / 3 >= $('.wrap-knowledgeInsight-inner').offset().top) {
470                groupFadeHeight().then(function () {
471                    $('.list-knowledgeInsight').css({
472                        top: 0,
473                        opacity: 1
474                    });
475                });
476            }
477
478
479            if (scrollAmount - $(window).height() / 3 >= $('.wrap-publishment').offset().top) {
480                groupFadeHeight().then(function () {
481                    $('.list-publishment').css({
482                        top: 0,
483                        opacity: 1
484                    });
485                });
486            }
487
488        }
489
490    }
491
492    function groupFadeHeight() {
493        var d = new $.Deferred();
494        var $groupFade = $('.group-fade');
495        //setTimeout(function () {
496        $groupFade.each(function () {
497            var _fadeHeight = $(this).find('ul').outerHeight();
498            $(this).css('height', _fadeHeight);
499        });
500        //}, 300);
501        d.resolve();
502        return d.promise();
503    }
504
505    groupFadeHeight();
506
507    adaptContentHeight().then(scrollEffect);
508
509    $(window).on('scroll resize orientationchange', function () {
510        groupFadeHeight();
511        adaptContentHeight().then(scrollEffect);
512    });
513
514
515    if (fixedBritain[0]) {
516        initialFixedBritainPosition().then(fixedBritainPositionControll);
517
518        $(window).on('load resize orientationchange', function () {
519            fixedBritainPositionControll();
520        });
521
522        $(window).on('scroll', function () {
523            fixedBritainPositionControll();
524        });
525    }
526});

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.