PageSourceSearch

https://www.cambridgeassessment.org.uk/js/ucles.jquery.multi-media.js

js cambridgeassessment.org.uk collected 2026-09-24 18:05:14 UTC 9,855 bytes, 292 lines download raw bytes

1/*global $, jQuery*/
2/*global jwplayer, jwplayer*/
3/*global window, js*/
4(function ($) {
5    "use strict";
6
7    function getStandardPlayerSetup(item) {
8        var setup = {
9            width: '100%',
10            aspectratio: '16:9',
11            base: '/js/',
12            abouttext: 'us',
13            aboutlink: '/about-us/',
14            sharing: {},
15            events: {
16                onPlaylistItem: function (index, items) {
17                    replaceSharing(index.id);
18                }
19            }
20        },
21            iesettings = {
22                primary: 'flash'
23            },
24
25            title = $(item).find("[itemprop='name']"),
26            description = $(item).find("[itemprop='description']"),
27            image = $(item).find("[itemprop='thumbnailUrl'], [itemprop='thumbnail']"),
28            aspectRatio = $(item).find("[itemprop='aspectRatio']"),
29            urls = $(item).find("[itemprop='contentUrl']"),
30            transcript = $(item).find("[itemprop='transcript']"),
31			//Storing caption file name inside a variable 
32			caption = $(item).find("[itemprop='video_subtitle']");
33
34        if ($('html').hasClass('lte9') || $('html').hasClass('ie')) {
35            $.extend(setup, iesettings);
36        }
37
38        if (title.length > 0) {
39            setup.title = title.attr("content");
40        }
41
42        if (description.length > 0) {
43            setup.description = description.attr("content");
44        }
45
46        if (image.length > 0) {
47            setup.image = image.attr("content");
48        } else {
49            setup.height = 24;
50        }
51
52        if (aspectRatio.length > 0) {
53            setup.aspectratio = aspectRatio.attr("content");
54        }
55
56        if (urls.length > 0) {
57            if (urls.length > 1) {
58                setup.sources = [{
59                    file: $(urls[1]).attr("content")
60                }, {
61                    file: $(urls[0]).attr("content")
62                }];
63            } else {
64                setup.file = $(urls[0]).attr("content");
65            }
66        }
67
68        if (transcript.length > 0) {
69            setup.transcript = transcript.attr("content");
70        }
71
72        //checking the length of the caption
73        if (caption.length > 0) {
74            //Extracting caption file name 
75            setup.caption = caption.attr("content");
76            //Adding caption file
77            setup.tracks = [{
78                file: setup.caption,
79                label: "English",
80                kind: "captions",
81                "default": true
82            }]
83        }
84        return setup;
85    }
86
87    $(document).on("click", ".jwplayer button", function (event) {
88        event.preventDefault();
89    });
90
91    function getFancyboxPlayerSetup(item) {
92        var setup = {
93            width: '100%',
94            aspectratio: '16:9',
95            autostart: true,
96            base: '/js/',
97            abouttext: 'us',
98            aboutlink: '/about-us/',
99            sharing: {},
100            events: {
101                onPlaylistItem: function (index, items) {
102                    replaceSharing(index.id);
103                }
104            }
105        },
106            title = $(item).find("[itemprop='name']"),
107            description = $(item).find("[itemprop='description']"),
108            image = $(item).find("[itemprop='thumbnailUrl'], [itemprop='thumbnail']"),
109            aspectRatio = $(item).find("[itemprop='aspectRatio']"),
110            urls = $(item).find("[itemprop='contentUrl']"),
111            transcript = $(item).find("[itemprop='transcript']"),
112			//Storing caption message inside a variable 
113			caption = $(item).find("[itemprop='video_subtitle']"),
114            iesettings = {
115                primary: 'flash'
116            };
117
118        if ($('html').hasClass('lte9')) {
119            $.extend(setup, iesettings);
120        }
121
122
123        if (title.length > 0) {
124            setup.title = title.attr("content");
125        }
126
127        if (description.length > 0) {
128            setup.description = description.attr("content");
129        }
130
131        if (image.length > 0) {
132            setup.image = image.attr("content");
133        } else {
134            setup.height = 24;
135        }
136
137        if (aspectRatio.length > 0) {
138            setup.aspectratio = aspectRatio.attr("content");
139        }
140
141        if (urls.length > 0) {
142            if (urls.length > 1) {
143                setup.sources = [{
144                    file: $(urls[1]).attr("content")
145                }, {
146                    file: $(urls[0]).attr("content")
147                }];
148            } else {
149                setup.file = $(urls[0]).attr("content");
150            }
151        }
152        //checking the length of the caption
153        if (caption.length > 0) {
154            //Extracting caption file name 
155            setup.caption = caption.attr("content");
156            //Adding caption file
157            setup.tracks = [{
158                file: setup.caption,
159                label: "English",
160                kind: "captions",
161                "default": true
162            }]
163        }
164
165        if (transcript.length > 0) {
166            setup.transcript = transcript.attr("content");
167        }
168        return setup;
169    }
170
171    function loadItem(item, start, componentId) {
172        $('.item').removeClass('active');
173        $(item).addClass('active');
174
175        jwplayer(componentId).setup(getStandardPlayerSetup(item));
176
177        $('.now-playing').html($(item).find(".now-playing-item").html());
178
179        if (start) {
180            jwplayer(componentId).play(true);
181        }
182    }
183
184    $.fn.addMultiMediaPlayer = function () {
185        return this.each(function (val, item) {
186            var componentId = $(item).data("componentid");
187            jwplayer(componentId).setup(getStandardPlayerSetup(item));
188        });
189    };
190
191    $.fn.addMultiMediaPlayList = function () {
192        return this.each(function (val, item) {
193            var componentId = $(item).data("componentid");
194            // Add the click handler to each li
195            $(item).children("li.item").click(function () {
196                loadItem(this, true, componentId);
197            });
198            // Make the first item ready to play
199            loadItem($(item).children("li.item")[0], false, componentId);
200        });
201    };
202
203    $.fn.addMultiMediaPlayerInLightBox = function () {
204        return this.each(function (val, item) {
205            var componentId = $(item).data("componentid"),
206                anchorSelector = "a.fancybox-panel-" + componentId,
207                panelId = "panel-" + componentId;
208
209            $(item).find(anchorSelector).fancybox({
210                'content': '<div id="' + panelId + '"></div>',
211                helpers: {
212                    overlay: {
213                        closeClick: false
214                    } // prevents closing when clicking OUTSIDE fancy box 
215                },
216                maxWidth: '100%',
217                maxHeight: '100%',
218                fitToView: false,
219                width: '70%',
220                height: '70%',
221                autoSize: false,
222                aspectRatio: true,
223                openEffect: 'none',
224                closeEffect: 'none',
225                nextEffect: 'none',
226                prevEffect: 'none',
227                afterShow: function () {
228                    jwplayer(panelId).setup(getFancyboxPlayerSetup(item));
229                    jwplayer().onReady(function () {
230                        $.fancybox.update();
231                        jwplayer().resize('100%', '97.5%');
232                    });
233                }
234            });
235        });
236    };
237
238    $.fn.addMultiMediaGalleryInLightBox = function () {
239        return this.each(function (val, item) {
240            var componentId = $(item).attr('id'),
241                ele = $(this.element),
242                parentId = ele.parent().attr("data-componentid");
243
244            $("a[class*='fancybox-panel-']", $('#' + componentId)).fancybox({
245                'content': '<div id="panel-' + componentId + '"></div>',
246                helpers: {
247                    overlay: {
248                        closeClick: false
249                    } // prevents closing when clicking OUTSIDE fancybox 
250                },
251                maxWidth: '100%',
252                maxHeight: '100%',
253                fitToView: false,
254                width: '70%',
255                height: '70%',
256                autoSize: false,
257                aspectRatio: true,
258                openEffect: 'none',
259                closeEffect: 'none',
260                nextEffect: 'none',
261                prevEffect: 'none',
262                afterShow: function () {
263                    if (!ele.hasClass("imageMedia")) {
264                        jwplayer('panel-' + componentId).setup(getFancyboxPlayerSetup($(this.element).parents('figure').first()));
265                        jwplayer().onReady(function () {
266                            $.fancybox.update();
267                            jwplayer().resize('100%', '97.5%');
268                        });
269                        //jwplayer().on('resize');
270                    }
271                }
272            });
273        });
274    };
275
276    function replaceSharing(componentId) {
277
278        var code = $(".widget-code"),
279            id = "#" + componentId + "_sharing",
280            container = $(id).children(":first");
281
282        if (code.length > 0) {
283            if (container.length > 0) {
284                container.addClass("sharing-widget");
285                container.html(code[0].innerHTML.trim());
286                if (addthis) {
287                    addthis.toolbox(id);
288                }
289            }
290        }
291    }
292}(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.