docs.js 17 KB

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