docs.js 18 KB

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