PageSourceSearch

https://shitucompany.cn/vendors/bower_components/plugins/integration/bootstrap/3/dataTables.bootstrap.js

js shitucompany.cn collected 2026-10-02 16:09:57 UTC 4,287 bytes, 186 lines download raw bytes

vendor: 4,287 bytes, lines 1-186
1/*! DataTables Bootstrap 3 integration
2 * ©2011-2014 SpryMedia Ltd - datatables.net/license
3 */
4
5/**
6 * DataTables integration for Bootstrap 3. This requires Bootstrap 3 and
7 * DataTables 1.10 or newer.
8 *
9 * This file sets the defaults and adds options to DataTables to style its
10 * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
11 * for further information.
12 */
13(function(window, document, undefined){
14
15var factory = function( $, DataTable ) {
16"use strict";
17
18
19/* Set the defaults for DataTables initialisation */
20$.extend( true, DataTable.defaults, {
21	dom:
22		"<'row'<'col-sm-6'l><'col-sm-6'f>>" +
23		"<'row'<'col-sm-12'tr>>" +
24		"<'row'<'col-sm-6'i><'col-sm-6'p>>",
25	renderer: 'bootstrap'
26} );
27
28
29/* Default class modification */
30$.extend( DataTable.ext.classes, {
31	sWrapper:      "dataTables_wrapper form-inline dt-bootstrap",
32	sFilterInput:  "form-control input-sm",
33	sLengthSelect: "form-control input-sm"
34} );
35
36
37/* Bootstrap paging button renderer */
38DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
39	var api     = new DataTable.Api( settings );
40	var classes = settings.oClasses;
41	var lang    = settings.oLanguage.oPaginate;
42	var btnDisplay, btnClass;
43
44	var attach = function( container, buttons ) {
45		var i, ien, node, button;
46		var clickHandler = function ( e ) {
47			e.preventDefault();
48			if ( !$(e.currentTarget).hasClass('disabled') ) {
49				api.page( e.data.action ).draw( false );
50			}
51		};
52
53		for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
54			button = buttons[i];
55
56			if ( $.isArray( button ) ) {
57				attach( container, button );
58			}
59			else {
60				btnDisplay = '';
61				btnClass = '';
62
63				switch ( button ) {
64					case 'ellipsis':
65						btnDisplay = '&hellip;';
66						btnClass = 'disabled';
67						break;
68
69					case 'first':
70						btnDisplay = lang.sFirst;
71						btnClass = button + (page > 0 ?
72							'' : ' disabled');
73						break;
74
75					case 'previous':
76						btnDisplay = lang.sPrevious;
77						btnClass = button + (page > 0 ?
78							'' : ' disabled');
79						break;
80
81					case 'next':
82						btnDisplay = lang.sNext;
83						btnClass = button + (page < pages-1 ?
84							'' : ' disabled');
85						break;
86
87					case 'last':
88						btnDisplay = lang.sLast;
89						btnClass = button + (page < pages-1 ?
90							'' : ' disabled');
91						break;
92
93					default:
94						btnDisplay = button + 1;
95						btnClass = page === button ?
96							'active' : '';
97						break;
98				}
99
100				if ( btnDisplay ) {
101					node = $('<li>', {
102							'class': classes.sPageButton+' '+btnClass,
103							'aria-controls': settings.sTableId,
104							'tabindex': settings.iTabIndex,
105							'id': idx === 0 && typeof button === 'string' ?
106								settings.sTableId +'_'+ button :
107								null
108						} )
109						.append( $('<a>', {
110								'href': '#'
111							} )
112							.html( btnDisplay )
113						)
114						.appendTo( container );
115
116					settings.oApi._fnBindAction(
117						node, {action: button}, clickHandler
118					);
119				}
120			}
121		}
122	};
123
124	attach(
125		$(host).empty().html('<ul class="pagination"/>').children('ul'),
126		buttons
127	);
128};
129
130
131/*
132 * TableTools Bootstrap compatibility
133 * Required TableTools 2.1+
134 */
135if ( DataTable.TableTools ) {
136	// Set the classes that TableTools uses to something suitable for Bootstrap
137	$.extend( true, DataTable.TableTools.classes, {
138		"container": "DTTT btn-group",
139		"buttons": {
140			"normal": "btn btn-default",
141			"disabled": "disabled"
142		},
143		"collection": {
144			"container": "DTTT_dropdown dropdown-menu",
145			"buttons": {
146				"normal": "",
147				"disabled": "disabled"
148			}
149		},
150		"print": {
151			"info": "DTTT_print_info"
152		},
153		"select": {
154			"row": "active"
155		}
156	} );
157
158	// Have the collection use a bootstrap compatible drop down
159	$.extend( true, DataTable.TableTools.DEFAULTS.oTags, {
160		"collection": {
161			"container": "ul",
162			"button": "li",
163			"liner": "a"
164		}
165	} );
166}
167
168}; // /factory
169
170
171// Define as an AMD module if possible
172if ( typeof define === 'function' && define.amd ) {
173	define( ['jquery', 'datatables'], factory );
174}
175else if ( typeof exports === 'object' ) {
176    // Node/CommonJS
177    factory( require('jquery'), require('datatables') );
178}
179else if ( jQuery ) {
180	// Otherwise simply initialise as normal, stopping multiple evaluation
181	factory( jQuery, jQuery.fn.dataTable );
182}
183
184
185})(window, document);
186

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.