PageSourceSearch

https://cdn-resources.ableton.com/80bA26cPQ1hEJDFjpUKntxfqdmG3ZykO…/js/el-pagination.6fb3696fc792.js

js ableton.com collected 2026-09-24 08:25:49 UTC 5,818 bytes, 133 lines download raw bytes

1'use strict';
2
3(function ($) {
4
5    $.fn.endlessPaginate = function(options) {
6        var defaults = {
7            // Twitter-style pagination container selector.
8            containerSelector: '.endless_container',
9            // Twitter-style pagination loading selector.
10            loadingSelector: '.endless_loading',
11            // Twitter-style pagination link selector.
12            moreSelector: 'a.endless_more',
13            // Twitter-style pagination content wrapper selector.
14            contentSelector: null,
15            // Digg-style pagination page template selector.
16            pageSelector: '.endless_page_template',
17            // Digg-style pagination link selector.
18            pagesSelector: 'a.endless_page_link',
19            // Callback called when the user clicks to get another page.
20            onClick: function() {},
21            // Callback called when the new page is correctly displayed.
22            onCompleted: function() {},
23            // Set this to true to use the paginate-on-scroll feature.
24            paginateOnScroll: false,
25            // If paginate-on-scroll is on, this margin will be used.
26            paginateOnScrollMargin : 1,
27            // If paginate-on-scroll is on, it is possible to define chunks.
28            paginateOnScrollChunkSize: 0
29        },
30            settings = $.extend(defaults, options);
31
32        var getContext = function(link) {
33            return {
34                key: link.data("el-querystring-key").split(' ')[0],
35                url: link.attr('href')
36            };
37        };
38
39        return this.each(function() {
40            var element = $(this),
41                loadedPages = 1;
42
43            // Twitter-style pagination.
44            element.on('click', settings.moreSelector, function() {
45                var link = $(this),
46                    html_link = link.get(0),
47                    content_wrapper = element.find(settings.contentSelector),
48                    container = link.closest(settings.containerSelector),
49                    loading = container.find(settings.loadingSelector);
50                // Avoid multiple Ajax calls.
51                if (loading.is(':visible')) {
52                    return false;
53                }
54                link.hide();
55                loading.show();
56                var context = getContext(link);
57                // Fire onClick callback.
58                if (settings.onClick.apply(html_link, [context]) !== false) {
59                    var data = 'querystring_key=' + context.key;
60                    // Send the Ajax request.
61                    $.get(context.url, data, function (fragment) {
62                        // Increase the number of loaded pages.
63                        loadedPages += 1;
64
65                        if (!content_wrapper.length) {
66                            // Replace pagination container (the default behavior)
67                            container.before(fragment);
68                            container.remove();
69                        } else {
70                            // Insert the content in the specified wrapper and increment link
71                            content_wrapper.append(fragment);
72                            var nextPage = 'page=' + (loadedPages + 1);
73                            link.attr('href', link.attr('href').replace(/page=\d+/, nextPage));
74                            link.show();
75                            loading.hide();
76                        }
77
78                        // Fire onCompleted callback.
79                        settings.onCompleted.apply(
80                            html_link, [context, $.trim(fragment)]);
81                    }).fail(function (xhr, textStatus, error) {
82                        // Remove the container left if any
83                        container.remove();
84                    });
85                }
86                return false;
87            });
88
89            // On scroll pagination.
90            if (settings.paginateOnScroll) {
91                var win = $(window),
92                    doc = $(document);
93                doc.on('scroll', function () {
94                    if (doc.height() - win.height() -
95                        win.scrollTop() <= settings.paginateOnScrollMargin) {
96                        // Do not paginate on scroll if chunks are used and
97                        // the current chunk is complete.
98                        var chunckSize = settings.paginateOnScrollChunkSize;
99                        if (!chunckSize || loadedPages % chunckSize) {
100                            element.find(settings.moreSelector).trigger('click');
101                        } else {
102                            element.find(settings.moreSelector).addClass('endless_chunk_complete');
103                        }
104                    }
105                });
106            }
107
108            // Digg-style pagination.
109            element.on('click', settings.pagesSelector, function() {
110                var link = $(this),
111                    html_link = link.get(0),
112                    context = getContext(link);
113                // Fire onClick callback.
114                if (settings.onClick.apply(html_link, [context]) !== false) {
115                    var page_template = link.closest(settings.pageSelector),
116                        data = 'querystring_key=' + context.key;
117                    // Send the Ajax request.
118                    page_template.load(context.url, data, function(fragment) {
119                        // Fire onCompleted callback.
120                        settings.onCompleted.apply(
121                            html_link, [context, $.trim(fragment)]);
122                    });
123                }
124                return false;
125            });
126        });
127    };
128
129    $.endlessPaginate = function(options) {
130        return $('body').endlessPaginate(options);
131    };
132
133})(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.