bootstrap-table.js 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425
  1. /**
  2. * @author zhixin wen <wenzhixin2010@gmail.com>
  3. * version: 1.3.0
  4. * https://github.com/wenzhixin/bootstrap-table/
  5. */
  6. !function ($) {
  7. 'use strict';
  8. // TOOLS DEFINITION
  9. // ======================
  10. // it only does '%s', and return '' when arguments are undefined
  11. var sprintf = function(str) {
  12. var args = arguments,
  13. flag = true,
  14. i = 1;
  15. str = str.replace(/%s/g, function () {
  16. var arg = args[i++];
  17. if (typeof arg === 'undefined') {
  18. flag = false;
  19. return '';
  20. }
  21. return arg;
  22. });
  23. if (flag) {
  24. return str;
  25. }
  26. return '';
  27. };
  28. var getPropertyFromOther = function (list, from, to, value) {
  29. var result = '';
  30. $.each(list, function (i, item) {
  31. if (item[from] === value) {
  32. result = item[to];
  33. return false;
  34. }
  35. return true;
  36. });
  37. return result;
  38. };
  39. var getFieldIndex = function (columns, field) {
  40. var index = -1;
  41. $.each(columns, function (i, column) {
  42. if (column.field === field) {
  43. index = i;
  44. return false;
  45. }
  46. return true;
  47. });
  48. return index;
  49. };
  50. var getScrollBarWidth = function () {
  51. var inner = $('<p/>').addClass('fixed-table-scroll-inner'),
  52. outer = $('<div/>').addClass('fixed-table-scroll-outer'),
  53. w1, w2;
  54. outer.append(inner);
  55. $('body').append(outer);
  56. w1 = inner[0].offsetWidth;
  57. outer.css('overflow', 'scroll');
  58. w2 = inner[0].offsetWidth;
  59. if (w1 == w2) {
  60. w2 = outer[0].clientWidth;
  61. }
  62. outer.remove();
  63. return w1 - w2;
  64. };
  65. var calculateObjectValue = function (self, name, args, defaultValue) {
  66. if (typeof name === 'string') {
  67. // support obj.func1.func2
  68. var names = name.split('.');
  69. if (names.length > 1) {
  70. name = window;
  71. $.each(names, function (i, f) {
  72. name = name[f];
  73. });
  74. } else {
  75. name = window[name];
  76. }
  77. }
  78. if (typeof name === 'object') {
  79. return name;
  80. }
  81. if (typeof name === 'function') {
  82. return name.apply(self, args);
  83. }
  84. return defaultValue;
  85. };
  86. // BOOTSTRAP TABLE CLASS DEFINITION
  87. // ======================
  88. var BootstrapTable = function (el, options) {
  89. this.options = options;
  90. this.$el = $(el);
  91. this.$el_ = this.$el.clone();
  92. this.timeoutId_ = 0;
  93. this.init();
  94. };
  95. BootstrapTable.DEFAULTS = {
  96. classes: 'table table-hover',
  97. height: undefined,
  98. undefinedText: '-',
  99. sortName: undefined,
  100. sortOrder: 'asc',
  101. striped: false,
  102. columns: [],
  103. data: [],
  104. method: 'get',
  105. url: undefined,
  106. cache: true,
  107. contentType: 'application/json',
  108. queryParams: function (params) {return params;},
  109. queryParamsType: 'limit', // undefined
  110. responseHandler: function (res) {return res;},
  111. pagination: false,
  112. sidePagination: 'client', // client or server
  113. totalRows: 0, // server side need to set
  114. pageNumber: 1,
  115. pageSize: 10,
  116. pageList: [10, 25, 50, 100],
  117. search: false,
  118. selectItemName: 'btSelectItem',
  119. showHeader: true,
  120. showColumns: false,
  121. showRefresh: false,
  122. showToggle: false,
  123. minimumCountColumns: 1,
  124. idField: undefined,
  125. cardView: false,
  126. clickToSelect: false,
  127. singleSelect: false,
  128. toolbar: undefined,
  129. checkboxHeader: true,
  130. sortable: true,
  131. maintainSelected: false,
  132. rowStyle: function (row, index) {return {};},
  133. formatLoadingMessage: function () {
  134. return 'Loading, please wait…';
  135. },
  136. formatRecordsPerPage: function (pageNumber) {
  137. return sprintf('%s records per page', pageNumber);
  138. },
  139. formatShowingRows: function (pageFrom, pageTo, totalRows) {
  140. return sprintf('Showing %s to %s of %s rows', pageFrom, pageTo, totalRows);
  141. },
  142. formatSearch: function () {
  143. return 'Search';
  144. },
  145. formatNoMatches: function () {
  146. return 'No matching records found';
  147. },
  148. formatRefresh: function () {
  149. return 'Refresh';
  150. },
  151. formatToggle: function () {
  152. return 'Toggle';
  153. },
  154. formatColumns: function () {
  155. return 'Columns';
  156. },
  157. onAll: function (name, args) {return false;},
  158. onClickRow: function (item, $element) {return false;},
  159. onDblClickRow: function (item, $element) {return false;},
  160. onSort: function (name, order) {return false;},
  161. onCheck: function (row) {return false;},
  162. onUncheck: function (row) {return false;},
  163. onCheckAll: function () {return false;},
  164. onUncheckAll: function () {return false;},
  165. onLoadSuccess: function (data) {return false;},
  166. onLoadError: function (status) {return false;},
  167. onColumnSwitch: function (field, checked) {return false;}
  168. };
  169. BootstrapTable.COLUMN_DEFAULTS = {
  170. radio: false,
  171. checkbox: false,
  172. checkboxEnabled: true,
  173. field: undefined,
  174. title: undefined,
  175. 'class': undefined,
  176. align: undefined, // left, right, center
  177. halign: undefined, // left, right, center
  178. valign: undefined, // top, middle, bottom
  179. width: undefined,
  180. sortable: false,
  181. order: 'asc', // asc, desc
  182. visible: true,
  183. switchable: true,
  184. clickToSelect: true,
  185. formatter: undefined,
  186. events: undefined,
  187. sorter: undefined,
  188. cellStyle: undefined
  189. };
  190. BootstrapTable.EVENTS = {
  191. 'all.bs.table': 'onAll',
  192. 'click-row.bs.table': 'onClickRow',
  193. 'dbl-click-row.bs.table': 'onDblClickRow',
  194. 'sort.bs.table': 'onSort',
  195. 'check.bs.table': 'onCheck',
  196. 'uncheck.bs.table': 'onUncheck',
  197. 'check-all.bs.table': 'onCheckAll',
  198. 'uncheck-all.bs.table': 'onUncheckAll',
  199. 'load-success.bs.table': 'onLoadSuccess',
  200. 'load-error.bs.table': 'onLoadError',
  201. 'column-switch.bs.table': 'onColumnSwitch'
  202. };
  203. BootstrapTable.prototype.init = function () {
  204. this.initContainer();
  205. this.initTable();
  206. this.initHeader();
  207. this.initData();
  208. this.initToolbar();
  209. this.initPagination();
  210. this.initBody();
  211. this.initServer();
  212. };
  213. BootstrapTable.prototype.initContainer = function () {
  214. this.$container = $([
  215. '<div class="bootstrap-table">',
  216. '<div class="fixed-table-toolbar"></div>',
  217. '<div class="fixed-table-container">',
  218. '<div class="fixed-table-header"><table></table></div>',
  219. '<div class="fixed-table-body">',
  220. '<div class="fixed-table-loading">',
  221. this.options.formatLoadingMessage(),
  222. '</div>',
  223. '</div>',
  224. '<div class="fixed-table-pagination"></div>',
  225. '</div>',
  226. '</div>'].join(''));
  227. this.$container.insertAfter(this.$el);
  228. this.$container.find('.fixed-table-body').append(this.$el);
  229. this.$container.after('<div class="clearfix"></div>');
  230. this.$loading = this.$container.find('.fixed-table-loading');
  231. this.$el.addClass(this.options.classes);
  232. if (this.options.striped) {
  233. this.$el.addClass('table-striped');
  234. }
  235. };
  236. BootstrapTable.prototype.initTable = function () {
  237. var that = this,
  238. columns = [],
  239. data = [];
  240. this.$header = this.$el.find('thead');
  241. if (!this.$header.length) {
  242. this.$header = $('<thead></thead>').appendTo(this.$el);
  243. }
  244. if (!this.$header.find('tr').length) {
  245. this.$header.append('<tr></tr>');
  246. }
  247. this.$header.find('th').each(function () {
  248. var column = $.extend({}, {
  249. title: $(this).html(),
  250. 'class': $(this).attr('class')
  251. }, $(this).data());
  252. columns.push(column);
  253. });
  254. this.options.columns = $.extend([], columns, this.options.columns);
  255. $.each(this.options.columns, function (i, column) {
  256. that.options.columns[i] = $.extend({}, BootstrapTable.COLUMN_DEFAULTS,
  257. {field: i}, column); // when field is undefined, use index instead
  258. });
  259. // if options.data is setting, do not process tbody data
  260. if (this.options.data.length) {
  261. return;
  262. }
  263. this.$el.find('tbody tr').each(function () {
  264. var row = {};
  265. $(this).find('td').each(function (i) {
  266. row[that.options.columns[i].field] = $(this).html();
  267. });
  268. data.push(row);
  269. });
  270. this.options.data = data;
  271. };
  272. BootstrapTable.prototype.initHeader = function () {
  273. var that = this,
  274. visibleColumns = [],
  275. html = [];
  276. this.header = {
  277. fields: [],
  278. styles: [],
  279. classes: [],
  280. formatters: [],
  281. events: [],
  282. sorters: [],
  283. cellStyles: [],
  284. clickToSelects: []
  285. };
  286. $.each(this.options.columns, function (i, column) {
  287. var text = '',
  288. style = '',
  289. class_ = sprintf(' class="%s"', column['class']),
  290. order = that.options.sortOrder || column.order;
  291. if (!column.visible) {
  292. return;
  293. }
  294. style = sprintf('text-align: %s; ', column.halign ? column.halign : column.align);
  295. style += sprintf('vertical-align: %s; ', column.valign);
  296. style += sprintf('width: %spx; ', column.checkbox || column.radio ? 36 : column.width);
  297. visibleColumns.push(column);
  298. that.header.fields.push(column.field);
  299. that.header.styles.push(style);
  300. that.header.classes.push(class_);
  301. that.header.formatters.push(column.formatter);
  302. that.header.events.push(column.events);
  303. that.header.sorters.push(column.sorter);
  304. that.header.cellStyles.push(column.cellStyle);
  305. that.header.clickToSelects.push(column.clickToSelect);
  306. html.push('<th',
  307. column.checkbox || column.radio ?
  308. sprintf(' class="bs-checkbox %s"', column['class'] || '') :
  309. class_,
  310. sprintf(' style="%s"', style),
  311. '>');
  312. html.push(sprintf('<div class="th-inner %s">', that.options.sortable && column.sortable ?
  313. 'sortable' : ''));
  314. text = column.title;
  315. if (that.options.sortName === column.field && that.options.sortable && column.sortable) {
  316. text += that.getCaretHtml();
  317. }
  318. if (column.checkbox) {
  319. if (!that.options.singleSelect && that.options.checkboxHeader) {
  320. text = '<input name="btSelectAll" type="checkbox" />';
  321. }
  322. that.header.stateField = column.field;
  323. }
  324. if (column.radio) {
  325. text = '';
  326. that.header.stateField = column.field;
  327. that.options.singleSelect = true;
  328. }
  329. html.push(text);
  330. html.push('</div>');
  331. html.push('<div class="fht-cell"></div>');
  332. html.push('</th>');
  333. });
  334. this.$header.find('tr').html(html.join(''));
  335. this.$header.find('th').each(function (i) {
  336. $(this).data(visibleColumns[i]);
  337. });
  338. this.$container.off('click', 'th').on('click', 'th', function (event) {
  339. if (that.options.sortable && $(this).data().sortable) {
  340. that.onSort(event);
  341. }
  342. });
  343. if (!this.options.showHeader || this.options.cardView) {
  344. this.$header.hide();
  345. this.$container.find('.fixed-table-header').hide();
  346. this.$loading.css('top', 0);
  347. } else {
  348. this.$header.show();
  349. this.$container.find('.fixed-table-header').show();
  350. this.$loading.css('top', '37px');
  351. }
  352. this.$selectAll = this.$header.find('[name="btSelectAll"]');
  353. this.$container.off('click', '[name="btSelectAll"]')
  354. .on('click', '[name="btSelectAll"]', function () {
  355. var checked = $(this).prop('checked');
  356. that[checked ? 'checkAll' : 'uncheckAll']();
  357. });
  358. };
  359. BootstrapTable.prototype.initData = function (data, append) {
  360. if (append) {
  361. this.data = this.data.concat(data);
  362. } else {
  363. this.data = data || this.options.data;
  364. }
  365. this.options.data = this.data;
  366. if (this.options.sidePagination === 'server') {
  367. return;
  368. }
  369. this.initSort();
  370. };
  371. BootstrapTable.prototype.initSort = function () {
  372. var that = this,
  373. name = this.options.sortName,
  374. order = this.options.sortOrder === 'desc' ? -1 : 1,
  375. index = $.inArray(this.options.sortName, this.header.fields);
  376. if (index !== -1) {
  377. this.data.sort(function (a, b) {
  378. var aa = a[name],
  379. bb = b[name],
  380. value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
  381. if (value !== undefined) {
  382. return order * value;
  383. }
  384. // Fix #161: undefined or null string sort bug.
  385. if (aa === null) {
  386. aa = '';
  387. }
  388. if (bb === null) {
  389. bb = '';
  390. }
  391. if (aa === bb) {
  392. return 0;
  393. }
  394. if (aa < bb) {
  395. return order * -1;
  396. }
  397. return order;
  398. });
  399. }
  400. };
  401. BootstrapTable.prototype.onSort = function (event) {
  402. var $this = $(event.currentTarget),
  403. $this_ = this.$header.find('th').eq($this.index());
  404. this.$header.add(this.$header_).find('span.order').remove();
  405. if (this.options.sortName === $this.data('field')) {
  406. this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
  407. } else {
  408. this.options.sortName = $this.data('field');
  409. this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
  410. }
  411. this.trigger('sort', this.options.sortName, this.options.sortOrder);
  412. $this.add($this_).data('order', this.options.sortOrder)
  413. .find('.th-inner').append(this.getCaretHtml());
  414. if (this.options.sidePagination === 'server') {
  415. this.initServer();
  416. return;
  417. }
  418. this.initSort();
  419. this.initBody();
  420. };
  421. BootstrapTable.prototype.initToolbar = function () {
  422. var that = this,
  423. html = [],
  424. timeoutId = 0,
  425. $keepOpen,
  426. $search,
  427. switchableCount = 0;
  428. this.$toolbar = this.$container.find('.fixed-table-toolbar').html('');
  429. if (typeof this.options.toolbar === 'string') {
  430. $('<div class="bars pull-left"></div>')
  431. .appendTo(this.$toolbar)
  432. .append($(this.options.toolbar));
  433. }
  434. // showColumns, showToggle, showRefresh
  435. html = ['<div class="columns btn-group pull-right">'];
  436. if (this.options.showRefresh) {
  437. html.push(sprintf('<button class="btn btn-default" type="button" name="refresh" title="%s">',
  438. this.options.formatRefresh()),
  439. '<i class="glyphicon glyphicon-refresh icon-refresh"></i>',
  440. '</button>');
  441. }
  442. if (this.options.showToggle) {
  443. html.push(sprintf('<button class="btn btn-default" type="button" name="toggle" title="%s">',
  444. this.options.formatToggle()),
  445. '<i class="glyphicon glyphicon glyphicon-list-alt icon-list-alt"></i>',
  446. '</button>');
  447. }
  448. if (this.options.showColumns) {
  449. html.push(sprintf('<div class="keep-open %s" title="%s">',
  450. this.options.showRefresh || this.options.showToggle ? 'btn-group' : '',
  451. this.options.formatColumns()),
  452. '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',
  453. '<i class="glyphicon glyphicon-th icon-th"></i>',
  454. ' <span class="caret"></span>',
  455. '</button>',
  456. '<ul class="dropdown-menu" role="menu">');
  457. $.each(this.options.columns, function (i, column) {
  458. if (column.radio || column.checkbox) {
  459. return;
  460. }
  461. var checked = column.visible ? ' checked="checked"' : '';
  462. if (column.switchable) {
  463. html.push(sprintf('<li>' +
  464. '<label><input type="checkbox" data-field="%s" value="%s"%s> %s</label>' +
  465. '</li>', column.field, i, checked, column.title));
  466. switchableCount++;
  467. }
  468. });
  469. html.push('</ul>',
  470. '</div>');
  471. }
  472. html.push('</div>');
  473. if (html.length > 2) {
  474. this.$toolbar.append(html.join(''));
  475. }
  476. if (this.options.showRefresh) {
  477. this.$toolbar.find('button[name="refresh"]')
  478. .off('click').on('click', $.proxy(this.refresh, this));
  479. }
  480. if (this.options.showToggle) {
  481. this.$toolbar.find('button[name="toggle"]')
  482. .off('click').on('click', function () {
  483. that.options.cardView = !that.options.cardView;
  484. that.initHeader();
  485. that.initBody();
  486. });
  487. }
  488. if (this.options.showColumns) {
  489. $keepOpen = this.$toolbar.find('.keep-open');
  490. if (switchableCount <= this.options.minimumCountColumns) {
  491. $keepOpen.find('input').prop('disabled', true);
  492. }
  493. $keepOpen.find('li').off('click').on('click', function (event) {
  494. event.stopImmediatePropagation();
  495. });
  496. $keepOpen.find('input').off('click').on('click', function () {
  497. var $this = $(this);
  498. that.toggleColumn($this.val(), $this.prop('checked'), false);
  499. that.trigger('column-switch', $(this).data('field'), $this.prop('checked'));
  500. });
  501. }
  502. if (this.options.search) {
  503. html = [];
  504. html.push(
  505. '<div class="pull-right search">',
  506. sprintf('<input class="form-control" type="text" placeholder="%s">',
  507. this.options.formatSearch()),
  508. '</div>');
  509. this.$toolbar.append(html.join(''));
  510. $search = this.$toolbar.find('.search input');
  511. $search.off('keyup').on('keyup', function (event) {
  512. clearTimeout(timeoutId); // doesn't matter if it's 0
  513. timeoutId = setTimeout(function () {
  514. that.onSearch(event);
  515. }, 500); // 500ms
  516. });
  517. }
  518. };
  519. BootstrapTable.prototype.onSearch = function (event) {
  520. var text = $.trim($(event.currentTarget).val());
  521. // trim search input
  522. $(event.currentTarget).val(text);
  523. if (text === this.searchText) {
  524. return;
  525. }
  526. this.searchText = text;
  527. this.options.pageNumber = 1;
  528. this.initSearch();
  529. this.updatePagination();
  530. };
  531. BootstrapTable.prototype.initSearch = function () {
  532. var that = this;
  533. if (this.options.sidePagination !== 'server') {
  534. var s = this.searchText && this.searchText.toLowerCase();
  535. this.data = s ? $.grep(this.options.data, function (item, i) {
  536. key = $.isNumeric(key) ? parseInt(key, 10) : key;
  537. for (var key in item) {
  538. var value = item[key];
  539. // Fix #142: search use formated data
  540. value = calculateObjectValue(that.header,
  541. that.header.formatters[$.inArray(key, that.header.fields)],
  542. [value, item, i], value);
  543. if ($.inArray(key, that.header.fields) !== -1 &&
  544. (typeof value === 'string' ||
  545. typeof value === 'number') &&
  546. (value + '').toLowerCase().indexOf(s) !== -1) {
  547. return true;
  548. }
  549. }
  550. return false;
  551. }) : this.options.data;
  552. }
  553. };
  554. BootstrapTable.prototype.initPagination = function () {
  555. this.$pagination = this.$container.find('.fixed-table-pagination');
  556. if (!this.options.pagination) {
  557. return;
  558. }
  559. var that = this,
  560. html = [],
  561. i, from, to,
  562. $pageList,
  563. $first, $pre,
  564. $next, $last,
  565. $number,
  566. data = this.searchText ? this.data : this.options.data;
  567. if (this.options.sidePagination !== 'server') {
  568. this.options.totalRows = data.length;
  569. }
  570. this.totalPages = 0;
  571. if (this.options.totalRows) {
  572. this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1;
  573. }
  574. if (this.totalPages > 0 && this.options.pageNumber > this.totalPages) {
  575. this.options.pageNumber = this.totalPages;
  576. }
  577. this.pageFrom = (this.options.pageNumber - 1) * this.options.pageSize + 1;
  578. this.pageTo = this.options.pageNumber * this.options.pageSize;
  579. if (this.pageTo > this.options.totalRows) {
  580. this.pageTo = this.options.totalRows;
  581. }
  582. html.push(
  583. '<div class="pull-left pagination-detail">',
  584. '<span class="pagination-info">',
  585. this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows),
  586. '</span>');
  587. html.push('<span class="page-list">');
  588. var pageNumber = [
  589. '<span class="btn-group dropup">',
  590. '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">',
  591. '<span class="page-size">',
  592. this.options.pageSize,
  593. '</span>',
  594. ' <span class="caret"></span>',
  595. '</button>',
  596. '<ul class="dropdown-menu" role="menu">'],
  597. pageList = this.options.pageList;
  598. if (typeof this.options.pageList === 'string') {
  599. var list = this.options.pageList.slice(1, -1).replace(/ /g, '').split(',');
  600. pageList = [];
  601. $.each(list, function (i, value) {
  602. pageList.push(+value);
  603. });
  604. }
  605. $.each(pageList, function (i, page) {
  606. var active = page === that.options.pageSize ? ' class="active"' : '';
  607. pageNumber.push(sprintf('<li%s><a href="javascript:void(0)">%s</a></li>', active, page));
  608. });
  609. pageNumber.push('</ul></span>');
  610. html.push(this.options.formatRecordsPerPage(pageNumber.join('')));
  611. html.push('</span>');
  612. html.push('</div>',
  613. '<div class="pull-right pagination">',
  614. '<ul class="pagination">',
  615. '<li class="page-first"><a href="javascript:void(0)">&lt;&lt;</a></li>',
  616. '<li class="page-pre"><a href="javascript:void(0)">&lt;</a></li>');
  617. if (this.totalPages < 5) {
  618. from = 1;
  619. to = this.totalPages;
  620. } else {
  621. from = this.options.pageNumber - 2;
  622. to = from + 4;
  623. if (from < 1) {
  624. from = 1;
  625. to = 5;
  626. }
  627. if (to > this.totalPages) {
  628. to = this.totalPages;
  629. from = to - 4;
  630. }
  631. }
  632. for (i = from; i <= to; i++) {
  633. html.push('<li class="page-number' + (i === this.options.pageNumber ? ' active' : '') + '">',
  634. '<a href="javascript:void(0)">', i ,'</a>',
  635. '</li>');
  636. }
  637. html.push(
  638. '<li class="page-next"><a href="javascript:void(0)">&gt;</a></li>',
  639. '<li class="page-last"><a href="javascript:void(0)">&gt;&gt;</a></li>',
  640. '</ul>',
  641. '</div>');
  642. this.$pagination.html(html.join(''));
  643. $pageList = this.$pagination.find('.page-list a');
  644. $first = this.$pagination.find('.page-first');
  645. $pre = this.$pagination.find('.page-pre');
  646. $next = this.$pagination.find('.page-next');
  647. $last = this.$pagination.find('.page-last');
  648. $number = this.$pagination.find('.page-number');
  649. if (this.options.pageNumber <= 1) {
  650. $first.addClass('disabled');
  651. $pre.addClass('disabled');
  652. }
  653. if (this.options.pageNumber >= this.totalPages) {
  654. $next.addClass('disabled');
  655. $last.addClass('disabled');
  656. }
  657. $pageList.off('click').on('click', $.proxy(this.onPageListChange, this));
  658. $first.off('click').on('click', $.proxy(this.onPageFirst, this));
  659. $pre.off('click').on('click', $.proxy(this.onPagePre, this));
  660. $next.off('click').on('click', $.proxy(this.onPageNext, this));
  661. $last.off('click').on('click', $.proxy(this.onPageLast, this));
  662. $number.off('click').on('click', $.proxy(this.onPageNumber, this));
  663. };
  664. BootstrapTable.prototype.updatePagination = function () {
  665. if (!this.options.maintainSelected) {
  666. this.resetRows();
  667. }
  668. this.initPagination();
  669. if (this.options.sidePagination === 'server') {
  670. this.initServer();
  671. } else {
  672. this.initBody();
  673. }
  674. };
  675. BootstrapTable.prototype.onPageListChange = function (event) {
  676. var $this = $(event.currentTarget);
  677. $this.parent().addClass('active').siblings().removeClass('active');
  678. this.options.pageSize = +$this.text();
  679. this.$toolbar.find('.page-size').text(this.options.pageSize);
  680. this.updatePagination();
  681. };
  682. BootstrapTable.prototype.onPageFirst = function () {
  683. this.options.pageNumber = 1;
  684. this.updatePagination();
  685. };
  686. BootstrapTable.prototype.onPagePre = function () {
  687. this.options.pageNumber--;
  688. this.updatePagination();
  689. };
  690. BootstrapTable.prototype.onPageNext = function () {
  691. this.options.pageNumber++;
  692. this.updatePagination();
  693. };
  694. BootstrapTable.prototype.onPageLast = function () {
  695. this.options.pageNumber = this.totalPages;
  696. this.updatePagination();
  697. };
  698. BootstrapTable.prototype.onPageNumber = function (event) {
  699. if (this.options.pageNumber === +$(event.currentTarget).text()) {
  700. return;
  701. }
  702. this.options.pageNumber = +$(event.currentTarget).text();
  703. this.updatePagination();
  704. };
  705. BootstrapTable.prototype.initBody = function (fixedScroll) {
  706. var that = this,
  707. html = [],
  708. data = this.getData();
  709. this.$body = this.$el.find('tbody');
  710. if (!this.$body.length) {
  711. this.$body = $('<tbody></tbody>').appendTo(this.$el);
  712. }
  713. if (this.options.sidePagination === 'server') {
  714. data = this.data;
  715. }
  716. if (!this.options.pagination || this.options.sidePagination === 'server') {
  717. this.pageFrom = 1;
  718. this.pageTo = data.length;
  719. }
  720. for (var i = this.pageFrom - 1; i < this.pageTo; i++) {
  721. var item = data[i],
  722. style = {},
  723. csses = [];
  724. style = calculateObjectValue(this.options, this.options.rowStyle, [item, i], style);
  725. if (style && style.css) {
  726. for (var key in style.css) {
  727. csses.push(key + ': ' + style.css[key]);
  728. }
  729. }
  730. html.push('<tr',
  731. sprintf(' class="%s"', style.classes),
  732. sprintf(' data-index="%s"', i),
  733. '>'
  734. );
  735. if (this.options.cardView) {
  736. html.push(sprintf('<td colspan="%s">', this.header.fields.length));
  737. }
  738. $.each(this.header.fields, function (j, field) {
  739. var text = '',
  740. value = item[field],
  741. type = '',
  742. cellStyle = {},
  743. class_ = that.header.classes[j];
  744. style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
  745. value = calculateObjectValue(that.header,
  746. that.header.formatters[j], [value, item, i], value);
  747. cellStyle = calculateObjectValue(that.header,
  748. that.header.cellStyles[j], [value, item, i], cellStyle);
  749. if (cellStyle.classes) {
  750. class_ = sprintf(' class="%s"', cellStyle.classes);
  751. }
  752. if (cellStyle.css) {
  753. csses = [];
  754. for (var key in cellStyle.css) {
  755. csses.push(key + ': ' + cellStyle.css[key]);
  756. }
  757. style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
  758. }
  759. if (that.options.columns[j].checkbox || that.options.columns[j].radio) {
  760. //if card view mode bypass
  761. if (that.options.cardView) {
  762. return true;
  763. }
  764. type = that.options.columns[j].checkbox ? 'checkbox' : type;
  765. type = that.options.columns[j].radio ? 'radio' : type;
  766. text = ['<td class="bs-checkbox">',
  767. '<input' +
  768. sprintf(' data-index="%s"', i) +
  769. sprintf(' name="%s"', that.options.selectItemName) +
  770. sprintf(' type="%s"', type) +
  771. sprintf(' value="%s"', item[that.options.idField]) +
  772. sprintf(' checked="%s"', value === true ||
  773. (value && value.checked) ? 'checked' : undefined) +
  774. sprintf(' disabled="%s"', !that.options.columns[j].checkboxEnabled ||
  775. (value && value.disabled) ? 'disabled' : undefined) +
  776. ' />',
  777. '</td>'].join('');
  778. } else {
  779. value = typeof value === 'undefined' ? that.options.undefinedText : value;
  780. text = that.options.cardView ?
  781. ['<div class="card-view">',
  782. that.options.showHeader ? sprintf('<span class="title" %s>%s</span>', style,
  783. getPropertyFromOther(that.options.columns, 'field', 'title', field)) : '',
  784. sprintf('<span class="value">%s</span>', value),
  785. '</div>'].join('') :
  786. [sprintf('<td%s %s>', class_, style),
  787. value,
  788. '</td>'].join('');
  789. }
  790. html.push(text);
  791. });
  792. if (this.options.cardView) {
  793. html.push('</td>');
  794. }
  795. html.push('</tr>');
  796. }
  797. // show no records
  798. if (!html.length) {
  799. html.push('<tr class="no-records-found">',
  800. sprintf('<td colspan="%s">%s</td>', this.header.fields.length, this.options.formatNoMatches()),
  801. '</tr>');
  802. }
  803. this.$body.html(html.join(''));
  804. if (!fixedScroll) {
  805. this.$container.find('.fixed-table-body').scrollTop(0);
  806. }
  807. // click to select by column
  808. this.$body.find('> tr > td').off('click').on('click', function () {
  809. var $tr = $(this).parent();
  810. that.trigger('click-row', that.data[$tr.data('index')], $tr);
  811. // if click to select - then trigger the checkbox/radio click
  812. if (that.options.clickToSelect) {
  813. if (that.header.clickToSelects[$tr.children().index($(this))]) {
  814. $tr.find(sprintf('[name="%s"]',
  815. that.options.selectItemName)).trigger('click');
  816. }
  817. }
  818. });
  819. this.$body.find('tr').off('dblclick').on('dblclick', function () {
  820. that.trigger('dbl-click-row', that.data[$(this).data('index')], $(this));
  821. });
  822. this.$selectItem = this.$body.find(sprintf('[name="%s"]', this.options.selectItemName));
  823. this.$selectItem.off('click').on('click', function (event) {
  824. event.stopImmediatePropagation();
  825. // radio trigger click event bug!
  826. if ($(this).is(':radio')) {
  827. $(this).prop('checked', true);
  828. }
  829. var checkAll = that.$selectItem.filter(':enabled').length ===
  830. that.$selectItem.filter(':enabled').filter(':checked').length,
  831. checked = $(this).prop('checked'),
  832. row = that.data[$(this).data('index')];
  833. that.$selectAll.add(that.$selectAll_).prop('checked', checkAll);
  834. row[that.header.stateField] = checked;
  835. that.trigger(checked ? 'check' : 'uncheck', row);
  836. if (that.options.singleSelect) {
  837. that.$selectItem.not(this).each(function () {
  838. that.data[$(this).data('index')][that.header.stateField] = false;
  839. });
  840. that.$selectItem.filter(':checked').not(this).prop('checked', false);
  841. }
  842. that.updateSelected();
  843. });
  844. $.each(this.header.events, function (i, events) {
  845. if (!events) {
  846. return;
  847. }
  848. // fix bug, if events is defined with namespace
  849. if (typeof events === 'string') {
  850. events = calculateObjectValue(null, events);
  851. }
  852. for (var key in events) {
  853. that.$body.find('tr').each(function () {
  854. var $tr = $(this),
  855. $td = $tr.find('td').eq(i),
  856. index = key.indexOf(' '),
  857. name = key.substring(0, index),
  858. el = key.substring(index + 1),
  859. func = events[key];
  860. $td.find(el).off(name).on(name, function (e) {
  861. var index = $tr.data('index'),
  862. row = that.data[index],
  863. value = row[that.header.fields[i]];
  864. func(e, value, row, index);
  865. });
  866. });
  867. }
  868. });
  869. this.updateSelected();
  870. this.resetView();
  871. };
  872. BootstrapTable.prototype.initServer = function (silent) {
  873. var that = this,
  874. data = {},
  875. params = {
  876. pageSize: this.options.pageSize,
  877. pageNumber: this.options.pageNumber,
  878. searchText: this.searchText,
  879. sortName: this.options.sortName,
  880. sortOrder: this.options.sortOrder
  881. };
  882. if (!this.options.url) {
  883. return;
  884. }
  885. if (this.options.queryParamsType === 'limit') {
  886. params = {
  887. limit: params.pageSize,
  888. offset: params.pageSize * (params.pageNumber - 1),
  889. search: params.searchText,
  890. sort: params.sortName,
  891. order: params.sortOrder
  892. };
  893. }
  894. data = calculateObjectValue(this.options, this.options.queryParams, [params], data);
  895. // false to stop request
  896. if (data === false) {
  897. return;
  898. }
  899. if (!silent) {
  900. this.$loading.show();
  901. }
  902. $.ajax({
  903. type: this.options.method,
  904. url: this.options.url,
  905. data: data,
  906. cache: this.options.cache,
  907. contentType: this.options.contentType,
  908. dataType: 'json',
  909. success: function (res) {
  910. res = calculateObjectValue(that.options, that.options.responseHandler, [res], res);
  911. var data = res;
  912. if (that.options.sidePagination === 'server') {
  913. that.options.totalRows = res.total;
  914. data = res.rows;
  915. }
  916. that.load(data);
  917. that.trigger('load-success', data);
  918. },
  919. error: function (res) {
  920. that.trigger('load-error', res.status);
  921. },
  922. complete: function () {
  923. if (!silent) {
  924. that.$loading.hide();
  925. }
  926. }
  927. });
  928. };
  929. BootstrapTable.prototype.getCaretHtml = function () {
  930. return ['<span class="order' + (this.options.sortOrder === 'desc' ? '' : ' dropup') + '">',
  931. '<span class="caret" style="margin: 10px 5px;"></span>',
  932. '</span>'].join('');
  933. };
  934. BootstrapTable.prototype.updateSelected = function () {
  935. this.$selectItem.each(function () {
  936. $(this).parents('tr')[$(this).prop('checked') ? 'addClass' : 'removeClass']('selected');
  937. });
  938. };
  939. BootstrapTable.prototype.updateRows = function (checked) {
  940. var that = this;
  941. this.$selectItem.each(function () {
  942. that.data[$(this).data('index')][that.header.stateField] = checked;
  943. });
  944. };
  945. BootstrapTable.prototype.resetRows = function () {
  946. var that = this;
  947. $.each(this.data, function (i, row) {
  948. that.$selectAll.prop('checked', false);
  949. that.$selectItem.prop('checked', false);
  950. row[that.header.stateField] = false;
  951. });
  952. };
  953. BootstrapTable.prototype.trigger = function (name) {
  954. var args = Array.prototype.slice.call(arguments, 1);
  955. name += '.bs.table';
  956. this.options[BootstrapTable.EVENTS[name]].apply(this.options, args);
  957. this.$el.trigger($.Event(name), args);
  958. this.options.onAll(name, args);
  959. this.$el.trigger($.Event('all.bs.table'), [name, args]);
  960. };
  961. BootstrapTable.prototype.resetHeader = function () {
  962. var that = this,
  963. $fixedHeader = this.$container.find('.fixed-table-header'),
  964. $fixedBody = this.$container.find('.fixed-table-body'),
  965. scrollWidth = this.$el.width() > $fixedBody.width() ? getScrollBarWidth() : 0;
  966. // fix #61: the hidden table reset header bug.
  967. if (this.$el.is(':hidden')) {
  968. clearTimeout(this.timeoutId_); // doesn't matter if it's 0
  969. this.timeoutId_ = setTimeout($.proxy(this.resetHeader, this), 100); // 100ms
  970. return;
  971. }
  972. this.$header_ = this.$header.clone(true, true);
  973. this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
  974. // fix bug: get $el.css('width') error sometime (height = 500)
  975. setTimeout(function () {
  976. $fixedHeader.css({
  977. 'height': '37px',
  978. 'border-bottom': '1px solid #dddddd',
  979. 'margin-right': scrollWidth
  980. }).find('table').css('width', that.$el.css('width'))
  981. .html('').attr('class', that.$el.attr('class'))
  982. .append(that.$header_);
  983. // fix bug: $.data() is not working as expected after $.append()
  984. that.$header.find('th').each(function (i) {
  985. that.$header_.find('th').eq(i).data($(this).data());
  986. });
  987. that.$body.find('tr:first-child:not(.no-records-found) > *').each(function(i) {
  988. that.$header_.find('div.fht-cell').eq(i).width($(this).innerWidth());
  989. });
  990. that.$el.css('margin-top', -that.$header.height());
  991. // horizontal scroll event
  992. $fixedBody.off('scroll').on('scroll', function () {
  993. $fixedHeader.scrollLeft($(this).scrollLeft());
  994. });
  995. });
  996. };
  997. BootstrapTable.prototype.toggleColumn = function (index, checked, needUpdate) {
  998. if (index === -1) {
  999. return;
  1000. }
  1001. this.options.columns[index].visible = checked;
  1002. this.initHeader();
  1003. this.initSearch();
  1004. this.initPagination();
  1005. this.initBody();
  1006. if (this.options.showColumns) {
  1007. var $items = this.$toolbar.find('.keep-open input').prop('disabled', false);
  1008. if (needUpdate) {
  1009. $items.filter(sprintf('[value="%s"]', index)).prop('checked', checked);
  1010. }
  1011. if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
  1012. $items.filter(':checked').prop('disabled', true);
  1013. }
  1014. }
  1015. };
  1016. // PUBLIC FUNCTION DEFINITION
  1017. // =======================
  1018. BootstrapTable.prototype.resetView = function (params) {
  1019. var that = this,
  1020. header = this.header;
  1021. if (params && params.height) {
  1022. this.options.height = params.height;
  1023. }
  1024. this.$selectAll.prop('checked', this.$selectItem.length > 0 &&
  1025. this.$selectItem.length === this.$selectItem.filter(':checked').length);
  1026. if (this.options.height) {
  1027. var toolbarHeight = +this.$toolbar.children().outerHeight(true),
  1028. paginationHeight = +this.$pagination.children().outerHeight(true),
  1029. height = this.options.height - toolbarHeight - paginationHeight;
  1030. this.$container.find('.fixed-table-container').css('height', height + 'px');
  1031. }
  1032. if (this.options.cardView) {
  1033. // remove the element css
  1034. that.$el.css('margin-top', '0');
  1035. that.$container.find('.fixed-table-container').css('padding-bottom', '0');
  1036. return;
  1037. }
  1038. if (this.options.showHeader && this.options.height) {
  1039. this.resetHeader();
  1040. }
  1041. if (this.options.height && this.options.showHeader) {
  1042. this.$container.find('.fixed-table-container').css('padding-bottom', '37px');
  1043. }
  1044. };
  1045. BootstrapTable.prototype.getData = function () {
  1046. return this.searchText ? this.data : this.options.data;
  1047. };
  1048. BootstrapTable.prototype.load = function (data) {
  1049. this.initData(data);
  1050. this.initSearch();
  1051. this.initPagination();
  1052. this.initBody();
  1053. };
  1054. BootstrapTable.prototype.append = function (data) {
  1055. this.initData(data, true);
  1056. this.initSearch();
  1057. this.initPagination();
  1058. this.initBody(true);
  1059. };
  1060. BootstrapTable.prototype.remove = function (params) {
  1061. var len = this.options.data.length,
  1062. i, row;
  1063. if (!params.hasOwnProperty('field') || !params.hasOwnProperty('values')) {
  1064. return;
  1065. }
  1066. for (i = len - 1; i >= 0; i--) {
  1067. row = this.options.data[i];
  1068. if (!row.hasOwnProperty(params.field)) {
  1069. return;
  1070. }
  1071. if ($.inArray(row[params.field], params.values) !== -1) {
  1072. this.options.data.splice(i, 1);
  1073. }
  1074. }
  1075. if (len === this.options.data.length) {
  1076. return;
  1077. }
  1078. this.initSearch();
  1079. this.initPagination();
  1080. this.initBody(true);
  1081. };
  1082. BootstrapTable.prototype.updateRow = function (params) {
  1083. if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
  1084. return;
  1085. }
  1086. $.extend(this.data[params.index], params.row);
  1087. this.initBody();
  1088. };
  1089. BootstrapTable.prototype.mergeCells = function (options) {
  1090. var row = options.index,
  1091. col = $.inArray(options.field, this.header.fields),
  1092. rowspan = options.rowspan || 1,
  1093. colspan = options.colspan || 1,
  1094. i, j,
  1095. $tr = this.$body.find('tr'),
  1096. $td = $tr.eq(row).find('td').eq(col);
  1097. if (row < 0 || col < 0 || row >= this.data.length) {
  1098. return;
  1099. }
  1100. for (i = row; i < row + rowspan; i++) {
  1101. for (j = col; j < col + colspan; j++) {
  1102. $tr.eq(i).find('td').eq(j).hide();
  1103. }
  1104. }
  1105. $td.attr('rowspan', rowspan).attr('colspan', colspan)
  1106. .show(10, $.proxy(this.resetView, this));
  1107. };
  1108. BootstrapTable.prototype.getSelections = function () {
  1109. var that = this;
  1110. return $.grep(this.data, function (row) {
  1111. return row[that.header.stateField];
  1112. });
  1113. };
  1114. BootstrapTable.prototype.checkAll = function () {
  1115. this.$selectAll.add(this.$selectAll_).prop('checked', true);
  1116. this.$selectItem.filter(':enabled').prop('checked', true);
  1117. this.updateRows(true);
  1118. this.updateSelected();
  1119. this.trigger('check-all');
  1120. };
  1121. BootstrapTable.prototype.uncheckAll = function () {
  1122. this.$selectAll.add(this.$selectAll_).prop('checked', false);
  1123. this.$selectItem.filter(':enabled').prop('checked', false);
  1124. this.updateRows(false);
  1125. this.updateSelected();
  1126. this.trigger('uncheck-all');
  1127. };
  1128. BootstrapTable.prototype.destroy = function () {
  1129. this.$el.insertBefore(this.$container);
  1130. $(this.options.toolbar).insertBefore(this.$el);
  1131. this.$container.next().remove();
  1132. this.$container.remove();
  1133. this.$el.html(this.$el_.html())
  1134. .attr('class', this.$el_.attr('class') || ''); // reset the class
  1135. };
  1136. BootstrapTable.prototype.showLoading = function () {
  1137. this.$loading.show();
  1138. };
  1139. BootstrapTable.prototype.hideLoading = function () {
  1140. this.$loading.hide();
  1141. };
  1142. BootstrapTable.prototype.refresh = function (params) {
  1143. if (params && params.url) {
  1144. this.options.url = params.url;
  1145. }
  1146. this.initServer(params && params.silent);
  1147. };
  1148. BootstrapTable.prototype.showColumn = function (field) {
  1149. this.toggleColumn(getFieldIndex(this.options.columns, field), true, true);
  1150. };
  1151. BootstrapTable.prototype.hideColumn = function (field) {
  1152. this.toggleColumn(getFieldIndex(this.options.columns, field), false, true);
  1153. };
  1154. // BOOTSTRAP TABLE PLUGIN DEFINITION
  1155. // =======================
  1156. var allowedMethods = [
  1157. 'getSelections', 'getData',
  1158. 'load', 'append', 'remove',
  1159. 'updateRow',
  1160. 'mergeCells',
  1161. 'checkAll', 'uncheckAll',
  1162. 'refresh',
  1163. 'resetView',
  1164. 'destroy',
  1165. 'showLoading', 'hideLoading',
  1166. 'showColumn', 'hideColumn'
  1167. ];
  1168. $.fn.bootstrapTable = function (option, _relatedTarget) {
  1169. var value;
  1170. this.each(function () {
  1171. var $this = $(this),
  1172. data = $this.data('bootstrap.table'),
  1173. options = $.extend({}, BootstrapTable.DEFAULTS, $this.data(),
  1174. typeof option === 'object' && option);
  1175. if (typeof option === 'string') {
  1176. if ($.inArray(option, allowedMethods) < 0) {
  1177. throw "Unknown method: " + option;
  1178. }
  1179. if (!data) {
  1180. return;
  1181. }
  1182. value = data[option](_relatedTarget);
  1183. if (option === 'destroy') {
  1184. $this.removeData('bootstrap.table');
  1185. }
  1186. }
  1187. if (!data) {
  1188. $this.data('bootstrap.table', (data = new BootstrapTable(this, options)));
  1189. }
  1190. });
  1191. return typeof value === 'undefined' ? this : value;
  1192. };
  1193. $.fn.bootstrapTable.Constructor = BootstrapTable;
  1194. $.fn.bootstrapTable.defaults = BootstrapTable.DEFAULTS;
  1195. $.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
  1196. $.fn.bootstrapTable.methods = allowedMethods;
  1197. // BOOTSTRAP TABLE INIT
  1198. // =======================
  1199. $(function () {
  1200. $('[data-toggle="table"]').bootstrapTable();
  1201. });
  1202. }(jQuery);