View | Details | Raw Unified | Return to bug 29397
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/select2.js (-1 / +30 lines)
Lines 37-39 $(document).ready(function(){ Link Here
37
        });
37
        });
38
    });
38
    });
39
});
39
});
40
- 
40
41
/* wrapper that nests paging information into the results object for use with koha REST apis */
42
(function($) {
43
    $.fn.kohaSelect = function(config) {
44
        if (config.hasOwnProperty('ajax')) {
45
            config.ajax.transport = function(params, success, failure) {
46
                var read_headers = function(data, textStatus, jqXHR) {
47
                    var more = false;
48
                    var link = jqXHR.getResponseHeader('Link') || '';
49
                    if (link.search(/<([^>]+)>;\s*rel\s*=\s*['"]?next['"]?\s*(,|$)/i) > -1) {
50
                        more = true;
51
                    }
52
53
                    return {
54
                        results: data,
55
                        pagination: {
56
                            more: more
57
                        }
58
                    };
59
                };
60
                var $request = $.ajax(params);
61
                $request.then(read_headers).then(success);
62
                $request.fail(failure);
63
64
            };
65
        }
66
67
        $(this).select2(config);
68
    };
69
})(jQuery);

Return to bug 29397