docs.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. $(function () {
  2. 'use strict';
  3. function initTables() {
  4. var cardView = false;
  5. if ($(window).width() < 640) {
  6. cardView = true;
  7. }
  8. $('#table, #column, #event, #method, #localization').bootstrapTable('destroy');
  9. $('#table').bootstrapTable({
  10. cardView: cardView,
  11. columns: [
  12. {field: 'name', title: 'Name', align: 'center', width: 60, sortable: true},
  13. {field: 'type', title: 'Type', align: 'center', width: 60},
  14. {field: 'description', title: 'Description', width: 400},
  15. {field: 'default', title: 'Default', align: '', width: 180}
  16. ],
  17. data: [
  18. {
  19. name: 'bootstrapVersion',
  20. type: 'Number',
  21. description: 'Bootstrap version.',
  22. 'default': '3'
  23. },
  24. {
  25. name: 'classes',
  26. type: 'String',
  27. description: 'The class name of table.',
  28. 'default': 'table table-hover'
  29. },
  30. {
  31. name: 'height',
  32. type: 'Number',
  33. description: 'The height of table.',
  34. 'default': 'undefined'
  35. },
  36. {
  37. name: 'undefinedText',
  38. type: 'String',
  39. description: 'Defines the default undefined text.',
  40. 'default': '-'
  41. },
  42. {
  43. name: 'striped',
  44. type: 'Boolean',
  45. description: 'True to stripe the rows.',
  46. 'default': 'false'
  47. },
  48. {
  49. name: 'sortName',
  50. type: 'String',
  51. description: 'Defines which column can be sorted.',
  52. 'default': 'undefined'
  53. },
  54. {
  55. name: 'sortOrder',
  56. type: 'String',
  57. description: 'Defines the column sort order, can only be "asc" or "desc".',
  58. 'default': 'asc'
  59. },
  60. {
  61. name: 'columns',
  62. type: 'Array',
  63. description: 'The table columns config object, see column properties for more details.',
  64. 'default': '[]'
  65. },
  66. {
  67. name: 'data',
  68. type: 'Array',
  69. description: 'The data to be loaded.',
  70. 'default': '[]'
  71. },
  72. {
  73. name: 'method',
  74. type: 'String',
  75. description: 'The method type to request remote data.',
  76. 'default': 'get'
  77. },
  78. {
  79. name: 'url',
  80. type: 'String',
  81. description: 'A URL to request data from remote site.',
  82. 'default': 'undefined'
  83. },
  84. {
  85. name: 'contentType',
  86. type: 'String',
  87. description: 'The contentType of request remote data.',
  88. 'default': 'application/json'
  89. },
  90. {
  91. name: 'queryParams',
  92. type: 'Function',
  93. description: 'When request remote data, sending additional parameters by format the queryParams, the parameters object contains: <br>pageSize, pageNumber, searchText, sortName, sortOrder.',
  94. 'default': 'function(params) {<br>return {};<br>}'
  95. },
  96. {
  97. name: 'pagination',
  98. type: 'Boolean',
  99. description: 'True to show a pagination toolbar on datagrid bottom.',
  100. 'default': 'false'
  101. },
  102. {
  103. name: 'sidePagination',
  104. type: 'String',
  105. description: 'Defines the side pagination of table, can only be "client" or "server".',
  106. 'default': 'client'
  107. },
  108. {
  109. name: 'totalRows',
  110. type: 'Number',
  111. description: 'Defines the total rows of table, you need to set this option when the sidePagination option is set to "server".',
  112. 'default': 0
  113. },
  114. {
  115. name: 'pageNumber',
  116. type: 'Number',
  117. description: 'When set pagination property, initialize the page number.',
  118. 'default': 1
  119. },
  120. {
  121. name: 'pageSize',
  122. type: 'Number',
  123. description: 'When set pagination property, initialize the page size.',
  124. 'default': 10
  125. },
  126. {
  127. name: 'pageList',
  128. type: 'Array',
  129. description: 'When set pagination property, initialize the page size selecting list.',
  130. 'default': '[10, 25, 50, 100]'
  131. },
  132. {
  133. name: 'search',
  134. type: 'Boolean',
  135. description: 'Enable the search input.',
  136. 'default': 'false'
  137. },
  138. {
  139. name: 'selectItemName',
  140. type: 'String',
  141. description: 'The name of radio or checkbox input.',
  142. 'default': 'btSelectItem'
  143. },
  144. {
  145. name: 'showHeader',
  146. type: 'Boolean',
  147. description: 'False to hide the table header.',
  148. 'default': 'true'
  149. },
  150. {
  151. name: 'showColumns',
  152. type: 'Boolean',
  153. description: 'True to show the columns drop down list.',
  154. 'default': 'false'
  155. },
  156. {
  157. name: 'idField',
  158. type: 'String',
  159. description: 'Indicate which field is an identity field.',
  160. 'default': 'undefined'
  161. },
  162. {
  163. name: 'cardView',
  164. type: 'Boolean',
  165. description: 'True to show card view table, for example mobile view.',
  166. 'default': 'false'
  167. },
  168. {
  169. name: 'clickToSelect',
  170. type: 'Boolean',
  171. description: 'True to select checkbox or radiobox when click rows.',
  172. 'default': 'false'
  173. },
  174. {
  175. name: 'toolbar',
  176. type: 'String',
  177. description: 'A jQuery selector that indicate the toolbar, for example: <br>#toolbar, .toolbar.',
  178. 'default': 'undefined'
  179. },
  180. {
  181. name: 'rowStyle',
  182. type: 'Function',
  183. description: 'The row formatter function, take two parameters: <br>row: the row record data.<br>index: the row index.<br>Support classes or css, code example:<br>{<br>classes: "red", <br>css: {background: "red", color: "white"}<br>}',
  184. 'default': '{}'
  185. }
  186. ]
  187. });
  188. $('#column').bootstrapTable({
  189. cardView: cardView,
  190. columns: [
  191. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 60, sortable: true},
  192. {field: 'type', title: 'Type', align: 'center', valign: 'middle', width: 60},
  193. {field: 'description', title: 'Description', width: 400},
  194. {field: 'default', title: 'Default', align: 'right', valign: 'middle', width: 180}
  195. ],
  196. data: [
  197. {
  198. name: 'radio',
  199. type: 'Boolean',
  200. description: 'True to show a radio. The radio column has fixed width.',
  201. 'default': 'false'
  202. },
  203. {
  204. name: 'checkbox',
  205. type: 'Boolean',
  206. description: 'True to show a checkbox. The checkbox column has fixed width.',
  207. 'default': 'false'
  208. },
  209. {
  210. name: 'field',
  211. type: 'String',
  212. description: 'The column field name.',
  213. 'default': 'undefined'
  214. },
  215. {
  216. name: 'title',
  217. type: 'String',
  218. description: 'The column title text.',
  219. 'default': 'undefined'
  220. },
  221. {
  222. name: 'align',
  223. type: 'String',
  224. description: 'Indicate how to align the column data. "left", "right", "center" can be used.',
  225. 'default': 'undefined'},
  226. {
  227. name: 'valign',
  228. type: 'String',
  229. description: 'Indicate how to align the cell data. "top", "middle", "bottom" can be used.',
  230. 'default': 'undefined'
  231. },
  232. {
  233. name: 'width',
  234. type: 'Number',
  235. description: 'The width of column. If not defined, the width will auto expand to fit its contents.',
  236. 'default': 'undefined'},
  237. {
  238. name: 'sortable',
  239. type: 'Boolean',
  240. description: 'True to allow the column can be sorted.',
  241. 'default': 'false'
  242. },
  243. {
  244. name: 'order',
  245. type: 'String',
  246. description: 'The default sort order, can only be "asc" or "desc".',
  247. 'default': 'asc'
  248. },
  249. {
  250. name: 'visible',
  251. type: 'Boolean',
  252. description: 'True to visible the columns item.',
  253. 'default': 'true'
  254. },
  255. {
  256. name: 'formatter',
  257. type: 'Function',
  258. description: 'The cell formatter function, take two parameters: <br />value: the field value. <br />row: the row record data.<br />index: the row index.',
  259. 'default': 'undefined'
  260. },
  261. {
  262. name: 'sorter',
  263. type: 'Function',
  264. description: 'The custom field sort function that used to do local sorting, take two parameters: <br />a: the first field value.<br /> b: the second field value.',
  265. 'default': 'undefined'
  266. }
  267. ]
  268. });
  269. $('#event').bootstrapTable({
  270. cardView: cardView,
  271. columns: [
  272. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100, sortable: true},
  273. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100, sortable: true},
  274. {field: 'description', title: 'Description', width: 400, sortable: true}
  275. ],
  276. data: [
  277. {
  278. name: 'onClickRow',
  279. parameter: 'row',
  280. description: 'Fires when user click a row, the parameters contains: <br />row: the record corresponding to the clicked row.'},
  281. {
  282. name: 'onSort',
  283. parameter: 'name, order',
  284. description: 'Fires when user sort a column, the parameters contains: <br />name: the sort column field name<br />order: the sort column order.'
  285. },
  286. {
  287. name: 'onCheck',
  288. parameter: 'row',
  289. description: 'Fires when user check a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  290. },
  291. {
  292. name: 'onUncheck',
  293. parameter: 'row',
  294. description: 'Fires when user uncheck a row, the parameters contains: <br />row: the record corresponding to the clicked row.'
  295. },
  296. {
  297. name: 'onCheckAll',
  298. parameter: 'none',
  299. description: 'Fires when user check all rows.'
  300. },
  301. {
  302. name: 'onUncheckAll',
  303. parameter: 'none',
  304. description: 'Fires when user uncheck all rows.'
  305. },
  306. {
  307. name: 'onLoadSuccess',
  308. parameter: 'data',
  309. description: 'Fires when remote data is loaded successfully.'
  310. },
  311. {
  312. name: 'onLoadError',
  313. parameter: 'status',
  314. description: 'Fires when some errors occur to load remote data.'
  315. },
  316. {
  317. name: 'onBeforeLoad',
  318. parameter: 'res',
  319. description: 'Fires before a request is made to load data.'
  320. }
  321. ],
  322. onClickRow: function (row) {
  323. console.log('onClickRow', row);
  324. },
  325. onSort: function (name, order) {
  326. console.log('onSort', name, order);
  327. },
  328. onCheck: function(row) {
  329. console.log('onCheck', row);
  330. },
  331. onUncheck: function(row) {
  332. console.log('onUncheck', row);
  333. },
  334. onCheckAll: function() {
  335. console.log('onCheckAll');
  336. },
  337. onUncheckAll: function() {
  338. console.log('onUncheckAll');
  339. }
  340. });
  341. $('#method').bootstrapTable({
  342. cardView: cardView,
  343. columns: [
  344. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  345. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  346. {field: 'description', title: 'Description', width: 400}
  347. ]
  348. }).bootstrapTable('load', [
  349. {name: 'getSelections', parameter: 'none', description: 'Return all selected rows, when no record selected, am empty array will return.'},
  350. {name: 'load', parameter: 'data', description: 'Load the data to table.'}
  351. ]).bootstrapTable('append', [
  352. {name: 'append', parameter: 'data', description: 'Append the data to table.'},
  353. {name: 'mergeCells', parameter: 'options', description: 'Merge some cells to one cell, the options contains following properties:'},
  354. {name: 'mergeCells', parameter: 'options', description: 'index: the row index.'},
  355. {name: 'mergeCells', parameter: 'options', description: 'field: the field name.'},
  356. {name: 'mergeCells', parameter: 'options', description: 'rowspan: the rowspan count to be merged.'},
  357. {name: 'mergeCells', parameter: 'options', description: 'colspan: the colspan count to be merged.'},
  358. {name: 'refresh', parameter: 'none', description: 'Refresh the remote server data.'},
  359. {name: 'showLoading', parameter: 'none', description: 'Show loading status.'},
  360. {name: 'hideLoading', parameter: 'none', description: 'Hide loading status.'},
  361. {name: 'checkAll', parameter: 'none', description: 'Check all current page rows.'},
  362. {name: 'uncheckAll', parameter: 'none', description: 'Uncheck all current page rows.'},
  363. {name: 'resetView', parameter: 'none', description: 'Reset the bootstrap table view, like display error when init the table with display: none.'},
  364. {name: 'destroy', parameter: 'none', description: 'Destroy the bootstrap table.'}
  365. ]).bootstrapTable('mergeCells', {
  366. index: 3,
  367. field: 'name',
  368. rowspan: 5
  369. }).bootstrapTable('mergeCells', {
  370. index: 3,
  371. field: 'parameter',
  372. rowspan: 5
  373. });
  374. $('#localization').bootstrapTable({
  375. cardView: cardView,
  376. columns: [
  377. {field: 'name', title: 'Name', align: 'center', valign: 'middle', width: 100},
  378. {field: 'parameter', title: 'Parameter', align: 'center', valign: 'middle', width: 100},
  379. {field: 'default', title: 'Default', align: 'center', valign: 'middle', width: 200}
  380. ],
  381. data: [{
  382. name: 'formatLoadingMessage',
  383. parameter: '-',
  384. 'default': 'Loading, please wait…'
  385. }, {
  386. name: 'formatRecordsPerPage',
  387. parameter: 'pageNumber',
  388. 'default': '%s records per page'
  389. }, {
  390. name: 'formatShowingRows',
  391. parameter: 'pageFrom, pageTo, totalRows',
  392. 'default': 'Showing %s to %s of %s rows'
  393. }, {
  394. name: 'formatSearch',
  395. parameter: '-',
  396. 'default': 'Search'
  397. }, {
  398. name: 'formatNoMatches',
  399. parameter: '-',
  400. 'default': 'No matching records found'
  401. }]
  402. });
  403. }
  404. var $window = $(window);
  405. var $body = $(document.body);
  406. var navHeight = $('.navbar').outerHeight(true) + 10;
  407. $body.scrollspy({
  408. target: '.bs-sidebar',
  409. offset: navHeight
  410. });
  411. $window.on('load', function () {
  412. $body.scrollspy('refresh')
  413. });
  414. $window.on('resize', function() {
  415. initTables();
  416. });
  417. // affix
  418. setTimeout(function () {
  419. var $sideBar = $('.bs-sidebar');
  420. $sideBar.affix({
  421. offset: {
  422. top: function () {
  423. var offsetTop = $sideBar.offset().top;
  424. var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10);
  425. var navOuterHeight = $('.bs-docs-nav').height();
  426. return (this.top = offsetTop - navOuterHeight - sideBarMargin);
  427. },
  428. bottom: function () {
  429. return (this.bottom = $('.bs-footer').outerHeight(true));
  430. }
  431. }
  432. });
  433. }, 100);
  434. initTables();
  435. });