PageSourceSearch

https://www.nakheel.com/ResourcePackages/NakheelComponents/assets/…/way-of-life.js?package=NakheelComponents

js nakheel.com collected 2026-10-02 04:47:51 UTC 5,086 bytes, 136 lines download raw bytes

1(function ($) { //an IIFE so safely alias jQuery to $
2    $.WayOfLife = function (element) {
3
4        //stores the passed element as a property of the created instance.
5        this.IsMobile = false;
6        this.Swiper;
7        if (element instanceof $) {
8            this.element = element
9        } else {
10            this.element = $(element);
11            this.elementSelector = element;
12        }
13    };
14
15    //assigning an object literal to the prototype is a shorter syntax
16    //than assigning one property at a time
17    $.WayOfLife.prototype = {
18        Init: function () {
19            if (this.element.length == 0) { return; }
20
21            this.InitSwiper();
22            var that = this;
23            //$(window).resize(function () {
24            //    that.InitSwiper();
25            //});
26
27            $('#wayoflife-next').on('click', function () {
28                $('.wayoflife-next').trigger('click');
29            });
30            $('#wayoflife-prev').on('click', function () {
31                $('.wayoflife-prev').trigger('click');
32            });
33
34            let selectedVideo;
35            this.element.find('.tile').on('click', function () {
36                let tile = $(this);
37                let currentVideo = tile.find("video").get(0);
38                let videoThumbnail = tile.find(".bg-image");
39                if (selectedVideo && (selectedVideo.src != currentVideo.src)) {
40                    let prevTitle = $(selectedVideo).parent(".tile");
41                    selectedVideo.pause();
42                    selectedVideo.currentTime = 0;
43
44                    prevTitle.find(".playicon").removeClass('d-none');
45                    prevTitle.removeClass('hide');
46                    prevTitle.find(".bg-image").removeClass('d-none');
47                }
48
49                let selectedPlayIcon = tile.find(".playicon");
50                selectedVideo = currentVideo;
51                selectedVideo.onended = function () {
52                    selectedVideo.currentTime = 0;
53                    selectedPlayIcon.removeClass('d-none');
54                    videoThumbnail.removeClass('d-none');
55                    tile.removeClass('hide');
56                };
57
58                if (selectedVideo.paused) {
59                    selectedVideo.play();
60                    selectedPlayIcon.addClass('d-none');
61                    videoThumbnail.addClass('d-none');
62                    tile.addClass('hide');
63                } else {
64                    selectedVideo.pause();
65                    selectedPlayIcon.removeClass('d-none');
66                    videoThumbnail.removeClass('d-none');
67                    tile.removeClass('hide');
68                }
69            });
70        },
71        InitSwiper: function () {
72            if (window.screen.availWidth < 1025 || window.innerWidth < 1025) {
73                this.element.find('.swiper-slide').hide();
74                let videoTiles = this.element.find('.tile');
75                let items = videoTiles.map((index, item) => '<div class="swiper-slide"><div class="grid-outer"><div class="full-tile"><div class="tile">' + item.innerHTML.split('\n').join("") + '</div></div></div></div>');
76                new Swiper(this.elementSelector,
77                    {
78                        //slidesPerView: 1,
79                        loop: false,
80                        navigation: {
81                            nextEl: ".swiper-button-next",
82                            prevEl: ".swiper-button-prev"
83                        },
84                        pagination: {
85                            el: ".wayoflife-pagination",
86                        }
87                    });
88
89                this.Swiper = document.querySelector(this.elementSelector).swiper;
90                this.Swiper.appendSlide(items);
91            } else {
92                new Swiper(this.elementSelector, $.WayOfLife.defaultOptions);
93                this.Swiper = document.querySelector(this.elementSelector).swiper;
94            }
95        }
96    };
97
98    $.WayOfLife.defaultOptions = {
99        slidesPerView: "auto",
100        loop: false,
101        navigation: {
102            nextEl: ".swiper-button-next",
103            prevEl: ".swiper-button-prev"
104        },
105        pagination: {
106            el: ".wayoflife-pagination",
107            clickable: true
108        },
109        lazy: {
110            //  tell swiper to load images before they appear
111            loadPrevNext: true,
112            // amount of images to load
113            loadPrevNextAmount: 4,
114        },
115        //breakpoints: {
116        //    // 567: {
117        //    //   slidesPerView: 1,
118        //    //   spaceBetween: 0,
119        //    // },
120        //    // 768: {
121        //    //   slidesPerView: 2,
122        //    //   spaceBetween: 25,
123        //    // },
124        //    1024: {
125        //        slidesPerView: 1,
126        //        spaceBetween: 0,
127        //    },
128        //},
129    };
130
131}(jQuery));
132
133var wayOfLife = new $.WayOfLife(".swiper-wayoflife");
134wayOfLife.Init();
135
136

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.