bootstrap-table.js 133 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782
  1. (function (global, factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define([], factory);
  4. } else if (typeof exports !== "undefined") {
  5. factory();
  6. } else {
  7. var mod = {
  8. exports: {}
  9. };
  10. factory();
  11. global.bootstrapTable = mod.exports;
  12. }
  13. })(this, function () {
  14. 'use strict';
  15. function _classCallCheck(instance, Constructor) {
  16. if (!(instance instanceof Constructor)) {
  17. throw new TypeError("Cannot call a class as a function");
  18. }
  19. }
  20. var _createClass = function () {
  21. function defineProperties(target, props) {
  22. for (var i = 0; i < props.length; i++) {
  23. var descriptor = props[i];
  24. descriptor.enumerable = descriptor.enumerable || false;
  25. descriptor.configurable = true;
  26. if ("value" in descriptor) descriptor.writable = true;
  27. Object.defineProperty(target, descriptor.key, descriptor);
  28. }
  29. }
  30. return function (Constructor, protoProps, staticProps) {
  31. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  32. if (staticProps) defineProperties(Constructor, staticProps);
  33. return Constructor;
  34. };
  35. }();
  36. var _slicedToArray = function () {
  37. function sliceIterator(arr, i) {
  38. var _arr = [];
  39. var _n = true;
  40. var _d = false;
  41. var _e = undefined;
  42. try {
  43. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  44. _arr.push(_s.value);
  45. if (i && _arr.length === i) break;
  46. }
  47. } catch (err) {
  48. _d = true;
  49. _e = err;
  50. } finally {
  51. try {
  52. if (!_n && _i["return"]) _i["return"]();
  53. } finally {
  54. if (_d) throw _e;
  55. }
  56. }
  57. return _arr;
  58. }
  59. return function (arr, i) {
  60. if (Array.isArray(arr)) {
  61. return arr;
  62. } else if (Symbol.iterator in Object(arr)) {
  63. return sliceIterator(arr, i);
  64. } else {
  65. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  66. }
  67. };
  68. }();
  69. function _toConsumableArray(arr) {
  70. if (Array.isArray(arr)) {
  71. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  72. arr2[i] = arr[i];
  73. }
  74. return arr2;
  75. } else {
  76. return Array.from(arr);
  77. }
  78. }
  79. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  80. return typeof obj;
  81. } : function (obj) {
  82. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  83. };
  84. /**
  85. * @author zhixin wen <wenzhixin2010@gmail.com>
  86. * version: 1.13.1
  87. * https://github.com/wenzhixin/bootstrap-table/
  88. */
  89. (function ($) {
  90. // TOOLS DEFINITION
  91. // ======================
  92. var bootstrapVersion = 3;
  93. try {
  94. var rawVersion = $.fn.dropdown.Constructor.VERSION;
  95. // Only try to parse VERSION if is is defined.
  96. // It is undefined in older versions of Bootstrap (tested with 3.1.1).
  97. if (rawVersion !== undefined) {
  98. bootstrapVersion = parseInt(rawVersion, 10);
  99. }
  100. } catch (e) {
  101. // ignore
  102. }
  103. var bootstrap = {
  104. 3: {
  105. iconsPrefix: 'glyphicon',
  106. icons: {
  107. paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down',
  108. paginationSwitchUp: 'glyphicon-collapse-up icon-chevron-up',
  109. refresh: 'glyphicon-refresh icon-refresh',
  110. toggleOff: 'glyphicon-list-alt icon-list-alt',
  111. toggleOn: 'glyphicon-list-alt icon-list-alt',
  112. columns: 'glyphicon-th icon-th',
  113. detailOpen: 'glyphicon-plus icon-plus',
  114. detailClose: 'glyphicon-minus icon-minus',
  115. fullscreen: 'glyphicon-fullscreen'
  116. },
  117. classes: {
  118. buttons: 'default',
  119. pull: 'pull'
  120. },
  121. html: {
  122. toobarDropdow: ['<ul class="dropdown-menu" role="menu">', '</ul>'],
  123. toobarDropdowItem: '<li role="menuitem"><label>%s</label></li>',
  124. pageDropdown: ['<ul class="dropdown-menu" role="menu">', '</ul>'],
  125. pageDropdownItem: '<li role="menuitem" class="%s"><a href="#">%s</a></li>'
  126. }
  127. },
  128. 4: {
  129. iconsPrefix: 'fa',
  130. icons: {
  131. paginationSwitchDown: 'fa-caret-square-down',
  132. paginationSwitchUp: 'fa-caret-square-up',
  133. refresh: 'fa-sync',
  134. toggleOff: 'fa-toggle-off',
  135. toggleOn: 'fa-toggle-on',
  136. columns: 'fa-th-list',
  137. detailOpen: 'fa-plus',
  138. detailClose: 'fa-minus',
  139. fullscreen: 'fa-arrows-alt'
  140. },
  141. classes: {
  142. buttons: 'secondary',
  143. pull: 'float'
  144. },
  145. html: {
  146. toobarDropdow: ['<div class="dropdown-menu dropdown-menu-right">', '</div>'],
  147. toobarDropdowItem: '<label class="dropdown-item">%s</label>',
  148. pageDropdown: ['<div class="dropdown-menu">', '</div>'],
  149. pageDropdownItem: '<a class="dropdown-item %s" href="#">%s</a>'
  150. }
  151. }
  152. }[bootstrapVersion];
  153. var Utils = {
  154. bootstrapVersion: bootstrapVersion,
  155. sprintf: function sprintf(_str) {
  156. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  157. args[_key - 1] = arguments[_key];
  158. }
  159. var flag = true;
  160. var i = 0;
  161. var str = _str.replace(/%s/g, function () {
  162. var arg = args[i++];
  163. if (typeof arg === 'undefined') {
  164. flag = false;
  165. return '';
  166. }
  167. return arg;
  168. });
  169. return flag ? str : '';
  170. },
  171. getFieldTitle: function getFieldTitle(list, value) {
  172. var _iteratorNormalCompletion = true;
  173. var _didIteratorError = false;
  174. var _iteratorError = undefined;
  175. try {
  176. for (var _iterator = list[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  177. var item = _step.value;
  178. if (item.field === value) {
  179. return item.title;
  180. }
  181. }
  182. } catch (err) {
  183. _didIteratorError = true;
  184. _iteratorError = err;
  185. } finally {
  186. try {
  187. if (!_iteratorNormalCompletion && _iterator.return) {
  188. _iterator.return();
  189. }
  190. } finally {
  191. if (_didIteratorError) {
  192. throw _iteratorError;
  193. }
  194. }
  195. }
  196. return '';
  197. },
  198. setFieldIndex: function setFieldIndex(columns) {
  199. var totalCol = 0;
  200. var flag = [];
  201. var _iteratorNormalCompletion2 = true;
  202. var _didIteratorError2 = false;
  203. var _iteratorError2 = undefined;
  204. try {
  205. for (var _iterator2 = columns[0][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
  206. var column = _step2.value;
  207. totalCol += column.colspan || 1;
  208. }
  209. } catch (err) {
  210. _didIteratorError2 = true;
  211. _iteratorError2 = err;
  212. } finally {
  213. try {
  214. if (!_iteratorNormalCompletion2 && _iterator2.return) {
  215. _iterator2.return();
  216. }
  217. } finally {
  218. if (_didIteratorError2) {
  219. throw _iteratorError2;
  220. }
  221. }
  222. }
  223. for (var i = 0; i < columns.length; i++) {
  224. flag[i] = [];
  225. for (var j = 0; j < totalCol; j++) {
  226. flag[i][j] = false;
  227. }
  228. }
  229. for (var _i = 0; _i < columns.length; _i++) {
  230. var _iteratorNormalCompletion3 = true;
  231. var _didIteratorError3 = false;
  232. var _iteratorError3 = undefined;
  233. try {
  234. for (var _iterator3 = columns[_i][Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
  235. var r = _step3.value;
  236. var rowspan = r.rowspan || 1;
  237. var colspan = r.colspan || 1;
  238. var index = flag[_i].indexOf(false);
  239. if (colspan === 1) {
  240. r.fieldIndex = index;
  241. // when field is undefined, use index instead
  242. if (typeof r.field === 'undefined') {
  243. r.field = index;
  244. }
  245. }
  246. for (var k = 0; k < rowspan; k++) {
  247. flag[_i + k][index] = true;
  248. }
  249. for (var _k = 0; _k < colspan; _k++) {
  250. flag[_i][index + _k] = true;
  251. }
  252. }
  253. } catch (err) {
  254. _didIteratorError3 = true;
  255. _iteratorError3 = err;
  256. } finally {
  257. try {
  258. if (!_iteratorNormalCompletion3 && _iterator3.return) {
  259. _iterator3.return();
  260. }
  261. } finally {
  262. if (_didIteratorError3) {
  263. throw _iteratorError3;
  264. }
  265. }
  266. }
  267. }
  268. },
  269. getScrollBarWidth: function getScrollBarWidth() {
  270. if (this.cachedWidth === null) {
  271. var $inner = $('<div/>').addClass('fixed-table-scroll-inner');
  272. var $outer = $('<div/>').addClass('fixed-table-scroll-outer');
  273. $outer.append($inner);
  274. $('body').append($outer);
  275. var w1 = $inner[0].offsetWidth;
  276. $outer.css('overflow', 'scroll');
  277. var w2 = $inner[0].offsetWidth;
  278. if (w1 === w2) {
  279. w2 = $outer[0].clientWidth;
  280. }
  281. $outer.remove();
  282. this.cachedWidth = w1 - w2;
  283. }
  284. return this.cachedWidth;
  285. },
  286. calculateObjectValue: function calculateObjectValue(self, name, args, defaultValue) {
  287. var func = name;
  288. if (typeof name === 'string') {
  289. // support obj.func1.func2
  290. var names = name.split('.');
  291. if (names.length > 1) {
  292. func = window;
  293. var _iteratorNormalCompletion4 = true;
  294. var _didIteratorError4 = false;
  295. var _iteratorError4 = undefined;
  296. try {
  297. for (var _iterator4 = names[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
  298. var f = _step4.value;
  299. func = func[f];
  300. }
  301. } catch (err) {
  302. _didIteratorError4 = true;
  303. _iteratorError4 = err;
  304. } finally {
  305. try {
  306. if (!_iteratorNormalCompletion4 && _iterator4.return) {
  307. _iterator4.return();
  308. }
  309. } finally {
  310. if (_didIteratorError4) {
  311. throw _iteratorError4;
  312. }
  313. }
  314. }
  315. } else {
  316. func = window[name];
  317. }
  318. }
  319. if (func !== null && (typeof func === 'undefined' ? 'undefined' : _typeof(func)) === 'object') {
  320. return func;
  321. }
  322. if (typeof func === 'function') {
  323. return func.apply(self, args || []);
  324. }
  325. if (!func && typeof name === 'string' && this.sprintf.apply(this, [name].concat(_toConsumableArray(args)))) {
  326. return this.sprintf.apply(this, [name].concat(_toConsumableArray(args)));
  327. }
  328. return defaultValue;
  329. },
  330. compareObjects: function compareObjects(objectA, objectB, compareLength) {
  331. var aKeys = Object.keys(objectA);
  332. var bKeys = Object.keys(objectB);
  333. if (compareLength && aKeys.length !== bKeys.length) {
  334. return false;
  335. }
  336. var _iteratorNormalCompletion5 = true;
  337. var _didIteratorError5 = false;
  338. var _iteratorError5 = undefined;
  339. try {
  340. for (var _iterator5 = aKeys[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
  341. var key = _step5.value;
  342. if (bKeys.includes(key) && objectA[key] !== objectB[key]) {
  343. return false;
  344. }
  345. }
  346. } catch (err) {
  347. _didIteratorError5 = true;
  348. _iteratorError5 = err;
  349. } finally {
  350. try {
  351. if (!_iteratorNormalCompletion5 && _iterator5.return) {
  352. _iterator5.return();
  353. }
  354. } finally {
  355. if (_didIteratorError5) {
  356. throw _iteratorError5;
  357. }
  358. }
  359. }
  360. return true;
  361. },
  362. escapeHTML: function escapeHTML(text) {
  363. if (typeof text === 'string') {
  364. return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;').replace(/`/g, '&#x60;');
  365. }
  366. return text;
  367. },
  368. getRealDataAttr: function getRealDataAttr(dataAttr) {
  369. var _iteratorNormalCompletion6 = true;
  370. var _didIteratorError6 = false;
  371. var _iteratorError6 = undefined;
  372. try {
  373. for (var _iterator6 = Object.entries(dataAttr)[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
  374. var _ref = _step6.value;
  375. var _ref2 = _slicedToArray(_ref, 2);
  376. var attr = _ref2[0];
  377. var value = _ref2[1];
  378. var auxAttr = attr.split(/(?=[A-Z])/).join('-').toLowerCase();
  379. if (auxAttr !== attr) {
  380. dataAttr[auxAttr] = value;
  381. delete dataAttr[attr];
  382. }
  383. }
  384. } catch (err) {
  385. _didIteratorError6 = true;
  386. _iteratorError6 = err;
  387. } finally {
  388. try {
  389. if (!_iteratorNormalCompletion6 && _iterator6.return) {
  390. _iterator6.return();
  391. }
  392. } finally {
  393. if (_didIteratorError6) {
  394. throw _iteratorError6;
  395. }
  396. }
  397. }
  398. return dataAttr;
  399. },
  400. getItemField: function getItemField(item, field, escape) {
  401. var value = item;
  402. if (typeof field !== 'string' || item.hasOwnProperty(field)) {
  403. return escape ? this.escapeHTML(item[field]) : item[field];
  404. }
  405. var props = field.split('.');
  406. var _iteratorNormalCompletion7 = true;
  407. var _didIteratorError7 = false;
  408. var _iteratorError7 = undefined;
  409. try {
  410. for (var _iterator7 = props[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
  411. var p = _step7.value;
  412. value = value && value[p];
  413. }
  414. } catch (err) {
  415. _didIteratorError7 = true;
  416. _iteratorError7 = err;
  417. } finally {
  418. try {
  419. if (!_iteratorNormalCompletion7 && _iterator7.return) {
  420. _iterator7.return();
  421. }
  422. } finally {
  423. if (_didIteratorError7) {
  424. throw _iteratorError7;
  425. }
  426. }
  427. }
  428. return escape ? this.escapeHTML(value) : value;
  429. },
  430. isIEBrowser: function isIEBrowser() {
  431. return navigator.userAgent.includes('MSIE ') || /Trident.*rv:11\./.test(navigator.userAgent);
  432. }
  433. };
  434. // BOOTSTRAP TABLE CLASS DEFINITION
  435. // ======================
  436. var DEFAULTS = {
  437. classes: 'table table-hover',
  438. theadClasses: '',
  439. sortClass: undefined,
  440. locale: undefined,
  441. height: undefined,
  442. undefinedText: '-',
  443. sortName: undefined,
  444. sortOrder: 'asc',
  445. sortStable: false,
  446. rememberOrder: false,
  447. striped: false,
  448. columns: [[]],
  449. data: [],
  450. totalField: 'total',
  451. dataField: 'rows',
  452. method: 'get',
  453. url: undefined,
  454. ajax: undefined,
  455. cache: true,
  456. contentType: 'application/json',
  457. dataType: 'json',
  458. ajaxOptions: {},
  459. queryParams: function queryParams(params) {
  460. return params;
  461. },
  462. queryParamsType: 'limit', responseHandler: function responseHandler(res) {
  463. return res;
  464. },
  465. pagination: false,
  466. onlyInfoPagination: false,
  467. paginationLoop: true,
  468. sidePagination: 'client', // client or server
  469. totalRows: 0, // server side need to set
  470. pageNumber: 1,
  471. pageSize: 10,
  472. pageList: [10, 25, 50, 100],
  473. paginationHAlign: 'right', // right, left
  474. paginationVAlign: 'bottom', // bottom, top, both
  475. paginationDetailHAlign: 'left', // right, left
  476. paginationPreText: '&lsaquo;',
  477. paginationNextText: '&rsaquo;',
  478. search: false,
  479. searchOnEnterKey: false,
  480. strictSearch: false,
  481. searchAlign: 'right',
  482. selectItemName: 'btSelectItem',
  483. showHeader: true,
  484. showFooter: false,
  485. showColumns: false,
  486. showPaginationSwitch: false,
  487. showRefresh: false,
  488. showToggle: false,
  489. showFullscreen: false,
  490. smartDisplay: true,
  491. escape: false,
  492. minimumCountColumns: 1,
  493. idField: undefined,
  494. uniqueId: undefined,
  495. cardView: false,
  496. detailView: false,
  497. detailFormatter: function detailFormatter(index, row) {
  498. return '';
  499. },
  500. detailFilter: function detailFilter(index, row) {
  501. return true;
  502. },
  503. trimOnSearch: true,
  504. clickToSelect: false,
  505. singleSelect: false,
  506. toolbar: undefined,
  507. toolbarAlign: 'left',
  508. buttonsToolbar: undefined,
  509. buttonsAlign: 'right',
  510. checkboxHeader: true,
  511. sortable: true,
  512. silentSort: true,
  513. maintainSelected: false,
  514. searchTimeOut: 500,
  515. searchText: '',
  516. iconSize: undefined,
  517. buttonsClass: bootstrap.classes.buttons,
  518. iconsPrefix: bootstrap.iconsPrefix, // glyphicon or fa(font-awesome)
  519. icons: bootstrap.icons,
  520. customSearch: $.noop,
  521. customSort: $.noop,
  522. ignoreClickToSelectOn: function ignoreClickToSelectOn(_ref3) {
  523. var tagName = _ref3.tagName;
  524. return ['A', 'BUTTON'].includes(tagName);
  525. },
  526. rowStyle: function rowStyle(row, index) {
  527. return {};
  528. },
  529. rowAttributes: function rowAttributes(row, index) {
  530. return {};
  531. },
  532. footerStyle: function footerStyle(row, index) {
  533. return {};
  534. },
  535. onAll: function onAll(name, args) {
  536. return false;
  537. },
  538. onClickCell: function onClickCell(field, value, row, $element) {
  539. return false;
  540. },
  541. onDblClickCell: function onDblClickCell(field, value, row, $element) {
  542. return false;
  543. },
  544. onClickRow: function onClickRow(item, $element) {
  545. return false;
  546. },
  547. onDblClickRow: function onDblClickRow(item, $element) {
  548. return false;
  549. },
  550. onSort: function onSort(name, order) {
  551. return false;
  552. },
  553. onCheck: function onCheck(row) {
  554. return false;
  555. },
  556. onUncheck: function onUncheck(row) {
  557. return false;
  558. },
  559. onCheckAll: function onCheckAll(rows) {
  560. return false;
  561. },
  562. onUncheckAll: function onUncheckAll(rows) {
  563. return false;
  564. },
  565. onCheckSome: function onCheckSome(rows) {
  566. return false;
  567. },
  568. onUncheckSome: function onUncheckSome(rows) {
  569. return false;
  570. },
  571. onLoadSuccess: function onLoadSuccess(data) {
  572. return false;
  573. },
  574. onLoadError: function onLoadError(status) {
  575. return false;
  576. },
  577. onColumnSwitch: function onColumnSwitch(field, checked) {
  578. return false;
  579. },
  580. onPageChange: function onPageChange(number, size) {
  581. return false;
  582. },
  583. onSearch: function onSearch(text) {
  584. return false;
  585. },
  586. onToggle: function onToggle(cardView) {
  587. return false;
  588. },
  589. onPreBody: function onPreBody(data) {
  590. return false;
  591. },
  592. onPostBody: function onPostBody() {
  593. return false;
  594. },
  595. onPostHeader: function onPostHeader() {
  596. return false;
  597. },
  598. onExpandRow: function onExpandRow(index, row, $detail) {
  599. return false;
  600. },
  601. onCollapseRow: function onCollapseRow(index, row) {
  602. return false;
  603. },
  604. onRefreshOptions: function onRefreshOptions(options) {
  605. return false;
  606. },
  607. onRefresh: function onRefresh(params) {
  608. return false;
  609. },
  610. onResetView: function onResetView() {
  611. return false;
  612. },
  613. onScrollBody: function onScrollBody() {
  614. return false;
  615. }
  616. };
  617. var LOCALES = {};
  618. LOCALES['en-US'] = LOCALES.en = {
  619. formatLoadingMessage: function formatLoadingMessage() {
  620. return 'Loading, please wait...';
  621. },
  622. formatRecordsPerPage: function formatRecordsPerPage(pageNumber) {
  623. return Utils.sprintf('%s rows per page', pageNumber);
  624. },
  625. formatShowingRows: function formatShowingRows(pageFrom, pageTo, totalRows) {
  626. return Utils.sprintf('Showing %s to %s of %s rows', pageFrom, pageTo, totalRows);
  627. },
  628. formatDetailPagination: function formatDetailPagination(totalRows) {
  629. return Utils.sprintf('Showing %s rows', totalRows);
  630. },
  631. formatSearch: function formatSearch() {
  632. return 'Search';
  633. },
  634. formatNoMatches: function formatNoMatches() {
  635. return 'No matching records found';
  636. },
  637. formatPaginationSwitch: function formatPaginationSwitch() {
  638. return 'Hide/Show pagination';
  639. },
  640. formatRefresh: function formatRefresh() {
  641. return 'Refresh';
  642. },
  643. formatToggle: function formatToggle() {
  644. return 'Toggle';
  645. },
  646. formatFullscreen: function formatFullscreen() {
  647. return 'Fullscreen';
  648. },
  649. formatColumns: function formatColumns() {
  650. return 'Columns';
  651. },
  652. formatAllRows: function formatAllRows() {
  653. return 'All';
  654. }
  655. };
  656. $.extend(DEFAULTS, LOCALES['en-US']);
  657. var COLUMN_DEFAULTS = {
  658. radio: false,
  659. checkbox: false,
  660. checkboxEnabled: true,
  661. field: undefined,
  662. title: undefined,
  663. titleTooltip: undefined,
  664. 'class': undefined,
  665. align: undefined, // left, right, center
  666. halign: undefined, // left, right, center
  667. falign: undefined, // left, right, center
  668. valign: undefined, // top, middle, bottom
  669. width: undefined,
  670. sortable: false,
  671. order: 'asc', // asc, desc
  672. visible: true,
  673. switchable: true,
  674. clickToSelect: true,
  675. formatter: undefined,
  676. footerFormatter: undefined,
  677. events: undefined,
  678. sorter: undefined,
  679. sortName: undefined,
  680. cellStyle: undefined,
  681. searchable: true,
  682. searchFormatter: true,
  683. cardVisible: true,
  684. escape: false,
  685. showSelectTitle: false
  686. };
  687. var EVENTS = {
  688. 'all.bs.table': 'onAll',
  689. 'click-cell.bs.table': 'onClickCell',
  690. 'dbl-click-cell.bs.table': 'onDblClickCell',
  691. 'click-row.bs.table': 'onClickRow',
  692. 'dbl-click-row.bs.table': 'onDblClickRow',
  693. 'sort.bs.table': 'onSort',
  694. 'check.bs.table': 'onCheck',
  695. 'uncheck.bs.table': 'onUncheck',
  696. 'check-all.bs.table': 'onCheckAll',
  697. 'uncheck-all.bs.table': 'onUncheckAll',
  698. 'check-some.bs.table': 'onCheckSome',
  699. 'uncheck-some.bs.table': 'onUncheckSome',
  700. 'load-success.bs.table': 'onLoadSuccess',
  701. 'load-error.bs.table': 'onLoadError',
  702. 'column-switch.bs.table': 'onColumnSwitch',
  703. 'page-change.bs.table': 'onPageChange',
  704. 'search.bs.table': 'onSearch',
  705. 'toggle.bs.table': 'onToggle',
  706. 'pre-body.bs.table': 'onPreBody',
  707. 'post-body.bs.table': 'onPostBody',
  708. 'post-header.bs.table': 'onPostHeader',
  709. 'expand-row.bs.table': 'onExpandRow',
  710. 'collapse-row.bs.table': 'onCollapseRow',
  711. 'refresh-options.bs.table': 'onRefreshOptions',
  712. 'reset-view.bs.table': 'onResetView',
  713. 'refresh.bs.table': 'onRefresh',
  714. 'scroll-body.bs.table': 'onScrollBody'
  715. };
  716. var BootstrapTable = function () {
  717. function BootstrapTable(el, options) {
  718. _classCallCheck(this, BootstrapTable);
  719. this.options = options;
  720. this.$el = $(el);
  721. this.$el_ = this.$el.clone();
  722. this.timeoutId_ = 0;
  723. this.timeoutFooter_ = 0;
  724. this.init();
  725. }
  726. _createClass(BootstrapTable, [{
  727. key: 'init',
  728. value: function init() {
  729. this.initLocale();
  730. this.initContainer();
  731. this.initTable();
  732. this.initHeader();
  733. this.initData();
  734. this.initHiddenRows();
  735. this.initFooter();
  736. this.initToolbar();
  737. this.initPagination();
  738. this.initBody();
  739. this.initSearchText();
  740. this.initServer();
  741. }
  742. }, {
  743. key: 'initLocale',
  744. value: function initLocale() {
  745. if (this.options.locale) {
  746. var locales = $.fn.bootstrapTable.locales;
  747. var parts = this.options.locale.split(/-|_/);
  748. parts[0].toLowerCase();
  749. if (parts[1]) {
  750. parts[1].toUpperCase();
  751. }
  752. if (locales[this.options.locale]) {
  753. // locale as requested
  754. $.extend(this.options, locales[this.options.locale]);
  755. } else if ($.fn.bootstrapTable.locales[parts.join('-')]) {
  756. // locale with sep set to - (in case original was specified with _)
  757. $.extend(this.options, locales[parts.join('-')]);
  758. } else if ($.fn.bootstrapTable.locales[parts[0]]) {
  759. // short locale language code (i.e. 'en')
  760. $.extend(this.options, locales[parts[0]]);
  761. }
  762. }
  763. }
  764. }, {
  765. key: 'initContainer',
  766. value: function initContainer() {
  767. var topPagination = ['top', 'both'].includes(this.options.paginationVAlign) ? '<div class="fixed-table-pagination clearfix"></div>' : '';
  768. var bottomPagination = ['bottom', 'both'].includes(this.options.paginationVAlign) ? '<div class="fixed-table-pagination"></div>' : '';
  769. this.$container = $('\n <div class="bootstrap-table">\n <div class="fixed-table-toolbar"></div>\n ' + topPagination + '\n <div class="fixed-table-container">\n <div class="fixed-table-header"><table></table></div>\n <div class="fixed-table-body">\n <div class="fixed-table-loading">\n ' + this.options.formatLoadingMessage() + '\n </div>\n </div>\n <div class="fixed-table-footer"><table><tr></tr></table></div>\n </div>\n ' + bottomPagination + '\n </div>\n ');
  770. this.$container.insertAfter(this.$el);
  771. this.$tableContainer = this.$container.find('.fixed-table-container');
  772. this.$tableHeader = this.$container.find('.fixed-table-header');
  773. this.$tableBody = this.$container.find('.fixed-table-body');
  774. this.$tableLoading = this.$container.find('.fixed-table-loading');
  775. this.$tableFooter = this.$container.find('.fixed-table-footer');
  776. // checking if custom table-toolbar exists or not
  777. if (this.options.buttonsToolbar) {
  778. this.$toolbar = $('body').find(this.options.buttonsToolbar);
  779. } else {
  780. this.$toolbar = this.$container.find('.fixed-table-toolbar');
  781. }
  782. this.$pagination = this.$container.find('.fixed-table-pagination');
  783. this.$tableBody.append(this.$el);
  784. this.$container.after('<div class="clearfix"></div>');
  785. this.$el.addClass(this.options.classes);
  786. if (this.options.striped) {
  787. this.$el.addClass('table-striped');
  788. }
  789. if (this.options.classes.split(' ').includes('table-no-bordered')) {
  790. this.$tableContainer.addClass('table-no-bordered');
  791. }
  792. }
  793. }, {
  794. key: 'initTable',
  795. value: function initTable() {
  796. var _this = this;
  797. var columns = [];
  798. var data = [];
  799. this.$header = this.$el.find('>thead');
  800. if (!this.$header.length) {
  801. this.$header = $('<thead class="' + this.options.theadClasses + '"></thead>').appendTo(this.$el);
  802. }
  803. this.$header.find('tr').each(function (i, el) {
  804. var column = [];
  805. $(el).find('th').each(function (i, el) {
  806. // #2014: getFieldIndex and elsewhere assume this is string, causes issues if not
  807. if (typeof $(el).data('field') !== 'undefined') {
  808. $(el).data('field', '' + $(el).data('field'));
  809. }
  810. column.push($.extend({}, {
  811. title: $(el).html(),
  812. 'class': $(el).attr('class'),
  813. titleTooltip: $(el).attr('title'),
  814. rowspan: $(el).attr('rowspan') ? +$(el).attr('rowspan') : undefined,
  815. colspan: $(el).attr('colspan') ? +$(el).attr('colspan') : undefined
  816. }, $(el).data()));
  817. });
  818. columns.push(column);
  819. });
  820. if (!Array.isArray(this.options.columns[0])) {
  821. this.options.columns = [this.options.columns];
  822. }
  823. this.options.columns = $.extend(true, [], columns, this.options.columns);
  824. this.columns = [];
  825. this.fieldsColumnsIndex = [];
  826. Utils.setFieldIndex(this.options.columns);
  827. this.options.columns.forEach(function (columns, i) {
  828. columns.forEach(function (_column, j) {
  829. var column = $.extend({}, BootstrapTable.COLUMN_DEFAULTS, _column);
  830. if (typeof column.fieldIndex !== 'undefined') {
  831. _this.columns[column.fieldIndex] = column;
  832. _this.fieldsColumnsIndex[column.field] = column.fieldIndex;
  833. }
  834. _this.options.columns[i][j] = column;
  835. });
  836. });
  837. // if options.data is setting, do not process tbody data
  838. if (this.options.data.length) {
  839. return;
  840. }
  841. var m = [];
  842. this.$el.find('>tbody>tr').each(function (y, el) {
  843. var row = {};
  844. // save tr's id, class and data-* attributes
  845. row._id = $(el).attr('id');
  846. row._class = $(el).attr('class');
  847. row._data = Utils.getRealDataAttr($(el).data());
  848. $(el).find('>td').each(function (_x, el) {
  849. var cspan = +$(el).attr('colspan') || 1;
  850. var rspan = +$(el).attr('rowspan') || 1;
  851. var x = _x;
  852. // skip already occupied cells in current row
  853. for (; m[y] && m[y][x]; x++) {}
  854. // ignore
  855. // mark matrix elements occupied by current cell with true
  856. for (var tx = x; tx < x + cspan; tx++) {
  857. for (var ty = y; ty < y + rspan; ty++) {
  858. if (!m[ty]) {
  859. // fill missing rows
  860. m[ty] = [];
  861. }
  862. m[ty][tx] = true;
  863. }
  864. }
  865. var field = _this.columns[x].field;
  866. row[field] = $(el).html();
  867. // save td's id, class and data-* attributes
  868. row['_' + field + '_id'] = $(el).attr('id');
  869. row['_' + field + '_class'] = $(el).attr('class');
  870. row['_' + field + '_rowspan'] = $(el).attr('rowspan');
  871. row['_' + field + '_colspan'] = $(el).attr('colspan');
  872. row['_' + field + '_title'] = $(el).attr('title');
  873. row['_' + field + '_data'] = Utils.getRealDataAttr($(el).data());
  874. });
  875. data.push(row);
  876. });
  877. this.options.data = data;
  878. if (data.length) {
  879. this.fromHtml = true;
  880. }
  881. }
  882. }, {
  883. key: 'initHeader',
  884. value: function initHeader() {
  885. var _this2 = this;
  886. var visibleColumns = {};
  887. var html = [];
  888. this.header = {
  889. fields: [],
  890. styles: [],
  891. classes: [],
  892. formatters: [],
  893. events: [],
  894. sorters: [],
  895. sortNames: [],
  896. cellStyles: [],
  897. searchables: []
  898. };
  899. this.options.columns.forEach(function (columns, i) {
  900. html.push('<tr>');
  901. if (i === 0 && !_this2.options.cardView && _this2.options.detailView) {
  902. html.push('<th class="detail" rowspan="' + _this2.options.columns.length + '">\n <div class="fht-cell"></div>\n </th>\n ');
  903. }
  904. columns.forEach(function (column, j) {
  905. var text = '';
  906. var halign = ''; // header align style
  907. var align = ''; // body align style
  908. var style = '';
  909. var class_ = Utils.sprintf(' class="%s"', column['class']);
  910. var unitWidth = 'px';
  911. var width = column.width;
  912. if (column.width !== undefined && !_this2.options.cardView) {
  913. if (typeof column.width === 'string') {
  914. if (column.width.includes('%')) {
  915. unitWidth = '%';
  916. }
  917. }
  918. }
  919. if (column.width && typeof column.width === 'string') {
  920. width = column.width.replace('%', '').replace('px', '');
  921. }
  922. halign = Utils.sprintf('text-align: %s; ', column.halign ? column.halign : column.align);
  923. align = Utils.sprintf('text-align: %s; ', column.align);
  924. style = Utils.sprintf('vertical-align: %s; ', column.valign);
  925. style += Utils.sprintf('width: %s; ', (column.checkbox || column.radio) && !width ? !column.showSelectTitle ? '36px' : undefined : width ? width + unitWidth : undefined);
  926. if (typeof column.fieldIndex !== 'undefined') {
  927. _this2.header.fields[column.fieldIndex] = column.field;
  928. _this2.header.styles[column.fieldIndex] = align + style;
  929. _this2.header.classes[column.fieldIndex] = class_;
  930. _this2.header.formatters[column.fieldIndex] = column.formatter;
  931. _this2.header.events[column.fieldIndex] = column.events;
  932. _this2.header.sorters[column.fieldIndex] = column.sorter;
  933. _this2.header.sortNames[column.fieldIndex] = column.sortName;
  934. _this2.header.cellStyles[column.fieldIndex] = column.cellStyle;
  935. _this2.header.searchables[column.fieldIndex] = column.searchable;
  936. if (!column.visible) {
  937. return;
  938. }
  939. if (_this2.options.cardView && !column.cardVisible) {
  940. return;
  941. }
  942. visibleColumns[column.field] = column;
  943. }
  944. html.push('<th' + Utils.sprintf(' title="%s"', column.titleTooltip), column.checkbox || column.radio ? Utils.sprintf(' class="bs-checkbox %s"', column['class'] || '') : class_, Utils.sprintf(' style="%s"', halign + style), Utils.sprintf(' rowspan="%s"', column.rowspan), Utils.sprintf(' colspan="%s"', column.colspan), Utils.sprintf(' data-field="%s"', column.field),
  945. // If `column` is not the first element of `this.options.columns[0]`, then className 'data-not-first-th' should be added.
  946. j === 0 && i > 0 ? ' data-not-first-th' : '', '>');
  947. html.push(Utils.sprintf('<div class="th-inner %s">', _this2.options.sortable && column.sortable ? 'sortable both' : ''));
  948. text = _this2.options.escape ? Utils.escapeHTML(column.title) : column.title;
  949. var title = text;
  950. if (column.checkbox) {
  951. text = '';
  952. if (!_this2.options.singleSelect && _this2.options.checkboxHeader) {
  953. text = '<input name="btSelectAll" type="checkbox" />';
  954. }
  955. _this2.header.stateField = column.field;
  956. }
  957. if (column.radio) {
  958. text = '';
  959. _this2.header.stateField = column.field;
  960. _this2.options.singleSelect = true;
  961. }
  962. if (!text && column.showSelectTitle) {
  963. text += title;
  964. }
  965. html.push(text);
  966. html.push('</div>');
  967. html.push('<div class="fht-cell"></div>');
  968. html.push('</div>');
  969. html.push('</th>');
  970. });
  971. html.push('</tr>');
  972. });
  973. this.$header.html(html.join(''));
  974. this.$header.find('th[data-field]').each(function (i, el) {
  975. $(el).data(visibleColumns[$(el).data('field')]);
  976. });
  977. this.$container.off('click', '.th-inner').on('click', '.th-inner', function (e) {
  978. var $this = $(e.currentTarget);
  979. if (_this2.options.detailView && !$this.parent().hasClass('bs-checkbox')) {
  980. if ($this.closest('.bootstrap-table')[0] !== _this2.$container[0]) {
  981. return false;
  982. }
  983. }
  984. if (_this2.options.sortable && $this.parent().data().sortable) {
  985. _this2.onSort(e);
  986. }
  987. });
  988. this.$header.children().children().off('keypress').on('keypress', function (e) {
  989. if (_this2.options.sortable && $(e.currentTarget).data().sortable) {
  990. var code = e.keyCode || e.which;
  991. if (code === 13) {
  992. // Enter keycode
  993. _this2.onSort(e);
  994. }
  995. }
  996. });
  997. $(window).off('resize.bootstrap-table');
  998. if (!this.options.showHeader || this.options.cardView) {
  999. this.$header.hide();
  1000. this.$tableHeader.hide();
  1001. this.$tableLoading.css('top', 0);
  1002. } else {
  1003. this.$header.show();
  1004. this.$tableHeader.show();
  1005. this.$tableLoading.css('top', this.$header.outerHeight() + 1);
  1006. // Assign the correct sortable arrow
  1007. this.getCaret();
  1008. $(window).on('resize.bootstrap-table', $.proxy(this.resetWidth, this));
  1009. }
  1010. this.$selectAll = this.$header.find('[name="btSelectAll"]');
  1011. this.$selectAll.off('click').on('click', function (_ref4) {
  1012. var currentTarget = _ref4.currentTarget;
  1013. var checked = $(currentTarget).prop('checked');
  1014. _this2[checked ? 'checkAll' : 'uncheckAll']();
  1015. _this2.updateSelected();
  1016. });
  1017. }
  1018. }, {
  1019. key: 'initFooter',
  1020. value: function initFooter() {
  1021. if (!this.options.showFooter || this.options.cardView) {
  1022. this.$tableFooter.hide();
  1023. } else {
  1024. this.$tableFooter.show();
  1025. }
  1026. }
  1027. }, {
  1028. key: 'initData',
  1029. value: function initData(data, type) {
  1030. if (type === 'append') {
  1031. this.options.data = this.options.data.concat(data);
  1032. } else if (type === 'prepend') {
  1033. this.options.data = [].concat(data).concat(this.options.data);
  1034. } else {
  1035. this.options.data = data || this.options.data;
  1036. }
  1037. this.data = this.options.data;
  1038. if (this.options.sidePagination === 'server') {
  1039. return;
  1040. }
  1041. this.initSort();
  1042. }
  1043. }, {
  1044. key: 'initSort',
  1045. value: function initSort() {
  1046. var _this3 = this;
  1047. var name = this.options.sortName;
  1048. var order = this.options.sortOrder === 'desc' ? -1 : 1;
  1049. var index = this.header.fields.indexOf(this.options.sortName);
  1050. var timeoutId = 0;
  1051. if (this.options.customSort !== $.noop) {
  1052. this.options.customSort.apply(this, [this.options.sortName, this.options.sortOrder]);
  1053. return;
  1054. }
  1055. if (index !== -1) {
  1056. if (this.options.sortStable) {
  1057. this.data.forEach(function (row, i) {
  1058. row._position = i;
  1059. });
  1060. }
  1061. this.data.sort(function (a, b) {
  1062. if (_this3.header.sortNames[index]) {
  1063. name = _this3.header.sortNames[index];
  1064. }
  1065. var aa = Utils.getItemField(a, name, _this3.options.escape);
  1066. var bb = Utils.getItemField(b, name, _this3.options.escape);
  1067. var value = Utils.calculateObjectValue(_this3.header, _this3.header.sorters[index], [aa, bb, a, b]);
  1068. if (value !== undefined) {
  1069. if (_this3.options.sortStable && value === 0) {
  1070. return a._position - b._position;
  1071. }
  1072. return order * value;
  1073. }
  1074. // Fix #161: undefined or null string sort bug.
  1075. if (aa === undefined || aa === null) {
  1076. aa = '';
  1077. }
  1078. if (bb === undefined || bb === null) {
  1079. bb = '';
  1080. }
  1081. if (_this3.options.sortStable && aa === bb) {
  1082. aa = a._position;
  1083. bb = b._position;
  1084. return a._position - b._position;
  1085. }
  1086. // IF both values are numeric, do a numeric comparison
  1087. if ($.isNumeric(aa) && $.isNumeric(bb)) {
  1088. // Convert numerical values form string to float.
  1089. aa = parseFloat(aa);
  1090. bb = parseFloat(bb);
  1091. if (aa < bb) {
  1092. return order * -1;
  1093. }
  1094. return order;
  1095. }
  1096. if (aa === bb) {
  1097. return 0;
  1098. }
  1099. // If value is not a string, convert to string
  1100. if (typeof aa !== 'string') {
  1101. aa = aa.toString();
  1102. }
  1103. if (aa.localeCompare(bb) === -1) {
  1104. return order * -1;
  1105. }
  1106. return order;
  1107. });
  1108. if (this.options.sortClass !== undefined) {
  1109. clearTimeout(timeoutId);
  1110. timeoutId = setTimeout(function () {
  1111. _this3.$el.removeClass(_this3.options.sortClass);
  1112. var index = _this3.$header.find(Utils.sprintf('[data-field="%s"]', _this3.options.sortName).index() + 1);
  1113. _this3.$el.find(Utils.sprintf('tr td:nth-child(%s)', index)).addClass(_this3.options.sortClass);
  1114. }, 250);
  1115. }
  1116. }
  1117. }
  1118. }, {
  1119. key: 'onSort',
  1120. value: function onSort(_ref5) {
  1121. var type = _ref5.type,
  1122. currentTarget = _ref5.currentTarget;
  1123. var $this = type === 'keypress' ? $(currentTarget) : $(currentTarget).parent();
  1124. var $this_ = this.$header.find('th').eq($this.index());
  1125. this.$header.add(this.$header_).find('span.order').remove();
  1126. if (this.options.sortName === $this.data('field')) {
  1127. this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
  1128. } else {
  1129. this.options.sortName = $this.data('field');
  1130. if (this.options.rememberOrder) {
  1131. this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
  1132. } else {
  1133. this.options.sortOrder = this.columns[this.fieldsColumnsIndex[$this.data('field')]].order;
  1134. }
  1135. }
  1136. this.trigger('sort', this.options.sortName, this.options.sortOrder);
  1137. $this.add($this_).data('order', this.options.sortOrder);
  1138. // Assign the correct sortable arrow
  1139. this.getCaret();
  1140. if (this.options.sidePagination === 'server') {
  1141. this.initServer(this.options.silentSort);
  1142. return;
  1143. }
  1144. this.initSort();
  1145. this.initBody();
  1146. }
  1147. }, {
  1148. key: 'initToolbar',
  1149. value: function initToolbar() {
  1150. var _this4 = this;
  1151. var html = [];
  1152. var timeoutId = 0;
  1153. var $keepOpen = void 0;
  1154. var $search = void 0;
  1155. var switchableCount = 0;
  1156. if (this.$toolbar.find('.bs-bars').children().length) {
  1157. $('body').append($(this.options.toolbar));
  1158. }
  1159. this.$toolbar.html('');
  1160. if (typeof this.options.toolbar === 'string' || _typeof(this.options.toolbar) === 'object') {
  1161. $(Utils.sprintf('<div class="bs-bars %s-%s"></div>', bootstrap.classes.pull, this.options.toolbarAlign)).appendTo(this.$toolbar).append($(this.options.toolbar));
  1162. }
  1163. // showColumns, showToggle, showRefresh
  1164. html = [Utils.sprintf('<div class="columns columns-%s btn-group %s-%s">', this.options.buttonsAlign, bootstrap.classes.pull, this.options.buttonsAlign)];
  1165. if (typeof this.options.icons === 'string') {
  1166. this.options.icons = Utils.calculateObjectValue(null, this.options.icons);
  1167. }
  1168. if (this.options.showPaginationSwitch) {
  1169. html.push(Utils.sprintf('<button class="btn' + Utils.sprintf(' btn-%s', this.options.buttonsClass) + Utils.sprintf(' btn-%s', this.options.iconSize) + '" type="button" name="paginationSwitch" aria-label="pagination Switch" title="%s">', this.options.formatPaginationSwitch()), Utils.sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.paginationSwitchDown), '</button>');
  1170. }
  1171. if (this.options.showFullscreen) {
  1172. this.$toolbar.find('button[name="fullscreen"]').off('click').on('click', $.proxy(this.toggleFullscreen, this));
  1173. }
  1174. if (this.options.showRefresh) {
  1175. html.push(Utils.sprintf('<button class="btn' + Utils.sprintf(' btn-%s', this.options.buttonsClass) + Utils.sprintf(' btn-%s', this.options.iconSize) + '" type="button" name="refresh" aria-label="refresh" title="%s">', this.options.formatRefresh()), Utils.sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.refresh), '</button>');
  1176. }
  1177. if (this.options.showToggle) {
  1178. html.push(Utils.sprintf('<button class="btn' + Utils.sprintf(' btn-%s', this.options.buttonsClass) + Utils.sprintf(' btn-%s', this.options.iconSize) + '" type="button" name="toggle" aria-label="toggle" title="%s">', this.options.formatToggle()), Utils.sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.toggleOff), '</button>');
  1179. }
  1180. if (this.options.showFullscreen) {
  1181. html.push(Utils.sprintf('<button class="btn' + Utils.sprintf(' btn-%s', this.options.buttonsClass) + Utils.sprintf(' btn-%s', this.options.iconSize) + '" type="button" name="fullscreen" aria-label="fullscreen" title="%s">', this.options.formatFullscreen()), Utils.sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.fullscreen), '</button>');
  1182. }
  1183. if (this.options.showColumns) {
  1184. html.push(Utils.sprintf('<div class="keep-open btn-group" title="%s">', this.options.formatColumns()), '<button type="button" aria-label="columns" class="btn' + Utils.sprintf(' btn-%s', this.options.buttonsClass) + Utils.sprintf(' btn-%s', this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">', Utils.sprintf('<i class="%s %s"></i>', this.options.iconsPrefix, this.options.icons.columns), ' <span class="caret"></span>', '</button>', bootstrap.html.toobarDropdow[0]);
  1185. this.columns.forEach(function (column, i) {
  1186. if (column.radio || column.checkbox) {
  1187. return;
  1188. }
  1189. if (_this4.options.cardView && !column.cardVisible) {
  1190. return;
  1191. }
  1192. var checked = column.visible ? ' checked="checked"' : '';
  1193. if (column.switchable) {
  1194. html.push(Utils.sprintf(bootstrap.html.toobarDropdowItem, Utils.sprintf('<input type="checkbox" data-field="%s" value="%s"%s> %s', column.field, i, checked, column.title)));
  1195. switchableCount++;
  1196. }
  1197. });
  1198. html.push(bootstrap.html.toobarDropdow[1], '</div>');
  1199. }
  1200. html.push('</div>');
  1201. // Fix #188: this.showToolbar is for extensions
  1202. if (this.showToolbar || html.length > 2) {
  1203. this.$toolbar.append(html.join(''));
  1204. }
  1205. if (this.options.showPaginationSwitch) {
  1206. this.$toolbar.find('button[name="paginationSwitch"]').off('click').on('click', $.proxy(this.togglePagination, this));
  1207. }
  1208. if (this.options.showRefresh) {
  1209. this.$toolbar.find('button[name="refresh"]').off('click').on('click', $.proxy(this.refresh, this));
  1210. }
  1211. if (this.options.showToggle) {
  1212. this.$toolbar.find('button[name="toggle"]').off('click').on('click', function () {
  1213. _this4.toggleView();
  1214. });
  1215. }
  1216. if (this.options.showColumns) {
  1217. $keepOpen = this.$toolbar.find('.keep-open');
  1218. if (switchableCount <= this.options.minimumCountColumns) {
  1219. $keepOpen.find('input').prop('disabled', true);
  1220. }
  1221. $keepOpen.find('li').off('click').on('click', function (e) {
  1222. e.stopImmediatePropagation();
  1223. });
  1224. $keepOpen.find('input').off('click').on('click', function (_ref6) {
  1225. var currentTarget = _ref6.currentTarget;
  1226. var $this = $(currentTarget);
  1227. _this4.toggleColumn($this.val(), $this.prop('checked'), false);
  1228. _this4.trigger('column-switch', $this.data('field'), $this.prop('checked'));
  1229. });
  1230. }
  1231. if (this.options.search) {
  1232. html = [];
  1233. html.push(Utils.sprintf('<div class="%s-%s search">', bootstrap.classes.pull, this.options.searchAlign), Utils.sprintf('<input class="form-control' + Utils.sprintf(' input-%s', this.options.iconSize) + '" type="text" placeholder="%s">', this.options.formatSearch()), '</div>');
  1234. this.$toolbar.append(html.join(''));
  1235. $search = this.$toolbar.find('.search input');
  1236. $search.off('keyup drop blur').on('keyup drop blur', function (event) {
  1237. if (_this4.options.searchOnEnterKey && event.keyCode !== 13) {
  1238. return;
  1239. }
  1240. if ([37, 38, 39, 40].includes(event.keyCode)) {
  1241. return;
  1242. }
  1243. clearTimeout(timeoutId); // doesn't matter if it's 0
  1244. timeoutId = setTimeout(function () {
  1245. _this4.onSearch(event);
  1246. }, _this4.options.searchTimeOut);
  1247. });
  1248. if (Utils.isIEBrowser()) {
  1249. $search.off('mouseup').on('mouseup', function (event) {
  1250. clearTimeout(timeoutId); // doesn't matter if it's 0
  1251. timeoutId = setTimeout(function () {
  1252. _this4.onSearch(event);
  1253. }, _this4.options.searchTimeOut);
  1254. });
  1255. }
  1256. }
  1257. }
  1258. }, {
  1259. key: 'onSearch',
  1260. value: function onSearch(_ref7) {
  1261. var currentTarget = _ref7.currentTarget,
  1262. firedByInitSearchText = _ref7.firedByInitSearchText;
  1263. var text = $.trim($(currentTarget).val());
  1264. // trim search input
  1265. if (this.options.trimOnSearch && $(currentTarget).val() !== text) {
  1266. $(currentTarget).val(text);
  1267. }
  1268. if (text === this.searchText) {
  1269. return;
  1270. }
  1271. this.searchText = text;
  1272. this.options.searchText = text;
  1273. if (!firedByInitSearchText) {
  1274. this.options.pageNumber = 1;
  1275. }
  1276. this.initSearch();
  1277. if (firedByInitSearchText) {
  1278. if (this.options.sidePagination === 'client') {
  1279. this.updatePagination();
  1280. }
  1281. } else {
  1282. this.updatePagination();
  1283. }
  1284. this.trigger('search', text);
  1285. }
  1286. }, {
  1287. key: 'initSearch',
  1288. value: function initSearch() {
  1289. var _this5 = this;
  1290. if (this.options.sidePagination !== 'server') {
  1291. if (this.options.customSearch !== $.noop) {
  1292. Utils.calculateObjectValue(this.options, this.options.customSearch, [this.searchText]);
  1293. return;
  1294. }
  1295. var s = this.searchText && (this.options.escape ? Utils.escapeHTML(this.searchText) : this.searchText).toLowerCase();
  1296. var f = $.isEmptyObject(this.filterColumns) ? null : this.filterColumns;
  1297. // Check filter
  1298. this.data = f ? this.options.data.filter(function (item, i) {
  1299. for (var key in f) {
  1300. if (Array.isArray(f[key]) && !f[key].includes(item[key]) || !Array.isArray(f[key]) && item[key] !== f[key]) {
  1301. return false;
  1302. }
  1303. }
  1304. return true;
  1305. }) : this.options.data;
  1306. this.data = s ? this.data.filter(function (item, i) {
  1307. for (var j = 0; j < _this5.header.fields.length; j++) {
  1308. if (!_this5.header.searchables[j]) {
  1309. continue;
  1310. }
  1311. var key = $.isNumeric(_this5.header.fields[j]) ? parseInt(_this5.header.fields[j], 10) : _this5.header.fields[j];
  1312. var column = _this5.columns[_this5.fieldsColumnsIndex[key]];
  1313. var value = void 0;
  1314. if (typeof key === 'string') {
  1315. value = item;
  1316. var props = key.split('.');
  1317. for (var _i2 = 0; _i2 < props.length; _i2++) {
  1318. if (value[props[_i2]] !== null) {
  1319. value = value[props[_i2]];
  1320. }
  1321. }
  1322. } else {
  1323. value = item[key];
  1324. }
  1325. // Fix #142: respect searchForamtter boolean
  1326. if (column && column.searchFormatter) {
  1327. value = Utils.calculateObjectValue(column, _this5.header.formatters[j], [value, item, i], value);
  1328. }
  1329. if (typeof value === 'string' || typeof value === 'number') {
  1330. if (_this5.options.strictSearch) {
  1331. if (('' + value).toLowerCase() === s) {
  1332. return true;
  1333. }
  1334. } else {
  1335. if (('' + value).toLowerCase().includes(s)) {
  1336. return true;
  1337. }
  1338. }
  1339. }
  1340. }
  1341. return false;
  1342. }) : this.data;
  1343. }
  1344. }
  1345. }, {
  1346. key: 'initPagination',
  1347. value: function initPagination() {
  1348. var _this6 = this;
  1349. if (!this.options.pagination) {
  1350. this.$pagination.hide();
  1351. return;
  1352. }
  1353. this.$pagination.show();
  1354. var html = [];
  1355. var $allSelected = false;
  1356. var i = void 0;
  1357. var from = void 0;
  1358. var to = void 0;
  1359. var $pageList = void 0;
  1360. var $pre = void 0;
  1361. var $next = void 0;
  1362. var $number = void 0;
  1363. var data = this.getData();
  1364. var pageList = this.options.pageList;
  1365. if (this.options.sidePagination !== 'server') {
  1366. this.options.totalRows = data.length;
  1367. }
  1368. this.totalPages = 0;
  1369. if (this.options.totalRows) {
  1370. if (this.options.pageSize === this.options.formatAllRows()) {
  1371. this.options.pageSize = this.options.totalRows;
  1372. $allSelected = true;
  1373. } else if (this.options.pageSize === this.options.totalRows) {
  1374. // Fix #667 Table with pagination,
  1375. // multiple pages and a search this matches to one page throws exception
  1376. var pageLst = typeof this.options.pageList === 'string' ? this.options.pageList.replace('[', '').replace(']', '').replace(/ /g, '').toLowerCase().split(',') : this.options.pageList;
  1377. if (pageLst.includes(this.options.formatAllRows().toLowerCase())) {
  1378. $allSelected = true;
  1379. }
  1380. }
  1381. this.totalPages = ~~((this.options.totalRows - 1) / this.options.pageSize) + 1;
  1382. this.options.totalPages = this.totalPages;
  1383. }
  1384. if (this.totalPages > 0 && this.options.pageNumber > this.totalPages) {
  1385. this.options.pageNumber = this.totalPages;
  1386. }
  1387. this.pageFrom = (this.options.pageNumber - 1) * this.options.pageSize + 1;
  1388. this.pageTo = this.options.pageNumber * this.options.pageSize;
  1389. if (this.pageTo > this.options.totalRows) {
  1390. this.pageTo = this.options.totalRows;
  1391. }
  1392. html.push(Utils.sprintf('<div class="%s-%s pagination-detail">', bootstrap.classes.pull, this.options.paginationDetailHAlign), '<span class="pagination-info">', this.options.onlyInfoPagination ? this.options.formatDetailPagination(this.options.totalRows) : this.options.formatShowingRows(this.pageFrom, this.pageTo, this.options.totalRows), '</span>');
  1393. if (!this.options.onlyInfoPagination) {
  1394. html.push('<span class="page-list">');
  1395. var pageNumber = [Utils.sprintf('<span class="btn-group %s">', this.options.paginationVAlign === 'top' || this.options.paginationVAlign === 'both' ? 'dropdown' : 'dropup'), '<button type="button" class="btn' + Utils.sprintf(' btn-%s', this.options.buttonsClass) + Utils.sprintf(' btn-%s', this.options.iconSize) + ' dropdown-toggle" data-toggle="dropdown">', '<span class="page-size">', $allSelected ? this.options.formatAllRows() : this.options.pageSize, '</span>', ' <span class="caret"></span>', '</button>', bootstrap.html.pageDropdown[0]];
  1396. if (typeof this.options.pageList === 'string') {
  1397. var list = this.options.pageList.replace('[', '').replace(']', '').replace(/ /g, '').split(',');
  1398. pageList = [];
  1399. var _iteratorNormalCompletion8 = true;
  1400. var _didIteratorError8 = false;
  1401. var _iteratorError8 = undefined;
  1402. try {
  1403. for (var _iterator8 = list[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
  1404. var value = _step8.value;
  1405. pageList.push(value.toUpperCase() === this.options.formatAllRows().toUpperCase() || value.toUpperCase() === 'UNLIMITED' ? this.options.formatAllRows() : +value);
  1406. }
  1407. } catch (err) {
  1408. _didIteratorError8 = true;
  1409. _iteratorError8 = err;
  1410. } finally {
  1411. try {
  1412. if (!_iteratorNormalCompletion8 && _iterator8.return) {
  1413. _iterator8.return();
  1414. }
  1415. } finally {
  1416. if (_didIteratorError8) {
  1417. throw _iteratorError8;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. pageList.forEach(function (page, i) {
  1423. if (!_this6.options.smartDisplay || i === 0 || pageList[i - 1] < _this6.options.totalRows) {
  1424. var active = void 0;
  1425. if ($allSelected) {
  1426. active = page === _this6.options.formatAllRows() ? 'active' : '';
  1427. } else {
  1428. active = page === _this6.options.pageSize ? 'active' : '';
  1429. }
  1430. pageNumber.push(Utils.sprintf(bootstrap.html.pageDropdownItem, active, page));
  1431. }
  1432. });
  1433. pageNumber.push(bootstrap.html.pageDropdown[1] + '</span>');
  1434. html.push(this.options.formatRecordsPerPage(pageNumber.join('')));
  1435. html.push('</span>');
  1436. html.push('</div>', Utils.sprintf('<div class="%s-%s pagination">', bootstrap.classes.pull, this.options.paginationHAlign), '<ul class="pagination' + Utils.sprintf(' pagination-%s', this.options.iconSize) + '">', Utils.sprintf('<li class="page-item page-pre"><a class="page-link" href="#">%s</a></li>', this.options.paginationPreText));
  1437. if (this.totalPages < 5) {
  1438. from = 1;
  1439. to = this.totalPages;
  1440. } else {
  1441. from = this.options.pageNumber - 2;
  1442. to = from + 4;
  1443. if (from < 1) {
  1444. from = 1;
  1445. to = 5;
  1446. }
  1447. if (to > this.totalPages) {
  1448. to = this.totalPages;
  1449. from = to - 4;
  1450. }
  1451. }
  1452. if (this.totalPages >= 6) {
  1453. if (this.options.pageNumber >= 3) {
  1454. html.push(Utils.sprintf('<li class="page-item page-first%s">', this.options.pageNumber === 1 ? ' active' : ''), '<a class="page-link" href="#">', 1, '</a>', '</li>');
  1455. from++;
  1456. }
  1457. if (this.options.pageNumber >= 4) {
  1458. if (this.options.pageNumber === 4 || this.totalPages === 6 || this.totalPages === 7) {
  1459. from--;
  1460. } else {
  1461. html.push('<li class="page-item page-first-separator disabled">', '<a class="page-link" href="#">...</a>', '</li>');
  1462. }
  1463. to--;
  1464. }
  1465. }
  1466. if (this.totalPages >= 7) {
  1467. if (this.options.pageNumber >= this.totalPages - 2) {
  1468. from--;
  1469. }
  1470. }
  1471. if (this.totalPages === 6) {
  1472. if (this.options.pageNumber >= this.totalPages - 2) {
  1473. to++;
  1474. }
  1475. } else if (this.totalPages >= 7) {
  1476. if (this.totalPages === 7 || this.options.pageNumber >= this.totalPages - 3) {
  1477. to++;
  1478. }
  1479. }
  1480. for (i = from; i <= to; i++) {
  1481. html.push(Utils.sprintf('<li class="page-item%s">', i === this.options.pageNumber ? ' active' : ''), '<a class="page-link" href="#">', i, '</a>', '</li>');
  1482. }
  1483. if (this.totalPages >= 8) {
  1484. if (this.options.pageNumber <= this.totalPages - 4) {
  1485. html.push('<li class="page-item page-last-separator disabled">', '<a class="page-link" href="#">...</a>', '</li>');
  1486. }
  1487. }
  1488. if (this.totalPages >= 6) {
  1489. if (this.options.pageNumber <= this.totalPages - 3) {
  1490. html.push(Utils.sprintf('<li class="page-item page-last%s">', this.totalPages === this.options.pageNumber ? ' active' : ''), '<a class="page-link" href="#">', this.totalPages, '</a>', '</li>');
  1491. }
  1492. }
  1493. html.push(Utils.sprintf('<li class="page-item page-next"><a class="page-link" href="#">%s</a></li>', this.options.paginationNextText), '</ul>', '</div>');
  1494. }
  1495. this.$pagination.html(html.join(''));
  1496. if (!this.options.onlyInfoPagination) {
  1497. $pageList = this.$pagination.find('.page-list a');
  1498. $pre = this.$pagination.find('.page-pre');
  1499. $next = this.$pagination.find('.page-next');
  1500. $number = this.$pagination.find('.page-item').not('.page-next, .page-pre');
  1501. if (this.options.smartDisplay) {
  1502. if (this.totalPages <= 1) {
  1503. this.$pagination.find('div.pagination').hide();
  1504. }
  1505. if (pageList.length < 2 || this.options.totalRows <= pageList[0]) {
  1506. this.$pagination.find('span.page-list').hide();
  1507. }
  1508. // when data is empty, hide the pagination
  1509. this.$pagination[this.getData().length ? 'show' : 'hide']();
  1510. }
  1511. if (!this.options.paginationLoop) {
  1512. if (this.options.pageNumber === 1) {
  1513. $pre.addClass('disabled');
  1514. }
  1515. if (this.options.pageNumber === this.totalPages) {
  1516. $next.addClass('disabled');
  1517. }
  1518. }
  1519. if ($allSelected) {
  1520. this.options.pageSize = this.options.formatAllRows();
  1521. }
  1522. // removed the events for last and first, onPageNumber executeds the same logic
  1523. $pageList.off('click').on('click', $.proxy(this.onPageListChange, this));
  1524. $pre.off('click').on('click', $.proxy(this.onPagePre, this));
  1525. $next.off('click').on('click', $.proxy(this.onPageNext, this));
  1526. $number.off('click').on('click', $.proxy(this.onPageNumber, this));
  1527. }
  1528. }
  1529. }, {
  1530. key: 'updatePagination',
  1531. value: function updatePagination(event) {
  1532. // Fix #171: IE disabled button can be clicked bug.
  1533. if (event && $(event.currentTarget).hasClass('disabled')) {
  1534. return;
  1535. }
  1536. if (!this.options.maintainSelected) {
  1537. this.resetRows();
  1538. }
  1539. this.initPagination();
  1540. if (this.options.sidePagination === 'server') {
  1541. this.initServer();
  1542. } else {
  1543. this.initBody();
  1544. }
  1545. this.trigger('page-change', this.options.pageNumber, this.options.pageSize);
  1546. }
  1547. }, {
  1548. key: 'onPageListChange',
  1549. value: function onPageListChange(event) {
  1550. event.preventDefault();
  1551. var $this = $(event.currentTarget);
  1552. $this.parent().addClass('active').siblings().removeClass('active');
  1553. this.options.pageSize = $this.text().toUpperCase() === this.options.formatAllRows().toUpperCase() ? this.options.formatAllRows() : +$this.text();
  1554. this.$toolbar.find('.page-size').text(this.options.pageSize);
  1555. this.updatePagination(event);
  1556. return false;
  1557. }
  1558. }, {
  1559. key: 'onPagePre',
  1560. value: function onPagePre(event) {
  1561. event.preventDefault();
  1562. if (this.options.pageNumber - 1 === 0) {
  1563. this.options.pageNumber = this.options.totalPages;
  1564. } else {
  1565. this.options.pageNumber--;
  1566. }
  1567. this.updatePagination(event);
  1568. return false;
  1569. }
  1570. }, {
  1571. key: 'onPageNext',
  1572. value: function onPageNext(event) {
  1573. event.preventDefault();
  1574. if (this.options.pageNumber + 1 > this.options.totalPages) {
  1575. this.options.pageNumber = 1;
  1576. } else {
  1577. this.options.pageNumber++;
  1578. }
  1579. this.updatePagination(event);
  1580. return false;
  1581. }
  1582. }, {
  1583. key: 'onPageNumber',
  1584. value: function onPageNumber(event) {
  1585. event.preventDefault();
  1586. if (this.options.pageNumber === +$(event.currentTarget).text()) {
  1587. return;
  1588. }
  1589. this.options.pageNumber = +$(event.currentTarget).text();
  1590. this.updatePagination(event);
  1591. return false;
  1592. }
  1593. }, {
  1594. key: 'initRow',
  1595. value: function initRow(item, i, data, parentDom) {
  1596. var _this7 = this;
  1597. var html = [];
  1598. var style = {};
  1599. var csses = [];
  1600. var data_ = '';
  1601. var attributes = {};
  1602. var htmlAttributes = [];
  1603. if (this.hiddenRows.includes(item)) {
  1604. return;
  1605. }
  1606. style = Utils.calculateObjectValue(this.options, this.options.rowStyle, [item, i], style);
  1607. if (style && style.css) {
  1608. var _iteratorNormalCompletion9 = true;
  1609. var _didIteratorError9 = false;
  1610. var _iteratorError9 = undefined;
  1611. try {
  1612. for (var _iterator9 = Object.entries(style.css)[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
  1613. var _ref8 = _step9.value;
  1614. var _ref9 = _slicedToArray(_ref8, 2);
  1615. var key = _ref9[0];
  1616. var value = _ref9[1];
  1617. csses.push(key + ': ' + value);
  1618. }
  1619. } catch (err) {
  1620. _didIteratorError9 = true;
  1621. _iteratorError9 = err;
  1622. } finally {
  1623. try {
  1624. if (!_iteratorNormalCompletion9 && _iterator9.return) {
  1625. _iterator9.return();
  1626. }
  1627. } finally {
  1628. if (_didIteratorError9) {
  1629. throw _iteratorError9;
  1630. }
  1631. }
  1632. }
  1633. }
  1634. attributes = Utils.calculateObjectValue(this.options, this.options.rowAttributes, [item, i], attributes);
  1635. if (attributes) {
  1636. var _iteratorNormalCompletion10 = true;
  1637. var _didIteratorError10 = false;
  1638. var _iteratorError10 = undefined;
  1639. try {
  1640. for (var _iterator10 = Object.entries(attributes)[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
  1641. var _ref10 = _step10.value;
  1642. var _ref11 = _slicedToArray(_ref10, 2);
  1643. var _key2 = _ref11[0];
  1644. var _value2 = _ref11[1];
  1645. htmlAttributes.push(_key2 + '="' + Utils.escapeHTML(_value2) + '"');
  1646. }
  1647. } catch (err) {
  1648. _didIteratorError10 = true;
  1649. _iteratorError10 = err;
  1650. } finally {
  1651. try {
  1652. if (!_iteratorNormalCompletion10 && _iterator10.return) {
  1653. _iterator10.return();
  1654. }
  1655. } finally {
  1656. if (_didIteratorError10) {
  1657. throw _iteratorError10;
  1658. }
  1659. }
  1660. }
  1661. }
  1662. if (item._data && !$.isEmptyObject(item._data)) {
  1663. var _iteratorNormalCompletion11 = true;
  1664. var _didIteratorError11 = false;
  1665. var _iteratorError11 = undefined;
  1666. try {
  1667. for (var _iterator11 = Object.entries(item._data)[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
  1668. var _ref12 = _step11.value;
  1669. var _ref13 = _slicedToArray(_ref12, 2);
  1670. var k = _ref13[0];
  1671. var v = _ref13[1];
  1672. // ignore data-index
  1673. if (k === 'index') {
  1674. return;
  1675. }
  1676. data_ += ' data-' + k + '="' + v + '"';
  1677. }
  1678. } catch (err) {
  1679. _didIteratorError11 = true;
  1680. _iteratorError11 = err;
  1681. } finally {
  1682. try {
  1683. if (!_iteratorNormalCompletion11 && _iterator11.return) {
  1684. _iterator11.return();
  1685. }
  1686. } finally {
  1687. if (_didIteratorError11) {
  1688. throw _iteratorError11;
  1689. }
  1690. }
  1691. }
  1692. }
  1693. html.push('<tr', Utils.sprintf(' %s', htmlAttributes.length ? htmlAttributes.join(' ') : undefined), Utils.sprintf(' id="%s"', Array.isArray(item) ? undefined : item._id), Utils.sprintf(' class="%s"', style.classes || (Array.isArray(item) ? undefined : item._class)), ' data-index="' + i + '"', Utils.sprintf(' data-uniqueid="%s"', item[this.options.uniqueId]), Utils.sprintf('%s', data_), '>');
  1694. if (this.options.cardView) {
  1695. html.push('<td colspan="' + this.header.fields.length + '"><div class="card-views">');
  1696. }
  1697. if (!this.options.cardView && this.options.detailView) {
  1698. html.push('<td>');
  1699. if (Utils.calculateObjectValue(null, this.options.detailFilter, [i, item])) {
  1700. html.push('\n <a class="detail-icon" href="#">\n <i class="' + this.options.iconsPrefix + ' ' + this.options.icons.detailOpen + '"></i>\n </a>\n ');
  1701. }
  1702. html.push('</td>');
  1703. }
  1704. this.header.fields.forEach(function (field, j) {
  1705. var text = '';
  1706. var value_ = Utils.getItemField(item, field, _this7.options.escape);
  1707. var value = '';
  1708. var type = '';
  1709. var cellStyle = {};
  1710. var id_ = '';
  1711. var class_ = _this7.header.classes[j];
  1712. var style_ = '';
  1713. var data_ = '';
  1714. var rowspan_ = '';
  1715. var colspan_ = '';
  1716. var title_ = '';
  1717. var column = _this7.columns[j];
  1718. if (_this7.fromHtml && typeof value_ === 'undefined') {
  1719. if (!column.checkbox && !column.radio) {
  1720. return;
  1721. }
  1722. }
  1723. if (!column.visible) {
  1724. return;
  1725. }
  1726. if (_this7.options.cardView && !column.cardVisible) {
  1727. return;
  1728. }
  1729. if (column.escape) {
  1730. value_ = Utils.escapeHTML(value_);
  1731. }
  1732. if (csses.concat([_this7.header.styles[j]]).length) {
  1733. style_ = ' style="' + csses.concat([_this7.header.styles[j]]).join('; ') + '"';
  1734. }
  1735. // handle td's id and class
  1736. if (item['_' + field + '_id']) {
  1737. id_ = Utils.sprintf(' id="%s"', item['_' + field + '_id']);
  1738. }
  1739. if (item['_' + field + '_class']) {
  1740. class_ = Utils.sprintf(' class="%s"', item['_' + field + '_class']);
  1741. }
  1742. if (item['_' + field + '_rowspan']) {
  1743. rowspan_ = Utils.sprintf(' rowspan="%s"', item['_' + field + '_rowspan']);
  1744. }
  1745. if (item['_' + field + '_colspan']) {
  1746. colspan_ = Utils.sprintf(' colspan="%s"', item['_' + field + '_colspan']);
  1747. }
  1748. if (item['_' + field + '_title']) {
  1749. title_ = Utils.sprintf(' title="%s"', item['_' + field + '_title']);
  1750. }
  1751. cellStyle = Utils.calculateObjectValue(_this7.header, _this7.header.cellStyles[j], [value_, item, i, field], cellStyle);
  1752. if (cellStyle.classes) {
  1753. class_ = ' class="' + cellStyle.classes + '"';
  1754. }
  1755. if (cellStyle.css) {
  1756. var csses_ = [];
  1757. var _iteratorNormalCompletion12 = true;
  1758. var _didIteratorError12 = false;
  1759. var _iteratorError12 = undefined;
  1760. try {
  1761. for (var _iterator12 = Object.entries(cellStyle.css)[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
  1762. var _ref14 = _step12.value;
  1763. var _ref15 = _slicedToArray(_ref14, 2);
  1764. var _key3 = _ref15[0];
  1765. var _value3 = _ref15[1];
  1766. csses_.push(_key3 + ': ' + _value3);
  1767. }
  1768. } catch (err) {
  1769. _didIteratorError12 = true;
  1770. _iteratorError12 = err;
  1771. } finally {
  1772. try {
  1773. if (!_iteratorNormalCompletion12 && _iterator12.return) {
  1774. _iterator12.return();
  1775. }
  1776. } finally {
  1777. if (_didIteratorError12) {
  1778. throw _iteratorError12;
  1779. }
  1780. }
  1781. }
  1782. style_ = ' style="' + csses_.concat(_this7.header.styles[j]).join('; ') + '"';
  1783. }
  1784. value = Utils.calculateObjectValue(column, _this7.header.formatters[j], [value_, item, i, field], value_);
  1785. if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) {
  1786. var _iteratorNormalCompletion13 = true;
  1787. var _didIteratorError13 = false;
  1788. var _iteratorError13 = undefined;
  1789. try {
  1790. for (var _iterator13 = Object.entries(item['_' + field + '_data'])[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
  1791. var _ref16 = _step13.value;
  1792. var _ref17 = _slicedToArray(_ref16, 2);
  1793. var _k2 = _ref17[0];
  1794. var _v = _ref17[1];
  1795. // ignore data-index
  1796. if (_k2 === 'index') {
  1797. return;
  1798. }
  1799. data_ += ' data-' + _k2 + '="' + _v + '"';
  1800. }
  1801. } catch (err) {
  1802. _didIteratorError13 = true;
  1803. _iteratorError13 = err;
  1804. } finally {
  1805. try {
  1806. if (!_iteratorNormalCompletion13 && _iterator13.return) {
  1807. _iterator13.return();
  1808. }
  1809. } finally {
  1810. if (_didIteratorError13) {
  1811. throw _iteratorError13;
  1812. }
  1813. }
  1814. }
  1815. }
  1816. if (column.checkbox || column.radio) {
  1817. type = column.checkbox ? 'checkbox' : type;
  1818. type = column.radio ? 'radio' : type;
  1819. var c = column['class'] || '';
  1820. var isChecked = value === true || value_ || value && value.checked;
  1821. var isDisabled = !column.checkboxEnabled || value && value.disabled;
  1822. text = [_this7.options.cardView ? '<div class="card-view ' + c + '">' : '<td class="bs-checkbox ' + c + '">', '<input\n data-index="' + i + '"\n name="' + _this7.options.selectItemName + '"\n type="' + type + '"\n ' + Utils.sprintf('value="%s"', item[_this7.options.idField]) + '\n ' + Utils.sprintf('checked="%s"', isChecked ? 'checked' : undefined) + '\n ' + Utils.sprintf('disabled="%s"', isDisabled ? 'disabled' : undefined) + ' />', _this7.header.formatters[j] && typeof value === 'string' ? value : '', _this7.options.cardView ? '</div>' : '</td>'].join('');
  1823. item[_this7.header.stateField] = value === true || !!value_ || value && value.checked;
  1824. } else {
  1825. value = typeof value === 'undefined' || value === null ? _this7.options.undefinedText : value;
  1826. if (_this7.options.cardView) {
  1827. var cardTitle = _this7.options.showHeader ? '<span class="title"' + style + '>' + Utils.getFieldTitle(_this7.columns, field) + '</span>' : '';
  1828. text = '<div class="card-view">' + cardTitle + '<span class="value">' + value + '</span></div>';
  1829. if (_this7.options.smartDisplay && value === '') {
  1830. text = '<div class="card-view"></div>';
  1831. }
  1832. } else {
  1833. text = '<td' + id_ + class_ + style_ + data_ + rowspan_ + colspan_ + title_ + '>' + value + '</td>';
  1834. }
  1835. }
  1836. html.push(text);
  1837. });
  1838. if (this.options.cardView) {
  1839. html.push('</div></td>');
  1840. }
  1841. html.push('</tr>');
  1842. return html.join('');
  1843. }
  1844. }, {
  1845. key: 'initBody',
  1846. value: function initBody(fixedScroll) {
  1847. var _this8 = this;
  1848. var data = this.getData();
  1849. this.trigger('pre-body', data);
  1850. this.$body = this.$el.find('>tbody');
  1851. if (!this.$body.length) {
  1852. this.$body = $('<tbody></tbody>').appendTo(this.$el);
  1853. }
  1854. // Fix #389 Bootstrap-table-flatJSON is not working
  1855. if (!this.options.pagination || this.options.sidePagination === 'server') {
  1856. this.pageFrom = 1;
  1857. this.pageTo = data.length;
  1858. }
  1859. var trFragments = $(document.createDocumentFragment());
  1860. var hasTr = false;
  1861. for (var i = this.pageFrom - 1; i < this.pageTo; i++) {
  1862. var item = data[i];
  1863. var tr = this.initRow(item, i, data, trFragments);
  1864. hasTr = hasTr || !!tr;
  1865. if (tr && typeof tr === 'string') {
  1866. trFragments.append(tr);
  1867. }
  1868. }
  1869. // show no records
  1870. if (!hasTr) {
  1871. this.$body.html('<tr class="no-records-found">' + Utils.sprintf('<td colspan="%s">%s</td>', this.$header.find('th').length, this.options.formatNoMatches()) + '</tr>');
  1872. } else {
  1873. this.$body.html(trFragments);
  1874. }
  1875. if (!fixedScroll) {
  1876. this.scrollTo(0);
  1877. }
  1878. // click to select by column
  1879. this.$body.find('> tr[data-index] > td').off('click dblclick').on('click dblclick', function (_ref18) {
  1880. var currentTarget = _ref18.currentTarget,
  1881. type = _ref18.type,
  1882. target = _ref18.target;
  1883. var $td = $(currentTarget);
  1884. var $tr = $td.parent();
  1885. var item = _this8.data[$tr.data('index')];
  1886. var index = $td[0].cellIndex;
  1887. var fields = _this8.getVisibleFields();
  1888. var field = fields[_this8.options.detailView && !_this8.options.cardView ? index - 1 : index];
  1889. var column = _this8.columns[_this8.fieldsColumnsIndex[field]];
  1890. var value = Utils.getItemField(item, field, _this8.options.escape);
  1891. if ($td.find('.detail-icon').length) {
  1892. return;
  1893. }
  1894. _this8.trigger(type === 'click' ? 'click-cell' : 'dbl-click-cell', field, value, item, $td);
  1895. _this8.trigger(type === 'click' ? 'click-row' : 'dbl-click-row', item, $tr, field);
  1896. // if click to select - then trigger the checkbox/radio click
  1897. if (type === 'click' && _this8.options.clickToSelect && column.clickToSelect && !_this8.options.ignoreClickToSelectOn(target)) {
  1898. var $selectItem = $tr.find(Utils.sprintf('[name="%s"]', _this8.options.selectItemName));
  1899. if ($selectItem.length) {
  1900. $selectItem[0].click(); // #144: .trigger('click') bug
  1901. }
  1902. }
  1903. });
  1904. this.$body.find('> tr[data-index] > td > .detail-icon').off('click').on('click', function (e) {
  1905. e.preventDefault();
  1906. var $this = $(e.currentTarget); // Fix #980 Detail view, when searching, returns wrong row
  1907. var $tr = $this.parent().parent();
  1908. var index = $tr.data('index');
  1909. var row = data[index];
  1910. // remove and update
  1911. if ($tr.next().is('tr.detail-view')) {
  1912. $this.find('i').attr('class', Utils.sprintf('%s %s', _this8.options.iconsPrefix, _this8.options.icons.detailOpen));
  1913. _this8.trigger('collapse-row', index, row, $tr.next());
  1914. $tr.next().remove();
  1915. } else {
  1916. $this.find('i').attr('class', Utils.sprintf('%s %s', _this8.options.iconsPrefix, _this8.options.icons.detailClose));
  1917. $tr.after(Utils.sprintf('<tr class="detail-view"><td colspan="%s"></td></tr>', $tr.find('td').length));
  1918. var $element = $tr.next().find('td');
  1919. var content = Utils.calculateObjectValue(_this8.options, _this8.options.detailFormatter, [index, row, $element], '');
  1920. if ($element.length === 1) {
  1921. $element.append(content);
  1922. }
  1923. _this8.trigger('expand-row', index, row, $element);
  1924. }
  1925. _this8.resetView();
  1926. return false;
  1927. });
  1928. this.$selectItem = this.$body.find(Utils.sprintf('[name="%s"]', this.options.selectItemName));
  1929. this.$selectItem.off('click').on('click', function (e) {
  1930. e.stopImmediatePropagation();
  1931. var $this = $(e.currentTarget);
  1932. _this8.check_($this.prop('checked'), $this.data('index'));
  1933. });
  1934. this.header.events.forEach(function (_events, i) {
  1935. var events = _events;
  1936. if (!events) {
  1937. return;
  1938. }
  1939. // fix bug, if events is defined with namespace
  1940. if (typeof events === 'string') {
  1941. events = Utils.calculateObjectValue(null, events);
  1942. }
  1943. var field = _this8.header.fields[i];
  1944. var fieldIndex = _this8.getVisibleFields().indexOf(field);
  1945. if (fieldIndex === -1) {
  1946. return;
  1947. }
  1948. if (_this8.options.detailView && !_this8.options.cardView) {
  1949. fieldIndex += 1;
  1950. }
  1951. var _loop = function _loop(key, event) {
  1952. _this8.$body.find('>tr:not(.no-records-found)').each(function (i, tr) {
  1953. var $tr = $(tr);
  1954. var $td = $tr.find(_this8.options.cardView ? '.card-view' : 'td').eq(fieldIndex);
  1955. var index = key.indexOf(' ');
  1956. var name = key.substring(0, index);
  1957. var el = key.substring(index + 1);
  1958. $td.find(el).off(name).on(name, function (e) {
  1959. var index = $tr.data('index');
  1960. var row = _this8.data[index];
  1961. var value = row[field];
  1962. event.apply(_this8, [e, value, row, index]);
  1963. });
  1964. });
  1965. };
  1966. var _iteratorNormalCompletion14 = true;
  1967. var _didIteratorError14 = false;
  1968. var _iteratorError14 = undefined;
  1969. try {
  1970. for (var _iterator14 = Object.entries(events)[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
  1971. var _ref19 = _step14.value;
  1972. var _ref20 = _slicedToArray(_ref19, 2);
  1973. var key = _ref20[0];
  1974. var event = _ref20[1];
  1975. _loop(key, event);
  1976. }
  1977. } catch (err) {
  1978. _didIteratorError14 = true;
  1979. _iteratorError14 = err;
  1980. } finally {
  1981. try {
  1982. if (!_iteratorNormalCompletion14 && _iterator14.return) {
  1983. _iterator14.return();
  1984. }
  1985. } finally {
  1986. if (_didIteratorError14) {
  1987. throw _iteratorError14;
  1988. }
  1989. }
  1990. }
  1991. });
  1992. this.updateSelected();
  1993. this.resetView();
  1994. this.trigger('post-body', data);
  1995. }
  1996. }, {
  1997. key: 'initServer',
  1998. value: function initServer(silent, query, url) {
  1999. var _this9 = this;
  2000. var data = {};
  2001. var index = this.header.fields.indexOf(this.options.sortName);
  2002. var params = {
  2003. searchText: this.searchText,
  2004. sortName: this.options.sortName,
  2005. sortOrder: this.options.sortOrder
  2006. };
  2007. if (this.header.sortNames[index]) {
  2008. params.sortName = this.header.sortNames[index];
  2009. }
  2010. if (this.options.pagination && this.options.sidePagination === 'server') {
  2011. params.pageSize = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
  2012. params.pageNumber = this.options.pageNumber;
  2013. }
  2014. if (!(url || this.options.url) && !this.options.ajax) {
  2015. return;
  2016. }
  2017. if (this.options.queryParamsType === 'limit') {
  2018. params = {
  2019. search: params.searchText,
  2020. sort: params.sortName,
  2021. order: params.sortOrder
  2022. };
  2023. if (this.options.pagination && this.options.sidePagination === 'server') {
  2024. params.offset = this.options.pageSize === this.options.formatAllRows() ? 0 : this.options.pageSize * (this.options.pageNumber - 1);
  2025. params.limit = this.options.pageSize === this.options.formatAllRows() ? this.options.totalRows : this.options.pageSize;
  2026. if (params.limit === 0) {
  2027. delete params.limit;
  2028. }
  2029. }
  2030. }
  2031. if (!$.isEmptyObject(this.filterColumnsPartial)) {
  2032. params.filter = JSON.stringify(this.filterColumnsPartial, null);
  2033. }
  2034. data = Utils.calculateObjectValue(this.options, this.options.queryParams, [params], data);
  2035. $.extend(data, query || {});
  2036. // false to stop request
  2037. if (data === false) {
  2038. return;
  2039. }
  2040. if (!silent) {
  2041. this.$tableLoading.show();
  2042. }
  2043. var request = $.extend({}, Utils.calculateObjectValue(null, this.options.ajaxOptions), {
  2044. type: this.options.method,
  2045. url: url || this.options.url,
  2046. data: this.options.contentType === 'application/json' && this.options.method === 'post' ? JSON.stringify(data) : data,
  2047. cache: this.options.cache,
  2048. contentType: this.options.contentType,
  2049. dataType: this.options.dataType,
  2050. success: function success(_res) {
  2051. var res = Utils.calculateObjectValue(_this9.options, _this9.options.responseHandler, [_res], _res);
  2052. _this9.load(res);
  2053. _this9.trigger('load-success', res);
  2054. if (!silent) _this9.$tableLoading.hide();
  2055. },
  2056. error: function error(res) {
  2057. var data = [];
  2058. if (_this9.options.sidePagination === 'server') {
  2059. data = {};
  2060. data[_this9.options.totalField] = 0;
  2061. data[_this9.options.dataField] = [];
  2062. }
  2063. _this9.load(data);
  2064. _this9.trigger('load-error', res.status, res);
  2065. if (!silent) _this9.$tableLoading.hide();
  2066. }
  2067. });
  2068. if (this.options.ajax) {
  2069. Utils.calculateObjectValue(this, this.options.ajax, [request], null);
  2070. } else {
  2071. if (this._xhr && this._xhr.readyState !== 4) {
  2072. this._xhr.abort();
  2073. }
  2074. this._xhr = $.ajax(request);
  2075. }
  2076. }
  2077. }, {
  2078. key: 'initSearchText',
  2079. value: function initSearchText() {
  2080. if (this.options.search) {
  2081. this.searchText = '';
  2082. if (this.options.searchText !== '') {
  2083. var $search = this.$toolbar.find('.search input');
  2084. $search.val(this.options.searchText);
  2085. this.onSearch({ currentTarget: $search, firedByInitSearchText: true });
  2086. }
  2087. }
  2088. }
  2089. }, {
  2090. key: 'getCaret',
  2091. value: function getCaret() {
  2092. var _this10 = this;
  2093. this.$header.find('th').each(function (i, th) {
  2094. $(th).find('.sortable').removeClass('desc asc').addClass($(th).data('field') === _this10.options.sortName ? _this10.options.sortOrder : 'both');
  2095. });
  2096. }
  2097. }, {
  2098. key: 'updateSelected',
  2099. value: function updateSelected() {
  2100. var checkAll = this.$selectItem.filter(':enabled').length && this.$selectItem.filter(':enabled').length === this.$selectItem.filter(':enabled').filter(':checked').length;
  2101. this.$selectAll.add(this.$selectAll_).prop('checked', checkAll);
  2102. this.$selectItem.each(function (i, el) {
  2103. $(el).closest('tr')[$(el).prop('checked') ? 'addClass' : 'removeClass']('selected');
  2104. });
  2105. }
  2106. }, {
  2107. key: 'updateRows',
  2108. value: function updateRows() {
  2109. var _this11 = this;
  2110. this.$selectItem.each(function (i, el) {
  2111. _this11.data[$(el).data('index')][_this11.header.stateField] = $(el).prop('checked');
  2112. });
  2113. }
  2114. }, {
  2115. key: 'resetRows',
  2116. value: function resetRows() {
  2117. var _iteratorNormalCompletion15 = true;
  2118. var _didIteratorError15 = false;
  2119. var _iteratorError15 = undefined;
  2120. try {
  2121. for (var _iterator15 = this.data[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
  2122. var row = _step15.value;
  2123. this.$selectAll.prop('checked', false);
  2124. this.$selectItem.prop('checked', false);
  2125. if (this.header.stateField) {
  2126. row[this.header.stateField] = false;
  2127. }
  2128. }
  2129. } catch (err) {
  2130. _didIteratorError15 = true;
  2131. _iteratorError15 = err;
  2132. } finally {
  2133. try {
  2134. if (!_iteratorNormalCompletion15 && _iterator15.return) {
  2135. _iterator15.return();
  2136. }
  2137. } finally {
  2138. if (_didIteratorError15) {
  2139. throw _iteratorError15;
  2140. }
  2141. }
  2142. }
  2143. this.initHiddenRows();
  2144. }
  2145. }, {
  2146. key: 'trigger',
  2147. value: function trigger(_name) {
  2148. var _options;
  2149. var name = _name + '.bs.table';
  2150. for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key4 = 1; _key4 < _len2; _key4++) {
  2151. args[_key4 - 1] = arguments[_key4];
  2152. }
  2153. (_options = this.options)[BootstrapTable.EVENTS[name]].apply(_options, args);
  2154. this.$el.trigger($.Event(name), args);
  2155. this.options.onAll(name, args);
  2156. this.$el.trigger($.Event('all.bs.table'), [name, args]);
  2157. }
  2158. }, {
  2159. key: 'resetHeader',
  2160. value: function resetHeader() {
  2161. // fix #61: the hidden table reset header bug.
  2162. // fix bug: get $el.css('width') error sometime (height = 500)
  2163. clearTimeout(this.timeoutId_);
  2164. this.timeoutId_ = setTimeout($.proxy(this.fitHeader, this), this.$el.is(':hidden') ? 100 : 0);
  2165. }
  2166. }, {
  2167. key: 'fitHeader',
  2168. value: function fitHeader() {
  2169. var _this12 = this;
  2170. if (this.$el.is(':hidden')) {
  2171. this.timeoutId_ = setTimeout($.proxy(this.fitHeader, this), 100);
  2172. return;
  2173. }
  2174. var fixedBody = this.$tableBody.get(0);
  2175. var scrollWidth = fixedBody.scrollWidth > fixedBody.clientWidth && fixedBody.scrollHeight > fixedBody.clientHeight + this.$header.outerHeight() ? Utils.getScrollBarWidth() : 0;
  2176. this.$el.css('margin-top', -this.$header.outerHeight());
  2177. var focused = $(':focus');
  2178. if (focused.length > 0) {
  2179. var $th = focused.parents('th');
  2180. if ($th.length > 0) {
  2181. var dataField = $th.attr('data-field');
  2182. if (dataField !== undefined) {
  2183. var $headerTh = this.$header.find('[data-field=\'' + dataField + '\']');
  2184. if ($headerTh.length > 0) {
  2185. $headerTh.find(':input').addClass('focus-temp');
  2186. }
  2187. }
  2188. }
  2189. }
  2190. this.$header_ = this.$header.clone(true, true);
  2191. this.$selectAll_ = this.$header_.find('[name="btSelectAll"]');
  2192. this.$tableHeader.css({
  2193. 'margin-right': scrollWidth
  2194. }).find('table').css('width', this.$el.outerWidth()).html('').attr('class', this.$el.attr('class')).append(this.$header_);
  2195. var focusedTemp = $('.focus-temp:visible:eq(0)');
  2196. if (focusedTemp.length > 0) {
  2197. focusedTemp.focus();
  2198. this.$header.find('.focus-temp').removeClass('focus-temp');
  2199. }
  2200. // fix bug: $.data() is not working as expected after $.append()
  2201. this.$header.find('th[data-field]').each(function (i, el) {
  2202. _this12.$header_.find(Utils.sprintf('th[data-field="%s"]', $(el).data('field'))).data($(el).data());
  2203. });
  2204. var visibleFields = this.getVisibleFields();
  2205. var $ths = this.$header_.find('th');
  2206. this.$body.find('>tr:first-child:not(.no-records-found) > *').each(function (i, el) {
  2207. var $this = $(el);
  2208. var index = i;
  2209. if (_this12.options.detailView && !_this12.options.cardView) {
  2210. if (i === 0) {
  2211. _this12.$header_.find('th.detail').find('.fht-cell').width($this.innerWidth());
  2212. }
  2213. index = i - 1;
  2214. }
  2215. if (index === -1) {
  2216. return;
  2217. }
  2218. var $th = _this12.$header_.find(Utils.sprintf('th[data-field="%s"]', visibleFields[index]));
  2219. if ($th.length > 1) {
  2220. $th = $($ths[$this[0].cellIndex]);
  2221. }
  2222. var zoomWidth = $th.width() - $th.find('.fht-cell').width();
  2223. $th.find('.fht-cell').width($this.innerWidth() - zoomWidth);
  2224. });
  2225. this.horizontalScroll();
  2226. this.trigger('post-header');
  2227. }
  2228. }, {
  2229. key: 'resetFooter',
  2230. value: function resetFooter() {
  2231. var data = this.getData();
  2232. var html = [];
  2233. if (!this.options.showFooter || this.options.cardView) {
  2234. // do nothing
  2235. return;
  2236. }
  2237. if (!this.options.cardView && this.options.detailView) {
  2238. html.push('<td><div class="th-inner">&nbsp;</div><div class="fht-cell"></div></td>');
  2239. }
  2240. var _iteratorNormalCompletion16 = true;
  2241. var _didIteratorError16 = false;
  2242. var _iteratorError16 = undefined;
  2243. try {
  2244. for (var _iterator16 = this.columns[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {
  2245. var column = _step16.value;
  2246. var falign = '';
  2247. var valign = '';
  2248. var csses = [];
  2249. var style = {};
  2250. var class_ = Utils.sprintf(' class="%s"', column['class']);
  2251. if (!column.visible) {
  2252. return;
  2253. }
  2254. if (this.options.cardView && !column.cardVisible) {
  2255. return;
  2256. }
  2257. falign = Utils.sprintf('text-align: %s; ', column.falign ? column.falign : column.align);
  2258. valign = Utils.sprintf('vertical-align: %s; ', column.valign);
  2259. style = Utils.calculateObjectValue(null, this.options.footerStyle);
  2260. if (style && style.css) {
  2261. var _iteratorNormalCompletion17 = true;
  2262. var _didIteratorError17 = false;
  2263. var _iteratorError17 = undefined;
  2264. try {
  2265. for (var _iterator17 = Object.keys(style.css)[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {
  2266. var _ref21 = _step17.value;
  2267. var _ref22 = _slicedToArray(_ref21, 2);
  2268. var key = _ref22[0];
  2269. var value = _ref22[1];
  2270. csses.push(key + ': ' + value);
  2271. }
  2272. } catch (err) {
  2273. _didIteratorError17 = true;
  2274. _iteratorError17 = err;
  2275. } finally {
  2276. try {
  2277. if (!_iteratorNormalCompletion17 && _iterator17.return) {
  2278. _iterator17.return();
  2279. }
  2280. } finally {
  2281. if (_didIteratorError17) {
  2282. throw _iteratorError17;
  2283. }
  2284. }
  2285. }
  2286. }
  2287. html.push('<td', class_, Utils.sprintf(' style="%s"', falign + valign + csses.concat().join('; ')), '>');
  2288. html.push('<div class="th-inner">');
  2289. html.push(Utils.calculateObjectValue(column, column.footerFormatter, [data], '&nbsp;') || '&nbsp;');
  2290. html.push('</div>');
  2291. html.push('<div class="fht-cell"></div>');
  2292. html.push('</div>');
  2293. html.push('</td>');
  2294. }
  2295. } catch (err) {
  2296. _didIteratorError16 = true;
  2297. _iteratorError16 = err;
  2298. } finally {
  2299. try {
  2300. if (!_iteratorNormalCompletion16 && _iterator16.return) {
  2301. _iterator16.return();
  2302. }
  2303. } finally {
  2304. if (_didIteratorError16) {
  2305. throw _iteratorError16;
  2306. }
  2307. }
  2308. }
  2309. this.$tableFooter.find('tr').html(html.join(''));
  2310. this.$tableFooter.show();
  2311. clearTimeout(this.timeoutFooter_);
  2312. this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), this.$el.is(':hidden') ? 100 : 0);
  2313. }
  2314. }, {
  2315. key: 'fitFooter',
  2316. value: function fitFooter() {
  2317. clearTimeout(this.timeoutFooter_);
  2318. if (this.$el.is(':hidden')) {
  2319. this.timeoutFooter_ = setTimeout($.proxy(this.fitFooter, this), 100);
  2320. return;
  2321. }
  2322. var elWidth = this.$el.css('width');
  2323. var scrollWidth = elWidth > this.$tableBody.width() ? Utils.getScrollBarWidth() : 0;
  2324. this.$tableFooter.css({
  2325. 'margin-right': scrollWidth
  2326. }).find('table').css('width', elWidth).attr('class', this.$el.attr('class'));
  2327. var $footerTd = this.$tableFooter.find('td');
  2328. this.$body.find('>tr:first-child:not(.no-records-found) > *').each(function (i, el) {
  2329. var $this = $(el);
  2330. $footerTd.eq(i).find('.fht-cell').width($this.innerWidth());
  2331. });
  2332. this.horizontalScroll();
  2333. }
  2334. }, {
  2335. key: 'horizontalScroll',
  2336. value: function horizontalScroll() {
  2337. var _this13 = this;
  2338. // horizontal scroll event
  2339. // TODO: it's probably better improving the layout than binding to scroll event
  2340. this.trigger('scroll-body');
  2341. this.$tableBody.off('scroll').on('scroll', function (_ref23) {
  2342. var currentTarget = _ref23.currentTarget;
  2343. if (_this13.options.showHeader && _this13.options.height) {
  2344. _this13.$tableHeader.scrollLeft($(currentTarget).scrollLeft());
  2345. }
  2346. if (_this13.options.showFooter && !_this13.options.cardView) {
  2347. _this13.$tableFooter.scrollLeft($(currentTarget).scrollLeft());
  2348. }
  2349. });
  2350. }
  2351. }, {
  2352. key: 'toggleColumn',
  2353. value: function toggleColumn(index, checked, needUpdate) {
  2354. if (index === -1) {
  2355. return;
  2356. }
  2357. this.columns[index].visible = checked;
  2358. this.initHeader();
  2359. this.initSearch();
  2360. this.initPagination();
  2361. this.initBody();
  2362. if (this.options.showColumns) {
  2363. var $items = this.$toolbar.find('.keep-open input').prop('disabled', false);
  2364. if (needUpdate) {
  2365. $items.filter(Utils.sprintf('[value="%s"]', index)).prop('checked', checked);
  2366. }
  2367. if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
  2368. $items.filter(':checked').prop('disabled', true);
  2369. }
  2370. }
  2371. }
  2372. }, {
  2373. key: 'getVisibleFields',
  2374. value: function getVisibleFields() {
  2375. var visibleFields = [];
  2376. var _iteratorNormalCompletion18 = true;
  2377. var _didIteratorError18 = false;
  2378. var _iteratorError18 = undefined;
  2379. try {
  2380. for (var _iterator18 = this.header.fields[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {
  2381. var field = _step18.value;
  2382. var column = this.columns[this.fieldsColumnsIndex[field]];
  2383. if (!column.visible) {
  2384. continue;
  2385. }
  2386. visibleFields.push(field);
  2387. }
  2388. } catch (err) {
  2389. _didIteratorError18 = true;
  2390. _iteratorError18 = err;
  2391. } finally {
  2392. try {
  2393. if (!_iteratorNormalCompletion18 && _iterator18.return) {
  2394. _iterator18.return();
  2395. }
  2396. } finally {
  2397. if (_didIteratorError18) {
  2398. throw _iteratorError18;
  2399. }
  2400. }
  2401. }
  2402. return visibleFields;
  2403. }
  2404. }, {
  2405. key: 'resetView',
  2406. value: function resetView(params) {
  2407. var padding = 0;
  2408. if (params && params.height) {
  2409. this.options.height = params.height;
  2410. }
  2411. this.$selectAll.prop('checked', this.$selectItem.length > 0 && this.$selectItem.length === this.$selectItem.filter(':checked').length);
  2412. if (this.options.height) {
  2413. var toolbarHeight = this.$toolbar.outerHeight(true);
  2414. var paginationHeight = this.$pagination.outerHeight(true);
  2415. var height = this.options.height - toolbarHeight - paginationHeight;
  2416. this.$tableContainer.css('height', height + 'px');
  2417. }
  2418. if (this.options.cardView) {
  2419. // remove the element css
  2420. this.$el.css('margin-top', '0');
  2421. this.$tableContainer.css('padding-bottom', '0');
  2422. this.$tableFooter.hide();
  2423. return;
  2424. }
  2425. if (this.options.showHeader && this.options.height) {
  2426. this.$tableHeader.show();
  2427. this.resetHeader();
  2428. padding += this.$header.outerHeight();
  2429. } else {
  2430. this.$tableHeader.hide();
  2431. this.trigger('post-header');
  2432. }
  2433. if (this.options.showFooter) {
  2434. this.resetFooter();
  2435. if (this.options.height) {
  2436. padding += this.$tableFooter.outerHeight() + 1;
  2437. }
  2438. }
  2439. // Assign the correct sortable arrow
  2440. this.getCaret();
  2441. this.$tableContainer.css('padding-bottom', padding + 'px');
  2442. this.trigger('reset-view');
  2443. }
  2444. }, {
  2445. key: 'getData',
  2446. value: function getData(useCurrentPage) {
  2447. var data = this.options.data;
  2448. if (this.searchText || this.options.sortName || !$.isEmptyObject(this.filterColumns) || !$.isEmptyObject(this.filterColumnsPartial)) {
  2449. data = this.data;
  2450. }
  2451. if (useCurrentPage) {
  2452. return data.slice(this.pageFrom - 1, this.pageTo);
  2453. }
  2454. return data;
  2455. }
  2456. }, {
  2457. key: 'load',
  2458. value: function load(_data) {
  2459. var fixedScroll = false;
  2460. var data = _data;
  2461. // #431: support pagination
  2462. if (this.options.pagination && this.options.sidePagination === 'server') {
  2463. this.options.totalRows = data[this.options.totalField];
  2464. }
  2465. fixedScroll = data.fixedScroll;
  2466. data = Array.isArray(data) ? data : data[this.options.dataField];
  2467. this.initData(data);
  2468. this.initSearch();
  2469. this.initPagination();
  2470. this.initBody(fixedScroll);
  2471. }
  2472. }, {
  2473. key: 'append',
  2474. value: function append(data) {
  2475. this.initData(data, 'append');
  2476. this.initSearch();
  2477. this.initPagination();
  2478. this.initSort();
  2479. this.initBody(true);
  2480. }
  2481. }, {
  2482. key: 'prepend',
  2483. value: function prepend(data) {
  2484. this.initData(data, 'prepend');
  2485. this.initSearch();
  2486. this.initPagination();
  2487. this.initSort();
  2488. this.initBody(true);
  2489. }
  2490. }, {
  2491. key: 'remove',
  2492. value: function remove(params) {
  2493. var len = this.options.data.length;
  2494. var i = void 0;
  2495. var row = void 0;
  2496. if (!params.hasOwnProperty('field') || !params.hasOwnProperty('values')) {
  2497. return;
  2498. }
  2499. for (i = len - 1; i >= 0; i--) {
  2500. row = this.options.data[i];
  2501. if (!row.hasOwnProperty(params.field)) {
  2502. continue;
  2503. }
  2504. if (params.values.includes(row[params.field])) {
  2505. this.options.data.splice(i, 1);
  2506. if (this.options.sidePagination === 'server') {
  2507. this.options.totalRows -= 1;
  2508. }
  2509. }
  2510. }
  2511. if (len === this.options.data.length) {
  2512. return;
  2513. }
  2514. this.initSearch();
  2515. this.initPagination();
  2516. this.initSort();
  2517. this.initBody(true);
  2518. }
  2519. }, {
  2520. key: 'removeAll',
  2521. value: function removeAll() {
  2522. if (this.options.data.length > 0) {
  2523. this.options.data.splice(0, this.options.data.length);
  2524. this.initSearch();
  2525. this.initPagination();
  2526. this.initBody(true);
  2527. }
  2528. }
  2529. }, {
  2530. key: 'getRowByUniqueId',
  2531. value: function getRowByUniqueId(_id) {
  2532. var uniqueId = this.options.uniqueId;
  2533. var len = this.options.data.length;
  2534. var id = _id;
  2535. var dataRow = null;
  2536. var i = void 0;
  2537. var row = void 0;
  2538. var rowUniqueId = void 0;
  2539. for (i = len - 1; i >= 0; i--) {
  2540. row = this.options.data[i];
  2541. if (row.hasOwnProperty(uniqueId)) {
  2542. // uniqueId is a column
  2543. rowUniqueId = row[uniqueId];
  2544. } else if (row._data && row._data.hasOwnProperty(uniqueId)) {
  2545. // uniqueId is a row data property
  2546. rowUniqueId = row._data[uniqueId];
  2547. } else {
  2548. continue;
  2549. }
  2550. if (typeof rowUniqueId === 'string') {
  2551. id = id.toString();
  2552. } else if (typeof rowUniqueId === 'number') {
  2553. if (Number(rowUniqueId) === rowUniqueId && rowUniqueId % 1 === 0) {
  2554. id = parseInt(id);
  2555. } else if (rowUniqueId === Number(rowUniqueId) && rowUniqueId !== 0) {
  2556. id = parseFloat(id);
  2557. }
  2558. }
  2559. if (rowUniqueId === id) {
  2560. dataRow = row;
  2561. break;
  2562. }
  2563. }
  2564. return dataRow;
  2565. }
  2566. }, {
  2567. key: 'removeByUniqueId',
  2568. value: function removeByUniqueId(id) {
  2569. var len = this.options.data.length;
  2570. var row = this.getRowByUniqueId(id);
  2571. if (row) {
  2572. this.options.data.splice(this.options.data.indexOf(row), 1);
  2573. }
  2574. if (len === this.options.data.length) {
  2575. return;
  2576. }
  2577. this.initSearch();
  2578. this.initPagination();
  2579. this.initBody(true);
  2580. }
  2581. }, {
  2582. key: 'updateByUniqueId',
  2583. value: function updateByUniqueId(params) {
  2584. var allParams = Array.isArray(params) ? params : [params];
  2585. var _iteratorNormalCompletion19 = true;
  2586. var _didIteratorError19 = false;
  2587. var _iteratorError19 = undefined;
  2588. try {
  2589. for (var _iterator19 = allParams[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {
  2590. var _params = _step19.value;
  2591. if (!_params.hasOwnProperty('id') || !_params.hasOwnProperty('row')) {
  2592. continue;
  2593. }
  2594. var rowId = this.options.data.indexOf(this.getRowByUniqueId(_params.id));
  2595. if (rowId === -1) {
  2596. continue;
  2597. }
  2598. $.extend(this.options.data[rowId], _params.row);
  2599. }
  2600. } catch (err) {
  2601. _didIteratorError19 = true;
  2602. _iteratorError19 = err;
  2603. } finally {
  2604. try {
  2605. if (!_iteratorNormalCompletion19 && _iterator19.return) {
  2606. _iterator19.return();
  2607. }
  2608. } finally {
  2609. if (_didIteratorError19) {
  2610. throw _iteratorError19;
  2611. }
  2612. }
  2613. }
  2614. this.initSearch();
  2615. this.initPagination();
  2616. this.initSort();
  2617. this.initBody(true);
  2618. }
  2619. }, {
  2620. key: 'refreshColumnTitle',
  2621. value: function refreshColumnTitle(params) {
  2622. if (!params.hasOwnProperty('field') || !params.hasOwnProperty('title')) {
  2623. return;
  2624. }
  2625. this.columns[this.fieldsColumnsIndex[params.field]].title = this.options.escape ? Utils.escapeHTML(params.title) : params.title;
  2626. if (this.columns[this.fieldsColumnsIndex[params.field]].visible) {
  2627. var header = this.options.height !== undefined ? this.$tableHeader : this.$header;
  2628. header.find('th[data-field]').each(function (i, el) {
  2629. if ($(el).data('field') === params.field) {
  2630. $($(el).find('.th-inner')[0]).text(params.title);
  2631. return false;
  2632. }
  2633. });
  2634. }
  2635. }
  2636. }, {
  2637. key: 'insertRow',
  2638. value: function insertRow(params) {
  2639. if (!params.hasOwnProperty('index') || !params.hasOwnProperty('row')) {
  2640. return;
  2641. }
  2642. this.options.data.splice(params.index, 0, params.row);
  2643. this.initSearch();
  2644. this.initPagination();
  2645. this.initSort();
  2646. this.initBody(true);
  2647. }
  2648. }, {
  2649. key: 'updateRow',
  2650. value: function updateRow(params) {
  2651. var allParams = Array.isArray(params) ? params : [params];
  2652. var _iteratorNormalCompletion20 = true;
  2653. var _didIteratorError20 = false;
  2654. var _iteratorError20 = undefined;
  2655. try {
  2656. for (var _iterator20 = allParams[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {
  2657. var _params2 = _step20.value;
  2658. if (!_params2.hasOwnProperty('index') || !_params2.hasOwnProperty('row')) {
  2659. continue;
  2660. }
  2661. $.extend(this.options.data[_params2.index], _params2.row);
  2662. }
  2663. } catch (err) {
  2664. _didIteratorError20 = true;
  2665. _iteratorError20 = err;
  2666. } finally {
  2667. try {
  2668. if (!_iteratorNormalCompletion20 && _iterator20.return) {
  2669. _iterator20.return();
  2670. }
  2671. } finally {
  2672. if (_didIteratorError20) {
  2673. throw _iteratorError20;
  2674. }
  2675. }
  2676. }
  2677. this.initSearch();
  2678. this.initPagination();
  2679. this.initSort();
  2680. this.initBody(true);
  2681. }
  2682. }, {
  2683. key: 'initHiddenRows',
  2684. value: function initHiddenRows() {
  2685. this.hiddenRows = [];
  2686. }
  2687. }, {
  2688. key: 'showRow',
  2689. value: function showRow(params) {
  2690. this.toggleRow(params, true);
  2691. }
  2692. }, {
  2693. key: 'hideRow',
  2694. value: function hideRow(params) {
  2695. this.toggleRow(params, false);
  2696. }
  2697. }, {
  2698. key: 'toggleRow',
  2699. value: function toggleRow(params, visible) {
  2700. var row = void 0;
  2701. if (params.hasOwnProperty('index')) {
  2702. row = this.getData()[params.index];
  2703. } else if (params.hasOwnProperty('uniqueId')) {
  2704. row = this.getRowByUniqueId(params.uniqueId);
  2705. }
  2706. if (!row) {
  2707. return;
  2708. }
  2709. var index = this.hiddenRows.indexOf(row);
  2710. if (!visible && index === -1) {
  2711. this.hiddenRows.push(row);
  2712. } else if (visible && index > -1) {
  2713. this.hiddenRows.splice(index, 1);
  2714. }
  2715. this.initBody(true);
  2716. }
  2717. }, {
  2718. key: 'getHiddenRows',
  2719. value: function getHiddenRows(show) {
  2720. if (show) {
  2721. this.initHiddenRows();
  2722. this.initBody(true);
  2723. return;
  2724. }
  2725. var data = this.getData();
  2726. var rows = [];
  2727. var _iteratorNormalCompletion21 = true;
  2728. var _didIteratorError21 = false;
  2729. var _iteratorError21 = undefined;
  2730. try {
  2731. for (var _iterator21 = data[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {
  2732. var row = _step21.value;
  2733. if (this.hiddenRows.includes(row)) {
  2734. rows.push(row);
  2735. }
  2736. }
  2737. } catch (err) {
  2738. _didIteratorError21 = true;
  2739. _iteratorError21 = err;
  2740. } finally {
  2741. try {
  2742. if (!_iteratorNormalCompletion21 && _iterator21.return) {
  2743. _iterator21.return();
  2744. }
  2745. } finally {
  2746. if (_didIteratorError21) {
  2747. throw _iteratorError21;
  2748. }
  2749. }
  2750. }
  2751. this.hiddenRows = rows;
  2752. return rows;
  2753. }
  2754. }, {
  2755. key: 'mergeCells',
  2756. value: function mergeCells(options) {
  2757. var row = options.index;
  2758. var col = this.getVisibleFields().indexOf(options.field);
  2759. var rowspan = options.rowspan || 1;
  2760. var colspan = options.colspan || 1;
  2761. var i = void 0;
  2762. var j = void 0;
  2763. var $tr = this.$body.find('>tr');
  2764. if (this.options.detailView && !this.options.cardView) {
  2765. col += 1;
  2766. }
  2767. var $td = $tr.eq(row).find('>td').eq(col);
  2768. if (row < 0 || col < 0 || row >= this.data.length) {
  2769. return;
  2770. }
  2771. for (i = row; i < row + rowspan; i++) {
  2772. for (j = col; j < col + colspan; j++) {
  2773. $tr.eq(i).find('>td').eq(j).hide();
  2774. }
  2775. }
  2776. $td.attr('rowspan', rowspan).attr('colspan', colspan).show();
  2777. }
  2778. }, {
  2779. key: 'updateCell',
  2780. value: function updateCell(params) {
  2781. if (!params.hasOwnProperty('index') || !params.hasOwnProperty('field') || !params.hasOwnProperty('value')) {
  2782. return;
  2783. }
  2784. this.data[params.index][params.field] = params.value;
  2785. if (params.reinit === false) {
  2786. return;
  2787. }
  2788. this.initSort();
  2789. this.initBody(true);
  2790. }
  2791. }, {
  2792. key: 'updateCellById',
  2793. value: function updateCellById(params) {
  2794. var _this14 = this;
  2795. if (!params.hasOwnProperty('id') || !params.hasOwnProperty('field') || !params.hasOwnProperty('value')) {
  2796. return;
  2797. }
  2798. var allParams = Array.isArray(params) ? params : [params];
  2799. allParams.forEach(function (_ref24) {
  2800. var id = _ref24.id,
  2801. field = _ref24.field,
  2802. value = _ref24.value;
  2803. var rowId = _this14.options.data.indexOf(_this14.getRowByUniqueId(id));
  2804. if (rowId === -1) {
  2805. return;
  2806. }
  2807. _this14.data[rowId][field] = value;
  2808. });
  2809. if (params.reinit === false) {
  2810. return;
  2811. }
  2812. this.initSort();
  2813. this.initBody(true);
  2814. }
  2815. }, {
  2816. key: 'getOptions',
  2817. value: function getOptions() {
  2818. // Deep copy: remove data
  2819. var options = $.extend({}, this.options);
  2820. delete options.data;
  2821. return $.extend(true, {}, options);
  2822. }
  2823. }, {
  2824. key: 'getSelections',
  2825. value: function getSelections() {
  2826. var _this15 = this;
  2827. // fix #2424: from html with checkbox
  2828. return this.options.data.filter(function (row) {
  2829. return row[_this15.header.stateField] === true;
  2830. });
  2831. }
  2832. }, {
  2833. key: 'getAllSelections',
  2834. value: function getAllSelections() {
  2835. var _this16 = this;
  2836. return this.options.data.filter(function (row) {
  2837. return row[_this16.header.stateField];
  2838. });
  2839. }
  2840. }, {
  2841. key: 'checkAll',
  2842. value: function checkAll() {
  2843. this.checkAll_(true);
  2844. }
  2845. }, {
  2846. key: 'uncheckAll',
  2847. value: function uncheckAll() {
  2848. this.checkAll_(false);
  2849. }
  2850. }, {
  2851. key: 'checkInvert',
  2852. value: function checkInvert() {
  2853. var $items = this.$selectItem.filter(':enabled');
  2854. var checked = $items.filter(':checked');
  2855. $items.each(function (i, el) {
  2856. $(el).prop('checked', !$(el).prop('checked'));
  2857. });
  2858. this.updateRows();
  2859. this.updateSelected();
  2860. this.trigger('uncheck-some', checked);
  2861. checked = this.getSelections();
  2862. this.trigger('check-some', checked);
  2863. }
  2864. }, {
  2865. key: 'checkAll_',
  2866. value: function checkAll_(checked) {
  2867. var rows = void 0;
  2868. if (!checked) {
  2869. rows = this.getSelections();
  2870. }
  2871. this.$selectAll.add(this.$selectAll_).prop('checked', checked);
  2872. this.$selectItem.filter(':enabled').prop('checked', checked);
  2873. this.updateRows();
  2874. if (checked) {
  2875. rows = this.getSelections();
  2876. }
  2877. this.trigger(checked ? 'check-all' : 'uncheck-all', rows);
  2878. }
  2879. }, {
  2880. key: 'check',
  2881. value: function check(index) {
  2882. this.check_(true, index);
  2883. }
  2884. }, {
  2885. key: 'uncheck',
  2886. value: function uncheck(index) {
  2887. this.check_(false, index);
  2888. }
  2889. }, {
  2890. key: 'check_',
  2891. value: function check_(checked, index) {
  2892. var $el = this.$selectItem.filter('[data-index="' + index + '"]');
  2893. var row = this.data[index];
  2894. if ($el.is(':radio') || this.options.singleSelect) {
  2895. var _iteratorNormalCompletion22 = true;
  2896. var _didIteratorError22 = false;
  2897. var _iteratorError22 = undefined;
  2898. try {
  2899. for (var _iterator22 = this.options.data[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
  2900. var r = _step22.value;
  2901. r[this.header.stateField] = false;
  2902. }
  2903. } catch (err) {
  2904. _didIteratorError22 = true;
  2905. _iteratorError22 = err;
  2906. } finally {
  2907. try {
  2908. if (!_iteratorNormalCompletion22 && _iterator22.return) {
  2909. _iterator22.return();
  2910. }
  2911. } finally {
  2912. if (_didIteratorError22) {
  2913. throw _iteratorError22;
  2914. }
  2915. }
  2916. }
  2917. this.$selectItem.filter(':checked').not($el).prop('checked', false);
  2918. }
  2919. row[this.header.stateField] = checked;
  2920. $el.prop('checked', checked);
  2921. this.updateSelected();
  2922. this.trigger(checked ? 'check' : 'uncheck', this.data[index], $el);
  2923. }
  2924. }, {
  2925. key: 'checkBy',
  2926. value: function checkBy(obj) {
  2927. this.checkBy_(true, obj);
  2928. }
  2929. }, {
  2930. key: 'uncheckBy',
  2931. value: function uncheckBy(obj) {
  2932. this.checkBy_(false, obj);
  2933. }
  2934. }, {
  2935. key: 'checkBy_',
  2936. value: function checkBy_(checked, obj) {
  2937. var _this17 = this;
  2938. if (!obj.hasOwnProperty('field') || !obj.hasOwnProperty('values')) {
  2939. return;
  2940. }
  2941. var rows = [];
  2942. this.options.data.forEach(function (row, i) {
  2943. if (!row.hasOwnProperty(obj.field)) {
  2944. return false;
  2945. }
  2946. if (obj.values.includes(row[obj.field])) {
  2947. var $el = _this17.$selectItem.filter(':enabled').filter(Utils.sprintf('[data-index="%s"]', i)).prop('checked', checked);
  2948. row[_this17.header.stateField] = checked;
  2949. rows.push(row);
  2950. _this17.trigger(checked ? 'check' : 'uncheck', row, $el);
  2951. }
  2952. });
  2953. this.updateSelected();
  2954. this.trigger(checked ? 'check-some' : 'uncheck-some', rows);
  2955. }
  2956. }, {
  2957. key: 'destroy',
  2958. value: function destroy() {
  2959. this.$el.insertBefore(this.$container);
  2960. $(this.options.toolbar).insertBefore(this.$el);
  2961. this.$container.next().remove();
  2962. this.$container.remove();
  2963. this.$el.html(this.$el_.html()).css('margin-top', '0').attr('class', this.$el_.attr('class') || ''); // reset the class
  2964. }
  2965. }, {
  2966. key: 'showLoading',
  2967. value: function showLoading() {
  2968. this.$tableLoading.show();
  2969. }
  2970. }, {
  2971. key: 'hideLoading',
  2972. value: function hideLoading() {
  2973. this.$tableLoading.hide();
  2974. }
  2975. }, {
  2976. key: 'togglePagination',
  2977. value: function togglePagination() {
  2978. this.options.pagination = !this.options.pagination;
  2979. var button = this.$toolbar.find('button[name="paginationSwitch"] i');
  2980. if (this.options.pagination) {
  2981. button.attr('class', this.options.iconsPrefix + ' ' + this.options.icons.paginationSwitchDown);
  2982. } else {
  2983. button.attr('class', this.options.iconsPrefix + ' ' + this.options.icons.paginationSwitchUp);
  2984. }
  2985. this.updatePagination();
  2986. }
  2987. }, {
  2988. key: 'toggleFullscreen',
  2989. value: function toggleFullscreen() {
  2990. this.$el.closest('.bootstrap-table').toggleClass('fullscreen');
  2991. }
  2992. }, {
  2993. key: 'refresh',
  2994. value: function refresh(params) {
  2995. if (params && params.url) {
  2996. this.options.url = params.url;
  2997. }
  2998. if (params && params.pageNumber) {
  2999. this.options.pageNumber = params.pageNumber;
  3000. }
  3001. if (params && params.pageSize) {
  3002. this.options.pageSize = params.pageSize;
  3003. }
  3004. this.initServer(params && params.silent, params && params.query, params && params.url);
  3005. this.trigger('refresh', params);
  3006. }
  3007. }, {
  3008. key: 'resetWidth',
  3009. value: function resetWidth() {
  3010. if (this.options.showHeader && this.options.height) {
  3011. this.fitHeader();
  3012. }
  3013. if (this.options.showFooter && !this.options.cardView) {
  3014. this.fitFooter();
  3015. }
  3016. }
  3017. }, {
  3018. key: 'showColumn',
  3019. value: function showColumn(field) {
  3020. this.toggleColumn(this.fieldsColumnsIndex[field], true, true);
  3021. }
  3022. }, {
  3023. key: 'hideColumn',
  3024. value: function hideColumn(field) {
  3025. this.toggleColumn(this.fieldsColumnsIndex[field], false, true);
  3026. }
  3027. }, {
  3028. key: 'getHiddenColumns',
  3029. value: function getHiddenColumns() {
  3030. return this.columns.filter(function (_ref25) {
  3031. var visible = _ref25.visible;
  3032. return !visible;
  3033. });
  3034. }
  3035. }, {
  3036. key: 'getVisibleColumns',
  3037. value: function getVisibleColumns() {
  3038. return this.columns.filter(function (_ref26) {
  3039. var visible = _ref26.visible;
  3040. return visible;
  3041. });
  3042. }
  3043. }, {
  3044. key: 'toggleAllColumns',
  3045. value: function toggleAllColumns(visible) {
  3046. var _iteratorNormalCompletion23 = true;
  3047. var _didIteratorError23 = false;
  3048. var _iteratorError23 = undefined;
  3049. try {
  3050. for (var _iterator23 = this.columns[Symbol.iterator](), _step23; !(_iteratorNormalCompletion23 = (_step23 = _iterator23.next()).done); _iteratorNormalCompletion23 = true) {
  3051. var column = _step23.value;
  3052. column.visible = visible;
  3053. }
  3054. } catch (err) {
  3055. _didIteratorError23 = true;
  3056. _iteratorError23 = err;
  3057. } finally {
  3058. try {
  3059. if (!_iteratorNormalCompletion23 && _iterator23.return) {
  3060. _iterator23.return();
  3061. }
  3062. } finally {
  3063. if (_didIteratorError23) {
  3064. throw _iteratorError23;
  3065. }
  3066. }
  3067. }
  3068. this.initHeader();
  3069. this.initSearch();
  3070. this.initPagination();
  3071. this.initBody();
  3072. if (this.options.showColumns) {
  3073. var $items = this.$toolbar.find('.keep-open input').prop('disabled', false);
  3074. if ($items.filter(':checked').length <= this.options.minimumCountColumns) {
  3075. $items.filter(':checked').prop('disabled', true);
  3076. }
  3077. }
  3078. }
  3079. }, {
  3080. key: 'showAllColumns',
  3081. value: function showAllColumns() {
  3082. this.toggleAllColumns(true);
  3083. }
  3084. }, {
  3085. key: 'hideAllColumns',
  3086. value: function hideAllColumns() {
  3087. this.toggleAllColumns(false);
  3088. }
  3089. }, {
  3090. key: 'filterBy',
  3091. value: function filterBy(columns) {
  3092. this.filterColumns = $.isEmptyObject(columns) ? {} : columns;
  3093. this.options.pageNumber = 1;
  3094. this.initSearch();
  3095. this.updatePagination();
  3096. }
  3097. }, {
  3098. key: 'scrollTo',
  3099. value: function scrollTo(_value) {
  3100. if (typeof _value === 'undefined') {
  3101. return this.$tableBody.scrollTop();
  3102. }
  3103. var value = 0;
  3104. if (typeof _value === 'string' && _value === 'bottom') {
  3105. value = this.$tableBody[0].scrollHeight;
  3106. }
  3107. this.$tableBody.scrollTop(value);
  3108. }
  3109. }, {
  3110. key: 'getScrollPosition',
  3111. value: function getScrollPosition() {
  3112. return this.scrollTo();
  3113. }
  3114. }, {
  3115. key: 'selectPage',
  3116. value: function selectPage(page) {
  3117. if (page > 0 && page <= this.options.totalPages) {
  3118. this.options.pageNumber = page;
  3119. this.updatePagination();
  3120. }
  3121. }
  3122. }, {
  3123. key: 'prevPage',
  3124. value: function prevPage() {
  3125. if (this.options.pageNumber > 1) {
  3126. this.options.pageNumber--;
  3127. this.updatePagination();
  3128. }
  3129. }
  3130. }, {
  3131. key: 'nextPage',
  3132. value: function nextPage() {
  3133. if (this.options.pageNumber < this.options.totalPages) {
  3134. this.options.pageNumber++;
  3135. this.updatePagination();
  3136. }
  3137. }
  3138. }, {
  3139. key: 'toggleView',
  3140. value: function toggleView() {
  3141. this.options.cardView = !this.options.cardView;
  3142. this.initHeader();
  3143. // Fixed remove toolbar when click cardView button.
  3144. // this.initToolbar();
  3145. var $icon = this.$toolbar.find('button[name="toggle"] i');
  3146. if (this.options.cardView) {
  3147. $icon.removeClass(this.options.icons.toggleOff);
  3148. $icon.addClass(this.options.icons.toggleOn);
  3149. } else {
  3150. $icon.removeClass(this.options.icons.toggleOn);
  3151. $icon.addClass(this.options.icons.toggleOff);
  3152. }
  3153. this.initBody();
  3154. this.trigger('toggle', this.options.cardView);
  3155. }
  3156. }, {
  3157. key: 'refreshOptions',
  3158. value: function refreshOptions(options) {
  3159. // If the objects are equivalent then avoid the call of destroy / init methods
  3160. if (Utils.compareObjects(this.options, options, true)) {
  3161. return;
  3162. }
  3163. this.options = $.extend(this.options, options);
  3164. this.trigger('refresh-options', this.options);
  3165. this.destroy();
  3166. this.init();
  3167. }
  3168. }, {
  3169. key: 'resetSearch',
  3170. value: function resetSearch(text) {
  3171. var $search = this.$toolbar.find('.search input');
  3172. $search.val(text || '');
  3173. this.onSearch({ currentTarget: $search });
  3174. }
  3175. }, {
  3176. key: 'expandRow_',
  3177. value: function expandRow_(expand, index) {
  3178. var $tr = this.$body.find(Utils.sprintf('> tr[data-index="%s"]', index));
  3179. if ($tr.next().is('tr.detail-view') === !expand) {
  3180. $tr.find('> td > .detail-icon').click();
  3181. }
  3182. }
  3183. }, {
  3184. key: 'expandRow',
  3185. value: function expandRow(index) {
  3186. this.expandRow_(true, index);
  3187. }
  3188. }, {
  3189. key: 'collapseRow',
  3190. value: function collapseRow(index) {
  3191. this.expandRow_(false, index);
  3192. }
  3193. }, {
  3194. key: 'expandAllRows',
  3195. value: function expandAllRows(isSubTable) {
  3196. var _this18 = this;
  3197. if (isSubTable) {
  3198. var $tr = this.$body.find(Utils.sprintf('> tr[data-index="%s"]', 0));
  3199. var detailIcon = null;
  3200. var executeInterval = false;
  3201. var idInterval = -1;
  3202. if (!$tr.next().is('tr.detail-view')) {
  3203. $tr.find('> td > .detail-icon').click();
  3204. executeInterval = true;
  3205. } else if (!$tr.next().next().is('tr.detail-view')) {
  3206. $tr.next().find('.detail-icon').click();
  3207. executeInterval = true;
  3208. }
  3209. if (executeInterval) {
  3210. try {
  3211. idInterval = setInterval(function () {
  3212. detailIcon = _this18.$body.find('tr.detail-view').last().find('.detail-icon');
  3213. if (detailIcon.length > 0) {
  3214. detailIcon.click();
  3215. } else {
  3216. clearInterval(idInterval);
  3217. }
  3218. }, 1);
  3219. } catch (ex) {
  3220. clearInterval(idInterval);
  3221. }
  3222. }
  3223. } else {
  3224. var trs = this.$body.children();
  3225. for (var i = 0; i < trs.length; i++) {
  3226. this.expandRow_(true, $(trs[i]).data('index'));
  3227. }
  3228. }
  3229. }
  3230. }, {
  3231. key: 'collapseAllRows',
  3232. value: function collapseAllRows(isSubTable) {
  3233. if (isSubTable) {
  3234. this.expandRow_(false, 0);
  3235. } else {
  3236. var trs = this.$body.children();
  3237. for (var i = 0; i < trs.length; i++) {
  3238. this.expandRow_(false, $(trs[i]).data('index'));
  3239. }
  3240. }
  3241. }
  3242. }, {
  3243. key: 'updateFormatText',
  3244. value: function updateFormatText(name, text) {
  3245. if (this.options[Utils.sprintf('format%s', name)]) {
  3246. if (typeof text === 'string') {
  3247. this.options[Utils.sprintf('format%s', name)] = function () {
  3248. return text;
  3249. };
  3250. } else if (typeof text === 'function') {
  3251. this.options[Utils.sprintf('format%s', name)] = text;
  3252. }
  3253. }
  3254. this.initToolbar();
  3255. this.initPagination();
  3256. this.initBody();
  3257. }
  3258. }]);
  3259. return BootstrapTable;
  3260. }();
  3261. BootstrapTable.DEFAULTS = DEFAULTS;
  3262. BootstrapTable.LOCALES = LOCALES;
  3263. BootstrapTable.COLUMN_DEFAULTS = COLUMN_DEFAULTS;
  3264. BootstrapTable.EVENTS = EVENTS;
  3265. // BOOTSTRAP TABLE PLUGIN DEFINITION
  3266. // =======================
  3267. var allowedMethods = ['getOptions', 'getSelections', 'getAllSelections', 'getData', 'load', 'append', 'prepend', 'remove', 'removeAll', 'insertRow', 'updateRow', 'updateCell', 'updateByUniqueId', 'removeByUniqueId', 'getRowByUniqueId', 'showRow', 'hideRow', 'getHiddenRows', 'mergeCells', 'refreshColumnTitle', 'checkAll', 'uncheckAll', 'checkInvert', 'check', 'uncheck', 'checkBy', 'uncheckBy', 'refresh', 'resetView', 'resetWidth', 'destroy', 'showLoading', 'hideLoading', 'showColumn', 'hideColumn', 'getHiddenColumns', 'getVisibleColumns', 'showAllColumns', 'hideAllColumns', 'filterBy', 'scrollTo', 'getScrollPosition', 'selectPage', 'prevPage', 'nextPage', 'togglePagination', 'toggleView', 'refreshOptions', 'resetSearch', 'expandRow', 'collapseRow', 'expandAllRows', 'collapseAllRows', 'updateFormatText', 'updateCellById'];
  3268. $.BootstrapTable = BootstrapTable;
  3269. $.fn.bootstrapTable = function (option) {
  3270. for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key5 = 1; _key5 < _len3; _key5++) {
  3271. args[_key5 - 1] = arguments[_key5];
  3272. }
  3273. var value = void 0;
  3274. this.each(function (i, el) {
  3275. var data = $(el).data('bootstrap.table');
  3276. var options = $.extend({}, BootstrapTable.DEFAULTS, $(el).data(), (typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object' && option);
  3277. if (typeof option === 'string') {
  3278. var _data2;
  3279. if (!allowedMethods.includes(option)) {
  3280. throw new Error('Unknown method: ' + option);
  3281. }
  3282. if (!data) {
  3283. return;
  3284. }
  3285. value = (_data2 = data)[option].apply(_data2, args);
  3286. if (option === 'destroy') {
  3287. $(el).removeData('bootstrap.table');
  3288. }
  3289. }
  3290. if (!data) {
  3291. $(el).data('bootstrap.table', data = new $.BootstrapTable(el, options));
  3292. }
  3293. });
  3294. return typeof value === 'undefined' ? this : value;
  3295. };
  3296. $.fn.bootstrapTable.Constructor = BootstrapTable;
  3297. $.fn.bootstrapTable.defaults = BootstrapTable.DEFAULTS;
  3298. $.fn.bootstrapTable.columnDefaults = BootstrapTable.COLUMN_DEFAULTS;
  3299. $.fn.bootstrapTable.locales = BootstrapTable.LOCALES;
  3300. $.fn.bootstrapTable.methods = allowedMethods;
  3301. $.fn.bootstrapTable.utils = Utils;
  3302. // BOOTSTRAP TABLE INIT
  3303. // =======================
  3304. $(function () {
  3305. $('[data-toggle="table"]').bootstrapTable();
  3306. });
  3307. })(jQuery);
  3308. });