bootstrap-table-multiple-sort.js 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery')) :
  3. typeof define === 'function' && define.amd ? define(['jquery'], factory) :
  4. (global = global || self, factory(global.jQuery));
  5. }(this, function ($) { 'use strict';
  6. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  7. var toString = {}.toString;
  8. var classofRaw = function (it) {
  9. return toString.call(it).slice(8, -1);
  10. };
  11. // `IsArray` abstract operation
  12. // https://tc39.github.io/ecma262/#sec-isarray
  13. var isArray = Array.isArray || function isArray(arg) {
  14. return classofRaw(arg) == 'Array';
  15. };
  16. var isObject = function (it) {
  17. return typeof it === 'object' ? it !== null : typeof it === 'function';
  18. };
  19. // `RequireObjectCoercible` abstract operation
  20. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  21. var requireObjectCoercible = function (it) {
  22. if (it == undefined) throw TypeError("Can't call method on " + it);
  23. return it;
  24. };
  25. // `ToObject` abstract operation
  26. // https://tc39.github.io/ecma262/#sec-toobject
  27. var toObject = function (argument) {
  28. return Object(requireObjectCoercible(argument));
  29. };
  30. var ceil = Math.ceil;
  31. var floor = Math.floor;
  32. // `ToInteger` abstract operation
  33. // https://tc39.github.io/ecma262/#sec-tointeger
  34. var toInteger = function (argument) {
  35. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  36. };
  37. var min = Math.min;
  38. // `ToLength` abstract operation
  39. // https://tc39.github.io/ecma262/#sec-tolength
  40. var toLength = function (argument) {
  41. return argument > 0 ? min(toInteger(argument), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  42. };
  43. // 7.1.1 ToPrimitive(input [, PreferredType])
  44. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  45. // and the second argument - flag - preferred type is a string
  46. var toPrimitive = function (it, S) {
  47. if (!isObject(it)) return it;
  48. var fn, val;
  49. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  50. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  51. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  52. throw TypeError("Can't convert object to primitive value");
  53. };
  54. var fails = function (exec) {
  55. try {
  56. return !!exec();
  57. } catch (e) {
  58. return true;
  59. }
  60. };
  61. // Thank's IE8 for his funny defineProperty
  62. var descriptors = !fails(function () {
  63. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  64. });
  65. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  66. var global = typeof window == 'object' && window && window.Math == Math ? window
  67. : typeof self == 'object' && self && self.Math == Math ? self
  68. // eslint-disable-next-line no-new-func
  69. : Function('return this')();
  70. var document = global.document;
  71. // typeof document.createElement is 'object' in old IE
  72. var exist = isObject(document) && isObject(document.createElement);
  73. var documentCreateElement = function (it) {
  74. return exist ? document.createElement(it) : {};
  75. };
  76. // Thank's IE8 for his funny defineProperty
  77. var ie8DomDefine = !descriptors && !fails(function () {
  78. return Object.defineProperty(documentCreateElement('div'), 'a', {
  79. get: function () { return 7; }
  80. }).a != 7;
  81. });
  82. var anObject = function (it) {
  83. if (!isObject(it)) {
  84. throw TypeError(String(it) + ' is not an object');
  85. } return it;
  86. };
  87. var nativeDefineProperty = Object.defineProperty;
  88. var f = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  89. anObject(O);
  90. P = toPrimitive(P, true);
  91. anObject(Attributes);
  92. if (ie8DomDefine) try {
  93. return nativeDefineProperty(O, P, Attributes);
  94. } catch (e) { /* empty */ }
  95. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  96. if ('value' in Attributes) O[P] = Attributes.value;
  97. return O;
  98. };
  99. var objectDefineProperty = {
  100. f: f
  101. };
  102. var createPropertyDescriptor = function (bitmap, value) {
  103. return {
  104. enumerable: !(bitmap & 1),
  105. configurable: !(bitmap & 2),
  106. writable: !(bitmap & 4),
  107. value: value
  108. };
  109. };
  110. var createProperty = function (object, key, value) {
  111. var propertyKey = toPrimitive(key);
  112. if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
  113. else object[propertyKey] = value;
  114. };
  115. function createCommonjsModule(fn, module) {
  116. return module = { exports: {} }, fn(module, module.exports), module.exports;
  117. }
  118. var hide = descriptors ? function (object, key, value) {
  119. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  120. } : function (object, key, value) {
  121. object[key] = value;
  122. return object;
  123. };
  124. var setGlobal = function (key, value) {
  125. try {
  126. hide(global, key, value);
  127. } catch (e) {
  128. global[key] = value;
  129. } return value;
  130. };
  131. var shared = createCommonjsModule(function (module) {
  132. var SHARED = '__core-js_shared__';
  133. var store = global[SHARED] || setGlobal(SHARED, {});
  134. (module.exports = function (key, value) {
  135. return store[key] || (store[key] = value !== undefined ? value : {});
  136. })('versions', []).push({
  137. version: '3.0.0',
  138. mode: 'global',
  139. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  140. });
  141. });
  142. var id = 0;
  143. var postfix = Math.random();
  144. var uid = function (key) {
  145. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + postfix).toString(36));
  146. };
  147. // Chrome 38 Symbol has incorrect toString conversion
  148. var nativeSymbol = !fails(function () {
  149. });
  150. var store = shared('wks');
  151. var Symbol$1 = global.Symbol;
  152. var wellKnownSymbol = function (name) {
  153. return store[name] || (store[name] = nativeSymbol && Symbol$1[name]
  154. || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
  155. };
  156. var SPECIES = wellKnownSymbol('species');
  157. // `ArraySpeciesCreate` abstract operation
  158. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  159. var arraySpeciesCreate = function (originalArray, length) {
  160. var C;
  161. if (isArray(originalArray)) {
  162. C = originalArray.constructor;
  163. // cross-realm fallback
  164. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  165. else if (isObject(C)) {
  166. C = C[SPECIES];
  167. if (C === null) C = undefined;
  168. }
  169. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  170. };
  171. var SPECIES$1 = wellKnownSymbol('species');
  172. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  173. return !fails(function () {
  174. var array = [];
  175. var constructor = array.constructor = {};
  176. constructor[SPECIES$1] = function () {
  177. return { foo: 1 };
  178. };
  179. return array[METHOD_NAME](Boolean).foo !== 1;
  180. });
  181. };
  182. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  183. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  184. // Nashorn ~ JDK8 bug
  185. var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  186. var f$1 = NASHORN_BUG ? function propertyIsEnumerable(V) {
  187. var descriptor = nativeGetOwnPropertyDescriptor(this, V);
  188. return !!descriptor && descriptor.enumerable;
  189. } : nativePropertyIsEnumerable;
  190. var objectPropertyIsEnumerable = {
  191. f: f$1
  192. };
  193. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  194. var split = ''.split;
  195. var indexedObject = fails(function () {
  196. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  197. // eslint-disable-next-line no-prototype-builtins
  198. return !Object('z').propertyIsEnumerable(0);
  199. }) ? function (it) {
  200. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  201. } : Object;
  202. // toObject with fallback for non-array-like ES3 strings
  203. var toIndexedObject = function (it) {
  204. return indexedObject(requireObjectCoercible(it));
  205. };
  206. var hasOwnProperty = {}.hasOwnProperty;
  207. var has = function (it, key) {
  208. return hasOwnProperty.call(it, key);
  209. };
  210. var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  211. var f$2 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
  212. O = toIndexedObject(O);
  213. P = toPrimitive(P, true);
  214. if (ie8DomDefine) try {
  215. return nativeGetOwnPropertyDescriptor$1(O, P);
  216. } catch (e) { /* empty */ }
  217. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  218. };
  219. var objectGetOwnPropertyDescriptor = {
  220. f: f$2
  221. };
  222. var functionToString = shared('native-function-to-string', Function.toString);
  223. var WeakMap = global.WeakMap;
  224. var nativeWeakMap = typeof WeakMap === 'function' && /native code/.test(functionToString.call(WeakMap));
  225. var shared$1 = shared('keys');
  226. var sharedKey = function (key) {
  227. return shared$1[key] || (shared$1[key] = uid(key));
  228. };
  229. var hiddenKeys = {};
  230. var WeakMap$1 = global.WeakMap;
  231. var set, get, has$1;
  232. var enforce = function (it) {
  233. return has$1(it) ? get(it) : set(it, {});
  234. };
  235. var getterFor = function (TYPE) {
  236. return function (it) {
  237. var state;
  238. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  239. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  240. } return state;
  241. };
  242. };
  243. if (nativeWeakMap) {
  244. var store$1 = new WeakMap$1();
  245. var wmget = store$1.get;
  246. var wmhas = store$1.has;
  247. var wmset = store$1.set;
  248. set = function (it, metadata) {
  249. wmset.call(store$1, it, metadata);
  250. return metadata;
  251. };
  252. get = function (it) {
  253. return wmget.call(store$1, it) || {};
  254. };
  255. has$1 = function (it) {
  256. return wmhas.call(store$1, it);
  257. };
  258. } else {
  259. var STATE = sharedKey('state');
  260. hiddenKeys[STATE] = true;
  261. set = function (it, metadata) {
  262. hide(it, STATE, metadata);
  263. return metadata;
  264. };
  265. get = function (it) {
  266. return has(it, STATE) ? it[STATE] : {};
  267. };
  268. has$1 = function (it) {
  269. return has(it, STATE);
  270. };
  271. }
  272. var internalState = {
  273. set: set,
  274. get: get,
  275. has: has$1,
  276. enforce: enforce,
  277. getterFor: getterFor
  278. };
  279. var redefine = createCommonjsModule(function (module) {
  280. var getInternalState = internalState.get;
  281. var enforceInternalState = internalState.enforce;
  282. var TEMPLATE = String(functionToString).split('toString');
  283. shared('inspectSource', function (it) {
  284. return functionToString.call(it);
  285. });
  286. (module.exports = function (O, key, value, options) {
  287. var unsafe = options ? !!options.unsafe : false;
  288. var simple = options ? !!options.enumerable : false;
  289. var noTargetGet = options ? !!options.noTargetGet : false;
  290. if (typeof value == 'function') {
  291. if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
  292. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  293. }
  294. if (O === global) {
  295. if (simple) O[key] = value;
  296. else setGlobal(key, value);
  297. return;
  298. } else if (!unsafe) {
  299. delete O[key];
  300. } else if (!noTargetGet && O[key]) {
  301. simple = true;
  302. }
  303. if (simple) O[key] = value;
  304. else hide(O, key, value);
  305. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  306. })(Function.prototype, 'toString', function toString() {
  307. return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
  308. });
  309. });
  310. var max = Math.max;
  311. var min$1 = Math.min;
  312. // Helper for a popular repeating case of the spec:
  313. // Let integer be ? ToInteger(index).
  314. // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
  315. var toAbsoluteIndex = function (index, length) {
  316. var integer = toInteger(index);
  317. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  318. };
  319. // `Array.prototype.{ indexOf, includes }` methods implementation
  320. // false -> Array#indexOf
  321. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  322. // true -> Array#includes
  323. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  324. var arrayIncludes = function (IS_INCLUDES) {
  325. return function ($this, el, fromIndex) {
  326. var O = toIndexedObject($this);
  327. var length = toLength(O.length);
  328. var index = toAbsoluteIndex(fromIndex, length);
  329. var value;
  330. // Array#includes uses SameValueZero equality algorithm
  331. // eslint-disable-next-line no-self-compare
  332. if (IS_INCLUDES && el != el) while (length > index) {
  333. value = O[index++];
  334. // eslint-disable-next-line no-self-compare
  335. if (value != value) return true;
  336. // Array#indexOf ignores holes, Array#includes - not
  337. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  338. if (O[index] === el) return IS_INCLUDES || index || 0;
  339. } return !IS_INCLUDES && -1;
  340. };
  341. };
  342. var arrayIndexOf = arrayIncludes(false);
  343. var objectKeysInternal = function (object, names) {
  344. var O = toIndexedObject(object);
  345. var i = 0;
  346. var result = [];
  347. var key;
  348. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  349. // Don't enum bug & hidden keys
  350. while (names.length > i) if (has(O, key = names[i++])) {
  351. ~arrayIndexOf(result, key) || result.push(key);
  352. }
  353. return result;
  354. };
  355. // IE8- don't enum bug keys
  356. var enumBugKeys = [
  357. 'constructor',
  358. 'hasOwnProperty',
  359. 'isPrototypeOf',
  360. 'propertyIsEnumerable',
  361. 'toLocaleString',
  362. 'toString',
  363. 'valueOf'
  364. ];
  365. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  366. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  367. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  368. return objectKeysInternal(O, hiddenKeys$1);
  369. };
  370. var objectGetOwnPropertyNames = {
  371. f: f$3
  372. };
  373. var f$4 = Object.getOwnPropertySymbols;
  374. var objectGetOwnPropertySymbols = {
  375. f: f$4
  376. };
  377. var Reflect = global.Reflect;
  378. // all object keys, includes non-enumerable and symbols
  379. var ownKeys = Reflect && Reflect.ownKeys || function ownKeys(it) {
  380. var keys = objectGetOwnPropertyNames.f(anObject(it));
  381. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  382. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  383. };
  384. var copyConstructorProperties = function (target, source) {
  385. var keys = ownKeys(source);
  386. var defineProperty = objectDefineProperty.f;
  387. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  388. for (var i = 0; i < keys.length; i++) {
  389. var key = keys[i];
  390. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  391. }
  392. };
  393. var replacement = /#|\.prototype\./;
  394. var isForced = function (feature, detection) {
  395. var value = data[normalize(feature)];
  396. return value == POLYFILL ? true
  397. : value == NATIVE ? false
  398. : typeof detection == 'function' ? fails(detection)
  399. : !!detection;
  400. };
  401. var normalize = isForced.normalize = function (string) {
  402. return String(string).replace(replacement, '.').toLowerCase();
  403. };
  404. var data = isForced.data = {};
  405. var NATIVE = isForced.NATIVE = 'N';
  406. var POLYFILL = isForced.POLYFILL = 'P';
  407. var isForced_1 = isForced;
  408. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  409. /*
  410. options.target - name of the target object
  411. options.global - target is the global object
  412. options.stat - export as static methods of target
  413. options.proto - export as prototype methods of target
  414. options.real - real prototype method for the `pure` version
  415. options.forced - export even if the native feature is available
  416. options.bind - bind methods to the target, required for the `pure` version
  417. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  418. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  419. options.sham - add a flag to not completely full polyfills
  420. options.enumerable - export as enumerable property
  421. options.noTargetGet - prevent calling a getter on target
  422. */
  423. var _export = function (options, source) {
  424. var TARGET = options.target;
  425. var GLOBAL = options.global;
  426. var STATIC = options.stat;
  427. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  428. if (GLOBAL) {
  429. target = global;
  430. } else if (STATIC) {
  431. target = global[TARGET] || setGlobal(TARGET, {});
  432. } else {
  433. target = (global[TARGET] || {}).prototype;
  434. }
  435. if (target) for (key in source) {
  436. sourceProperty = source[key];
  437. if (options.noTargetGet) {
  438. descriptor = getOwnPropertyDescriptor(target, key);
  439. targetProperty = descriptor && descriptor.value;
  440. } else targetProperty = target[key];
  441. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  442. // contained in target
  443. if (!FORCED && targetProperty !== undefined) {
  444. if (typeof sourceProperty === typeof targetProperty) continue;
  445. copyConstructorProperties(sourceProperty, targetProperty);
  446. }
  447. // add a flag to not completely full polyfills
  448. if (options.sham || (targetProperty && targetProperty.sham)) {
  449. hide(sourceProperty, 'sham', true);
  450. }
  451. // extend global
  452. redefine(target, key, sourceProperty, options);
  453. }
  454. };
  455. var IS_CONCAT_SPREADABLE = wellKnownSymbol('isConcatSpreadable');
  456. var MAX_SAFE_INTEGER = 0x1fffffffffffff;
  457. var MAXIMUM_ALLOWED_INDEX_EXCEEDED = 'Maximum allowed index exceeded';
  458. var IS_CONCAT_SPREADABLE_SUPPORT = !fails(function () {
  459. var array = [];
  460. array[IS_CONCAT_SPREADABLE] = false;
  461. return array.concat()[0] !== array;
  462. });
  463. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('concat');
  464. var isConcatSpreadable = function (O) {
  465. if (!isObject(O)) return false;
  466. var spreadable = O[IS_CONCAT_SPREADABLE];
  467. return spreadable !== undefined ? !!spreadable : isArray(O);
  468. };
  469. var FORCED = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT;
  470. // `Array.prototype.concat` method
  471. // https://tc39.github.io/ecma262/#sec-array.prototype.concat
  472. // with adding support of @@isConcatSpreadable and @@species
  473. _export({ target: 'Array', proto: true, forced: FORCED }, {
  474. concat: function concat(arg) { // eslint-disable-line no-unused-vars
  475. var O = toObject(this);
  476. var A = arraySpeciesCreate(O, 0);
  477. var n = 0;
  478. var i, k, length, len, E;
  479. for (i = -1, length = arguments.length; i < length; i++) {
  480. E = i === -1 ? O : arguments[i];
  481. if (isConcatSpreadable(E)) {
  482. len = toLength(E.length);
  483. if (n + len > MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  484. for (k = 0; k < len; k++, n++) if (k in E) createProperty(A, n, E[k]);
  485. } else {
  486. if (n >= MAX_SAFE_INTEGER) throw TypeError(MAXIMUM_ALLOWED_INDEX_EXCEEDED);
  487. createProperty(A, n++, E);
  488. }
  489. }
  490. A.length = n;
  491. return A;
  492. }
  493. });
  494. var aFunction = function (it) {
  495. if (typeof it != 'function') {
  496. throw TypeError(String(it) + ' is not a function');
  497. } return it;
  498. };
  499. // optional / simple context binding
  500. var bindContext = function (fn, that, length) {
  501. aFunction(fn);
  502. if (that === undefined) return fn;
  503. switch (length) {
  504. case 0: return function () {
  505. return fn.call(that);
  506. };
  507. case 1: return function (a) {
  508. return fn.call(that, a);
  509. };
  510. case 2: return function (a, b) {
  511. return fn.call(that, a, b);
  512. };
  513. case 3: return function (a, b, c) {
  514. return fn.call(that, a, b, c);
  515. };
  516. }
  517. return function (/* ...args */) {
  518. return fn.apply(that, arguments);
  519. };
  520. };
  521. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  522. // 0 -> Array#forEach
  523. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  524. // 1 -> Array#map
  525. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  526. // 2 -> Array#filter
  527. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  528. // 3 -> Array#some
  529. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  530. // 4 -> Array#every
  531. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  532. // 5 -> Array#find
  533. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  534. // 6 -> Array#findIndex
  535. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  536. var arrayMethods = function (TYPE, specificCreate) {
  537. var IS_MAP = TYPE == 1;
  538. var IS_FILTER = TYPE == 2;
  539. var IS_SOME = TYPE == 3;
  540. var IS_EVERY = TYPE == 4;
  541. var IS_FIND_INDEX = TYPE == 6;
  542. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  543. var create = specificCreate || arraySpeciesCreate;
  544. return function ($this, callbackfn, that) {
  545. var O = toObject($this);
  546. var self = indexedObject(O);
  547. var boundFunction = bindContext(callbackfn, that, 3);
  548. var length = toLength(self.length);
  549. var index = 0;
  550. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  551. var value, result;
  552. for (;length > index; index++) if (NO_HOLES || index in self) {
  553. value = self[index];
  554. result = boundFunction(value, index, O);
  555. if (TYPE) {
  556. if (IS_MAP) target[index] = result; // map
  557. else if (result) switch (TYPE) {
  558. case 3: return true; // some
  559. case 5: return value; // find
  560. case 6: return index; // findIndex
  561. case 2: target.push(value); // filter
  562. } else if (IS_EVERY) return false; // every
  563. }
  564. }
  565. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  566. };
  567. };
  568. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  569. var objectKeys = Object.keys || function keys(O) {
  570. return objectKeysInternal(O, enumBugKeys);
  571. };
  572. var objectDefineProperties = descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
  573. anObject(O);
  574. var keys = objectKeys(Properties);
  575. var length = keys.length;
  576. var i = 0;
  577. var key;
  578. while (length > i) objectDefineProperty.f(O, key = keys[i++], Properties[key]);
  579. return O;
  580. };
  581. var document$1 = global.document;
  582. var html = document$1 && document$1.documentElement;
  583. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  584. var IE_PROTO = sharedKey('IE_PROTO');
  585. var PROTOTYPE = 'prototype';
  586. var Empty = function () { /* empty */ };
  587. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  588. var createDict = function () {
  589. // Thrash, waste and sodomy: IE GC bug
  590. var iframe = documentCreateElement('iframe');
  591. var length = enumBugKeys.length;
  592. var lt = '<';
  593. var script = 'script';
  594. var gt = '>';
  595. var js = 'java' + script + ':';
  596. var iframeDocument;
  597. iframe.style.display = 'none';
  598. html.appendChild(iframe);
  599. iframe.src = String(js);
  600. iframeDocument = iframe.contentWindow.document;
  601. iframeDocument.open();
  602. iframeDocument.write(lt + script + gt + 'document.F=Object' + lt + '/' + script + gt);
  603. iframeDocument.close();
  604. createDict = iframeDocument.F;
  605. while (length--) delete createDict[PROTOTYPE][enumBugKeys[length]];
  606. return createDict();
  607. };
  608. var objectCreate = Object.create || function create(O, Properties) {
  609. var result;
  610. if (O !== null) {
  611. Empty[PROTOTYPE] = anObject(O);
  612. result = new Empty();
  613. Empty[PROTOTYPE] = null;
  614. // add "__proto__" for Object.getPrototypeOf polyfill
  615. result[IE_PROTO] = O;
  616. } else result = createDict();
  617. return Properties === undefined ? result : objectDefineProperties(result, Properties);
  618. };
  619. hiddenKeys[IE_PROTO] = true;
  620. var UNSCOPABLES = wellKnownSymbol('unscopables');
  621. var ArrayPrototype = Array.prototype;
  622. // Array.prototype[@@unscopables]
  623. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  624. if (ArrayPrototype[UNSCOPABLES] == undefined) {
  625. hide(ArrayPrototype, UNSCOPABLES, objectCreate(null));
  626. }
  627. // add a key to Array.prototype[@@unscopables]
  628. var addToUnscopables = function (key) {
  629. ArrayPrototype[UNSCOPABLES][key] = true;
  630. };
  631. var internalFind = arrayMethods(5);
  632. var FIND = 'find';
  633. var SKIPS_HOLES = true;
  634. // Shouldn't skip holes
  635. if (FIND in []) Array(1)[FIND](function () { SKIPS_HOLES = false; });
  636. // `Array.prototype.find` method
  637. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  638. _export({ target: 'Array', proto: true, forced: SKIPS_HOLES }, {
  639. find: function find(callbackfn /* , that = undefined */) {
  640. return internalFind(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  641. }
  642. });
  643. // https://tc39.github.io/ecma262/#sec-array.prototype-@@unscopables
  644. addToUnscopables(FIND);
  645. var sloppyArrayMethod = function (METHOD_NAME, argument) {
  646. var method = [][METHOD_NAME];
  647. return !method || !fails(function () {
  648. // eslint-disable-next-line no-useless-call
  649. method.call(null, argument || function () { throw Error(); }, 1);
  650. });
  651. };
  652. var nativeJoin = [].join;
  653. var ES3_STRINGS = indexedObject != Object;
  654. var SLOPPY_METHOD = sloppyArrayMethod('join', ',');
  655. // `Array.prototype.join` method
  656. // https://tc39.github.io/ecma262/#sec-array.prototype.join
  657. _export({ target: 'Array', proto: true, forced: ES3_STRINGS || SLOPPY_METHOD }, {
  658. join: function join(separator) {
  659. return nativeJoin.call(toIndexedObject(this), separator === undefined ? ',' : separator);
  660. }
  661. });
  662. var internalMap = arrayMethods(1);
  663. var SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport('map');
  664. // `Array.prototype.map` method
  665. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  666. // with adding support of @@species
  667. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$1 }, {
  668. map: function map(callbackfn /* , thisArg */) {
  669. return internalMap(this, callbackfn, arguments[1]);
  670. }
  671. });
  672. var SPECIES$2 = wellKnownSymbol('species');
  673. var nativeSlice = [].slice;
  674. var max$1 = Math.max;
  675. var SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport('slice');
  676. // `Array.prototype.slice` method
  677. // https://tc39.github.io/ecma262/#sec-array.prototype.slice
  678. // fallback for not array-like ES3 strings and DOM objects
  679. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$2 }, {
  680. slice: function slice(start, end) {
  681. var O = toIndexedObject(this);
  682. var length = toLength(O.length);
  683. var k = toAbsoluteIndex(start, length);
  684. var fin = toAbsoluteIndex(end === undefined ? length : end, length);
  685. // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
  686. var Constructor, result, n;
  687. if (isArray(O)) {
  688. Constructor = O.constructor;
  689. // cross-realm fallback
  690. if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
  691. Constructor = undefined;
  692. } else if (isObject(Constructor)) {
  693. Constructor = Constructor[SPECIES$2];
  694. if (Constructor === null) Constructor = undefined;
  695. }
  696. if (Constructor === Array || Constructor === undefined) {
  697. return nativeSlice.call(O, k, fin);
  698. }
  699. }
  700. result = new (Constructor === undefined ? Array : Constructor)(max$1(fin - k, 0));
  701. for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
  702. result.length = n;
  703. return result;
  704. }
  705. });
  706. var nativeSort = [].sort;
  707. var test = [1, 2, 3];
  708. // IE8-
  709. var FAILS_ON_UNDEFINED = fails(function () {
  710. test.sort(undefined);
  711. });
  712. // V8 bug
  713. var FAILS_ON_NULL = fails(function () {
  714. test.sort(null);
  715. });
  716. // Old WebKit
  717. var SLOPPY_METHOD$1 = sloppyArrayMethod('sort');
  718. var FORCED$1 = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || SLOPPY_METHOD$1;
  719. // `Array.prototype.sort` method
  720. // https://tc39.github.io/ecma262/#sec-array.prototype.sort
  721. _export({ target: 'Array', proto: true, forced: FORCED$1 }, {
  722. sort: function sort(comparefn) {
  723. return comparefn === undefined
  724. ? nativeSort.call(toObject(this))
  725. : nativeSort.call(toObject(this), aFunction(comparefn));
  726. }
  727. });
  728. var max$2 = Math.max;
  729. var min$2 = Math.min;
  730. var MAX_SAFE_INTEGER$1 = 0x1fffffffffffff;
  731. var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';
  732. var SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport('splice');
  733. // `Array.prototype.splice` method
  734. // https://tc39.github.io/ecma262/#sec-array.prototype.splice
  735. // with adding support of @@species
  736. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT$3 }, {
  737. splice: function splice(start, deleteCount /* , ...items */) {
  738. var O = toObject(this);
  739. var len = toLength(O.length);
  740. var actualStart = toAbsoluteIndex(start, len);
  741. var argumentsLength = arguments.length;
  742. var insertCount, actualDeleteCount, A, k, from, to;
  743. if (argumentsLength === 0) {
  744. insertCount = actualDeleteCount = 0;
  745. } else if (argumentsLength === 1) {
  746. insertCount = 0;
  747. actualDeleteCount = len - actualStart;
  748. } else {
  749. insertCount = argumentsLength - 2;
  750. actualDeleteCount = min$2(max$2(toInteger(deleteCount), 0), len - actualStart);
  751. }
  752. if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER$1) {
  753. throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
  754. }
  755. A = arraySpeciesCreate(O, actualDeleteCount);
  756. for (k = 0; k < actualDeleteCount; k++) {
  757. from = actualStart + k;
  758. if (from in O) createProperty(A, k, O[from]);
  759. }
  760. A.length = actualDeleteCount;
  761. if (insertCount < actualDeleteCount) {
  762. for (k = actualStart; k < len - actualDeleteCount; k++) {
  763. from = k + actualDeleteCount;
  764. to = k + insertCount;
  765. if (from in O) O[to] = O[from];
  766. else delete O[to];
  767. }
  768. for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
  769. } else if (insertCount > actualDeleteCount) {
  770. for (k = len - actualDeleteCount; k > actualStart; k--) {
  771. from = k + actualDeleteCount - 1;
  772. to = k + insertCount - 1;
  773. if (from in O) O[to] = O[from];
  774. else delete O[to];
  775. }
  776. }
  777. for (k = 0; k < insertCount; k++) {
  778. O[k + actualStart] = arguments[k + 2];
  779. }
  780. O.length = len - actualDeleteCount + insertCount;
  781. return A;
  782. }
  783. });
  784. var TO_STRING_TAG = wellKnownSymbol('toStringTag');
  785. // ES3 wrong here
  786. var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
  787. // fallback for IE11 Script Access Denied error
  788. var tryGet = function (it, key) {
  789. try {
  790. return it[key];
  791. } catch (e) { /* empty */ }
  792. };
  793. // getting tag from ES6+ `Object.prototype.toString`
  794. var classof = function (it) {
  795. var O, tag, result;
  796. return it === undefined ? 'Undefined' : it === null ? 'Null'
  797. // @@toStringTag case
  798. : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
  799. // builtinTag case
  800. : CORRECT_ARGUMENTS ? classofRaw(O)
  801. // ES3 arguments fallback
  802. : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
  803. };
  804. var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
  805. var test$1 = {};
  806. test$1[TO_STRING_TAG$1] = 'z';
  807. // `Object.prototype.toString` method implementation
  808. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  809. var objectToString = String(test$1) !== '[object z]' ? function toString() {
  810. return '[object ' + classof(this) + ']';
  811. } : test$1.toString;
  812. var ObjectPrototype = Object.prototype;
  813. // `Object.prototype.toString` method
  814. // https://tc39.github.io/ecma262/#sec-object.prototype.tostring
  815. if (objectToString !== ObjectPrototype.toString) {
  816. redefine(ObjectPrototype, 'toString', objectToString, { unsafe: true });
  817. }
  818. // a string of all valid unicode whitespaces
  819. // eslint-disable-next-line max-len
  820. var whitespaces = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  821. var whitespace = '[' + whitespaces + ']';
  822. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  823. var rtrim = RegExp(whitespace + whitespace + '*$');
  824. // 1 -> String#trimStart
  825. // 2 -> String#trimEnd
  826. // 3 -> String#trim
  827. var stringTrim = function (string, TYPE) {
  828. string = String(requireObjectCoercible(string));
  829. if (TYPE & 1) string = string.replace(ltrim, '');
  830. if (TYPE & 2) string = string.replace(rtrim, '');
  831. return string;
  832. };
  833. var nativeParseFloat = global.parseFloat;
  834. var FORCED$2 = 1 / nativeParseFloat(whitespaces + '-0') !== -Infinity;
  835. var _parseFloat = FORCED$2 ? function parseFloat(str) {
  836. var string = stringTrim(String(str), 3);
  837. var result = nativeParseFloat(string);
  838. return result === 0 && string.charAt(0) == '-' ? -0 : result;
  839. } : nativeParseFloat;
  840. // `parseFloat` method
  841. // https://tc39.github.io/ecma262/#sec-parsefloat-string
  842. _export({ global: true, forced: parseFloat != _parseFloat }, {
  843. parseFloat: _parseFloat
  844. });
  845. // `RegExp.prototype.flags` getter implementation
  846. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  847. var regexpFlags = function () {
  848. var that = anObject(this);
  849. var result = '';
  850. if (that.global) result += 'g';
  851. if (that.ignoreCase) result += 'i';
  852. if (that.multiline) result += 'm';
  853. if (that.unicode) result += 'u';
  854. if (that.sticky) result += 'y';
  855. return result;
  856. };
  857. var TO_STRING = 'toString';
  858. var nativeToString = /./[TO_STRING];
  859. var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) != '/a/b'; });
  860. // FF44- RegExp#toString has a wrong name
  861. var INCORRECT_NAME = nativeToString.name != TO_STRING;
  862. // `RegExp.prototype.toString` method
  863. // https://tc39.github.io/ecma262/#sec-regexp.prototype.tostring
  864. if (NOT_GENERIC || INCORRECT_NAME) {
  865. redefine(RegExp.prototype, TO_STRING, function toString() {
  866. var R = anObject(this);
  867. return '/'.concat(R.source, '/',
  868. 'flags' in R ? R.flags : !descriptors && R instanceof RegExp ? regexpFlags.call(R) : undefined);
  869. }, { unsafe: true });
  870. }
  871. var MATCH = wellKnownSymbol('match');
  872. // `IsRegExp` abstract operation
  873. // https://tc39.github.io/ecma262/#sec-isregexp
  874. var isRegexp = function (it) {
  875. var isRegExp;
  876. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classofRaw(it) == 'RegExp');
  877. };
  878. var SPECIES$3 = wellKnownSymbol('species');
  879. // `SpeciesConstructor` abstract operation
  880. // https://tc39.github.io/ecma262/#sec-speciesconstructor
  881. var speciesConstructor = function (O, defaultConstructor) {
  882. var C = anObject(O).constructor;
  883. var S;
  884. return C === undefined || (S = anObject(C)[SPECIES$3]) == undefined ? defaultConstructor : aFunction(S);
  885. };
  886. // CONVERT_TO_STRING: true -> String#at
  887. // CONVERT_TO_STRING: false -> String#codePointAt
  888. var stringAt = function (that, pos, CONVERT_TO_STRING) {
  889. var S = String(requireObjectCoercible(that));
  890. var position = toInteger(pos);
  891. var size = S.length;
  892. var first, second;
  893. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  894. first = S.charCodeAt(position);
  895. return first < 0xd800 || first > 0xdbff || position + 1 === size
  896. || (second = S.charCodeAt(position + 1)) < 0xdc00 || second > 0xdfff
  897. ? CONVERT_TO_STRING ? S.charAt(position) : first
  898. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xd800 << 10) + (second - 0xdc00) + 0x10000;
  899. };
  900. // `AdvanceStringIndex` abstract operation
  901. // https://tc39.github.io/ecma262/#sec-advancestringindex
  902. var advanceStringIndex = function (S, index, unicode) {
  903. return index + (unicode ? stringAt(S, index, true).length : 1);
  904. };
  905. var nativeExec = RegExp.prototype.exec;
  906. // This always refers to the native implementation, because the
  907. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  908. // which loads this file before patching the method.
  909. var nativeReplace = String.prototype.replace;
  910. var patchedExec = nativeExec;
  911. var UPDATES_LAST_INDEX_WRONG = (function () {
  912. var re1 = /a/;
  913. var re2 = /b*/g;
  914. nativeExec.call(re1, 'a');
  915. nativeExec.call(re2, 'a');
  916. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  917. })();
  918. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  919. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  920. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
  921. if (PATCH) {
  922. patchedExec = function exec(str) {
  923. var re = this;
  924. var lastIndex, reCopy, match, i;
  925. if (NPCG_INCLUDED) {
  926. reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
  927. }
  928. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  929. match = nativeExec.call(re, str);
  930. if (UPDATES_LAST_INDEX_WRONG && match) {
  931. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  932. }
  933. if (NPCG_INCLUDED && match && match.length > 1) {
  934. // Fix browsers whose `exec` methods don't consistently return `undefined`
  935. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  936. nativeReplace.call(match[0], reCopy, function () {
  937. for (i = 1; i < arguments.length - 2; i++) {
  938. if (arguments[i] === undefined) match[i] = undefined;
  939. }
  940. });
  941. }
  942. return match;
  943. };
  944. }
  945. var regexpExec = patchedExec;
  946. // `RegExpExec` abstract operation
  947. // https://tc39.github.io/ecma262/#sec-regexpexec
  948. var regexpExecAbstract = function (R, S) {
  949. var exec = R.exec;
  950. if (typeof exec === 'function') {
  951. var result = exec.call(R, S);
  952. if (typeof result !== 'object') {
  953. throw TypeError('RegExp exec method returned something other than an Object or null');
  954. }
  955. return result;
  956. }
  957. if (classofRaw(R) !== 'RegExp') {
  958. throw TypeError('RegExp#exec called on incompatible receiver');
  959. }
  960. return regexpExec.call(R, S);
  961. };
  962. var SPECIES$4 = wellKnownSymbol('species');
  963. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  964. // #replace needs built-in support for named groups.
  965. // #match works fine because it just return the exec results, even if it has
  966. // a "grops" property.
  967. var re = /./;
  968. re.exec = function () {
  969. var result = [];
  970. result.groups = { a: '7' };
  971. return result;
  972. };
  973. return ''.replace(re, '$<a>') !== '7';
  974. });
  975. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  976. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  977. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  978. var re = /(?:)/;
  979. var originalExec = re.exec;
  980. re.exec = function () { return originalExec.apply(this, arguments); };
  981. var result = 'ab'.split(re);
  982. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  983. });
  984. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  985. var SYMBOL = wellKnownSymbol(KEY);
  986. var DELEGATES_TO_SYMBOL = !fails(function () {
  987. // String methods call symbol-named RegEp methods
  988. var O = {};
  989. O[SYMBOL] = function () { return 7; };
  990. return ''[KEY](O) != 7;
  991. });
  992. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  993. // Symbol-named RegExp methods call .exec
  994. var execCalled = false;
  995. var re = /a/;
  996. re.exec = function () { execCalled = true; return null; };
  997. if (KEY === 'split') {
  998. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  999. // a new one. We need to return the patched regex when creating the new one.
  1000. re.constructor = {};
  1001. re.constructor[SPECIES$4] = function () { return re; };
  1002. }
  1003. re[SYMBOL]('');
  1004. return !execCalled;
  1005. });
  1006. if (
  1007. !DELEGATES_TO_SYMBOL ||
  1008. !DELEGATES_TO_EXEC ||
  1009. (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
  1010. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  1011. ) {
  1012. var nativeRegExpMethod = /./[SYMBOL];
  1013. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  1014. if (regexp.exec === regexpExec) {
  1015. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  1016. // The native String method already delegates to @@method (this
  1017. // polyfilled function), leasing to infinite recursion.
  1018. // We avoid it by directly calling the native @@method method.
  1019. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  1020. }
  1021. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  1022. }
  1023. return { done: false };
  1024. });
  1025. var stringMethod = methods[0];
  1026. var regexMethod = methods[1];
  1027. redefine(String.prototype, KEY, stringMethod);
  1028. redefine(RegExp.prototype, SYMBOL, length == 2
  1029. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  1030. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  1031. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  1032. // 21.2.5.6 RegExp.prototype[@@match](string)
  1033. // 21.2.5.9 RegExp.prototype[@@search](string)
  1034. : function (string) { return regexMethod.call(string, this); }
  1035. );
  1036. if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
  1037. }
  1038. };
  1039. var arrayPush = [].push;
  1040. var min$3 = Math.min;
  1041. var MAX_UINT32 = 0xffffffff;
  1042. // babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
  1043. var SUPPORTS_Y = !fails(function () { return !RegExp(MAX_UINT32, 'y'); });
  1044. // @@split logic
  1045. fixRegexpWellKnownSymbolLogic(
  1046. 'split',
  1047. 2,
  1048. function (SPLIT, nativeSplit, maybeCallNative) {
  1049. var internalSplit;
  1050. if (
  1051. 'abbc'.split(/(b)*/)[1] == 'c' ||
  1052. 'test'.split(/(?:)/, -1).length != 4 ||
  1053. 'ab'.split(/(?:ab)*/).length != 2 ||
  1054. '.'.split(/(.?)(.?)/).length != 4 ||
  1055. '.'.split(/()()/).length > 1 ||
  1056. ''.split(/.?/).length
  1057. ) {
  1058. // based on es5-shim implementation, need to rework it
  1059. internalSplit = function (separator, limit) {
  1060. var string = String(requireObjectCoercible(this));
  1061. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1062. if (lim === 0) return [];
  1063. if (separator === undefined) return [string];
  1064. // If `separator` is not a regex, use native split
  1065. if (!isRegexp(separator)) {
  1066. return nativeSplit.call(string, separator, lim);
  1067. }
  1068. var output = [];
  1069. var flags = (separator.ignoreCase ? 'i' : '') +
  1070. (separator.multiline ? 'm' : '') +
  1071. (separator.unicode ? 'u' : '') +
  1072. (separator.sticky ? 'y' : '');
  1073. var lastLastIndex = 0;
  1074. // Make `global` and avoid `lastIndex` issues by working with a copy
  1075. var separatorCopy = new RegExp(separator.source, flags + 'g');
  1076. var match, lastIndex, lastLength;
  1077. while (match = regexpExec.call(separatorCopy, string)) {
  1078. lastIndex = separatorCopy.lastIndex;
  1079. if (lastIndex > lastLastIndex) {
  1080. output.push(string.slice(lastLastIndex, match.index));
  1081. if (match.length > 1 && match.index < string.length) arrayPush.apply(output, match.slice(1));
  1082. lastLength = match[0].length;
  1083. lastLastIndex = lastIndex;
  1084. if (output.length >= lim) break;
  1085. }
  1086. if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
  1087. }
  1088. if (lastLastIndex === string.length) {
  1089. if (lastLength || !separatorCopy.test('')) output.push('');
  1090. } else output.push(string.slice(lastLastIndex));
  1091. return output.length > lim ? output.slice(0, lim) : output;
  1092. };
  1093. // Chakra, V8
  1094. } else if ('0'.split(undefined, 0).length) {
  1095. internalSplit = function (separator, limit) {
  1096. return separator === undefined && limit === 0 ? [] : nativeSplit.call(this, separator, limit);
  1097. };
  1098. } else internalSplit = nativeSplit;
  1099. return [
  1100. // `String.prototype.split` method
  1101. // https://tc39.github.io/ecma262/#sec-string.prototype.split
  1102. function split(separator, limit) {
  1103. var O = requireObjectCoercible(this);
  1104. var splitter = separator == undefined ? undefined : separator[SPLIT];
  1105. return splitter !== undefined
  1106. ? splitter.call(separator, O, limit)
  1107. : internalSplit.call(String(O), separator, limit);
  1108. },
  1109. // `RegExp.prototype[@@split]` method
  1110. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
  1111. //
  1112. // NOTE: This cannot be properly polyfilled in engines that don't support
  1113. // the 'y' flag.
  1114. function (regexp, limit) {
  1115. var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== nativeSplit);
  1116. if (res.done) return res.value;
  1117. var rx = anObject(regexp);
  1118. var S = String(this);
  1119. var C = speciesConstructor(rx, RegExp);
  1120. var unicodeMatching = rx.unicode;
  1121. var flags = (rx.ignoreCase ? 'i' : '') +
  1122. (rx.multiline ? 'm' : '') +
  1123. (rx.unicode ? 'u' : '') +
  1124. (SUPPORTS_Y ? 'y' : 'g');
  1125. // ^(? + rx + ) is needed, in combination with some S slicing, to
  1126. // simulate the 'y' flag.
  1127. var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
  1128. var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
  1129. if (lim === 0) return [];
  1130. if (S.length === 0) return regexpExecAbstract(splitter, S) === null ? [S] : [];
  1131. var p = 0;
  1132. var q = 0;
  1133. var A = [];
  1134. while (q < S.length) {
  1135. splitter.lastIndex = SUPPORTS_Y ? q : 0;
  1136. var z = regexpExecAbstract(splitter, SUPPORTS_Y ? S : S.slice(q));
  1137. var e;
  1138. if (
  1139. z === null ||
  1140. (e = min$3(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
  1141. ) {
  1142. q = advanceStringIndex(S, q, unicodeMatching);
  1143. } else {
  1144. A.push(S.slice(p, q));
  1145. if (A.length === lim) return A;
  1146. for (var i = 1; i <= z.length - 1; i++) {
  1147. A.push(z[i]);
  1148. if (A.length === lim) return A;
  1149. }
  1150. q = p = e;
  1151. }
  1152. }
  1153. A.push(S.slice(p));
  1154. return A;
  1155. }
  1156. ];
  1157. },
  1158. !SUPPORTS_Y
  1159. );
  1160. function _typeof(obj) {
  1161. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  1162. _typeof = function (obj) {
  1163. return typeof obj;
  1164. };
  1165. } else {
  1166. _typeof = function (obj) {
  1167. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  1168. };
  1169. }
  1170. return _typeof(obj);
  1171. }
  1172. /**
  1173. * @author Nadim Basalamah <dimbslmh@gmail.com>
  1174. * @version: v1.1.0
  1175. * https://github.com/dimbslmh/bootstrap-table/tree/master/src/extensions/multiple-sort/bootstrap-table-multiple-sort.js
  1176. * Modification: ErwannNevou <https://github.com/ErwannNevou>
  1177. */
  1178. var isSingleSort = false;
  1179. var Utils = $.fn.bootstrapTable.utils;
  1180. var bootstrap = {
  1181. bootstrap3: {
  1182. icons: {
  1183. plus: 'glyphicon-plus',
  1184. minus: 'glyphicon-minus',
  1185. sort: 'glyphicon-sort'
  1186. },
  1187. html: {
  1188. multipleSortModal: "\n <div class=\"modal fade\" id=\"%s\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"%sLabel\" aria-hidden=\"true\">\n <div class=\"modal-dialog\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\n <h4 class=\"modal-title\" id=\"%sLabel\">%s</h4>\n </div>\n <div class=\"modal-body\">\n <div class=\"bootstrap-table\">\n <div class=\"fixed-table-toolbar\">\n <div class=\"bars\">\n <div id=\"toolbar\">\n <button id=\"add\" type=\"button\" class=\"btn btn-default\">%s %s</button>\n <button id=\"delete\" type=\"button\" class=\"btn btn-default\" disabled>%s %s</button>\n </div>\n </div>\n </div>\n <div class=\"fixed-table-container\">\n <table id=\"multi-sort\" class=\"table\">\n <thead>\n <tr>\n <th></th>\n <th><div class=\"th-inner\">%s</div></th>\n <th><div class=\"th-inner\">%s</div></th>\n </tr>\n </thead>\n <tbody></tbody>\n </table>\n </div>\n </div>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">%s</button>\n <button type=\"button\" class=\"btn btn-primary multi-sort-order-button\">%s</button>\n </div>\n </div>\n </div>\n </div>\n ",
  1189. multipleSortButton: '<button class="multi-sort btn btn-default" type="button" data-toggle="modal" data-target="#%s" title="%s">%s</button>',
  1190. multipleSortSelect: '<select class="%s %s form-control">'
  1191. }
  1192. },
  1193. bootstrap4: {
  1194. icons: {
  1195. 'plus': 'fa-plus',
  1196. 'minus': 'fa-minus',
  1197. 'sort': 'fa-sort'
  1198. },
  1199. html: {
  1200. multipleSortModal: "\n <div class=\"modal fade\" id=\"%s\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"%sLabel\" aria-hidden=\"true\">\n <div class=\"modal-dialog\" role=\"document\">\n <div class=\"modal-content\">\n <div class=\"modal-header\">\n <h5 class=\"modal-title\" id=\"%sLabel\">%s</h5>\n <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">\n <span aria-hidden=\"true\">&times;</span>\n </button>\n </div>\n <div class=\"modal-body\">\n <div class=\"bootstrap-table\">\n <div class=\"fixed-table-toolbar\">\n <div class=\"bars\">\n <div id=\"toolbar\" class=\"pb-3\">\n <button id=\"add\" type=\"button\" class=\"btn btn-secondary\">%s %s</button>\n <button id=\"delete\" type=\"button\" class=\"btn btn-secondary\" disabled>%s %s</button>\n </div>\n </div>\n </div>\n <div class=\"fixed-table-container\">\n <table id=\"multi-sort\" class=\"table\">\n <thead>\n <tr>\n <th></th>\n <th><div class=\"th-inner\">%s</div></th>\n <th><div class=\"th-inner\">%s</div></th>\n </tr>\n </thead>\n <tbody></tbody>\n </table>\n </div>\n </div>\n </div>\n <div class=\"modal-footer\">\n <button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">%s</button>\n <button type=\"button\" class=\"btn btn-primary multi-sort-order-button\">%s</button>\n </div>\n </div>\n </div>\n </div>\n ",
  1201. multipleSortButton: '<button class="multi-sort btn btn-secondary" type="button" data-toggle="modal" data-target="#%s" title="%s">%s</button>',
  1202. multipleSortSelect: '<select class="%s %s form-control">'
  1203. }
  1204. },
  1205. semantic: {
  1206. icons: {
  1207. 'plus': 'fa-plus',
  1208. 'minus': 'fa-minus',
  1209. 'sort': 'fa-sort'
  1210. },
  1211. html: {
  1212. multipleSortModal: "\n <div class=\"ui modal tiny\" id=\"%s\" aria-labelledby=\"%sLabel\" aria-hidden=\"true\">\n <i class=\"close icon\"></i>\n <div class=\"header\" id=\"%sLabel\">\n %s\n </div>\n <div class=\"image content\">\n <div class=\"bootstrap-table\">\n <div class=\"fixed-table-toolbar\">\n <div class=\"bars\">\n <div id=\"toolbar\" class=\"pb-3\">\n <button id=\"add\" type=\"button\" class=\"ui button\">%s %s</button>\n <button id=\"delete\" type=\"button\" class=\"ui button\" disabled>%s %s</button>\n </div>\n </div>\n </div>\n <div class=\"fixed-table-container\">\n <table id=\"multi-sort\" class=\"table\">\n <thead>\n <tr>\n <th></th>\n <th><div class=\"th-inner\">%s</div></th>\n <th><div class=\"th-inner\">%s</div></th>\n </tr>\n </thead>\n <tbody></tbody>\n </table>\n </div>\n </div>\n </div>\n <div class=\"actions\">\n <div class=\"ui button deny\">%s</div>\n <div class=\"ui button approve multi-sort-order-button\">%s</div>\n </div>\n </div>\n ",
  1213. multipleSortButton: '<button class="multi-sort ui button" type="button" data-toggle="modal" data-target="#%s" title="%s">%s</button>',
  1214. multipleSortSelect: '<select class="%s %s">'
  1215. }
  1216. },
  1217. materialize: {
  1218. icons: {
  1219. 'plus': 'plus',
  1220. 'minus': 'minus',
  1221. 'sort': 'sort'
  1222. },
  1223. html: {
  1224. multipleSortModal: "\n <div id=\"%s\" class=\"modal\" aria-labelledby=\"%sLabel\" aria-hidden=\"true\">\n <div class=\"modal-content\" id=\"%sLabel\">\n <h4>%s</h4>\n <div class=\"bootstrap-table\">\n <div class=\"fixed-table-toolbar\">\n <div class=\"bars\">\n <div id=\"toolbar\" class=\"pb-3\">\n <button id=\"add\" type=\"button\" class=\"waves-effect waves-light btn\">%s %s</button>\n <button id=\"delete\" type=\"button\" class=\"waves-effect waves-light btn\" disabled>%s %s</button>\n </div>\n </div>\n </div>\n <div class=\"fixed-table-container\">\n <table id=\"multi-sort\" class=\"table\">\n <thead>\n <tr>\n <th></th>\n <th><div class=\"th-inner\">%s</div></th>\n <th><div class=\"th-inner\">%s</div></th>\n </tr>\n </thead>\n <tbody></tbody>\n </table>\n </div>\n </div>\n <div class=\"modal-footer\">\n <a href=\"javascript:void(0)\" class=\"modal-close waves-effect waves-light btn\">%s</a>\n <a href=\"javascript:void(0)\" class=\"modal-close waves-effect waves-light btn multi-sort-order-button\">%s</a>\n </div>\n </div>\n </div>\n ",
  1225. multipleSortButton: '<a href="#%s" class="multi-sort waves-effect waves-light btn modal-trigger" type="button" data-toggle="modal" title="%s">%s</a>',
  1226. multipleSortSelect: '<select class="%s %s browser-default">'
  1227. }
  1228. },
  1229. foundation: {
  1230. icons: {
  1231. 'plus': 'fa-plus',
  1232. 'minus': 'fa-minus',
  1233. 'sort': 'fa-sort'
  1234. },
  1235. html: {
  1236. multipleSortModal: "\n <div class=\"reveal\" id=\"%s\" data-reveal aria-labelledby=\"%sLabel\" aria-hidden=\"true\">\n <div id=\"%sLabel\">\n <h1>%s</h1>\n <div class=\"bootstrap-table\">\n <div class=\"fixed-table-toolbar\">\n <div class=\"bars\">\n <div id=\"toolbar\" class=\"padding-bottom-2\">\n <button id=\"add\" type=\"button\" class=\"waves-effect waves-light button\">%s %s</button>\n <button id=\"delete\" type=\"button\" class=\"waves-effect waves-light button\" disabled>%s %s</button>\n </div>\n </div>\n </div>\n <div class=\"fixed-table-container\">\n <table id=\"multi-sort\" class=\"table\">\n <thead>\n <tr>\n <th></th>\n <th><div class=\"th-inner\">%s</div></th>\n <th><div class=\"th-inner\">%s</div></th>\n </tr>\n </thead>\n <tbody></tbody>\n </table>\n </div>\n </div>\n \n <button class=\"waves-effect waves-light button\" data-close aria-label=\"Close modal\" type=\"button\">\n <span aria-hidden=\"true\">%s</span>\n </button>\n <button class=\"waves-effect waves-light button multi-sort-order-button\" data-close aria-label=\"Order\" type=\"button\">\n <span aria-hidden=\"true\">%s</span>\n </button>\n </div>\n </div>\n ",
  1237. multipleSortButton: '<button class="button multi-sort" data-open="%s" title="%s">%s</button>',
  1238. multipleSortSelect: '<select class="%s %s browser-default">'
  1239. }
  1240. },
  1241. bulma: {
  1242. icons: {
  1243. 'plus': 'fa-plus',
  1244. 'minus': 'fa-minus',
  1245. 'sort': 'fa-sort'
  1246. },
  1247. html: {
  1248. multipleSortModal: "\n <div class=\"modal\" id=\"%s\" aria-labelledby=\"%sLabel\" aria-hidden=\"true\">\n <div class=\"modal-background\"></div>\n <div class=\"modal-content\" id=\"%sLabel\">\n <div class=\"box\">\n <h2>%s</h2>\n <div class=\"bootstrap-table\">\n <div class=\"fixed-table-toolbar\">\n <div class=\"bars\">\n <div id=\"toolbar\" class=\"padding-bottom-2\">\n <button id=\"add\" type=\"button\" class=\"waves-effect waves-light button\">%s %s</button>\n <button id=\"delete\" type=\"button\" class=\"waves-effect waves-light button\" disabled>%s %s</button>\n </div>\n </div>\n </div>\n <div class=\"fixed-table-container\">\n <table id=\"multi-sort\" class=\"table\">\n <thead>\n <tr>\n <th></th>\n <th><div class=\"th-inner\">%s</div></th>\n <th><div class=\"th-inner\">%s</div></th>\n </tr>\n </thead>\n <tbody></tbody>\n </table>\n </div>\n </div>\n <button type=\"button\" class=\"waves-effect waves-light button\" data-close>%s</button>\n <button type=\"button\" class=\"waves-effect waves-light button multi-sort-order-button\" data-close>%s</button>\n </div>\n </div>\n </div>\n ",
  1249. multipleSortButton: '<button class="button multi-sort" data-target="%s" title="%s">%s</button>',
  1250. multipleSortSelect: '<select class="%s %s browser-default">'
  1251. }
  1252. }
  1253. }[$.fn.bootstrapTable.theme];
  1254. $.extend($.fn.bootstrapTable.defaults.icons, bootstrap.icons);
  1255. $.extend($.fn.bootstrapTable.defaults.html, bootstrap.html);
  1256. var showSortModal = function showSortModal(that) {
  1257. var _selector = that.sortModalSelector;
  1258. var _id = "#".concat(_selector);
  1259. var o = that.options;
  1260. if (!$(_id).hasClass('modal')) {
  1261. var sModal = Utils.sprintf(that.constants.html.multipleSortModal, _selector, _selector, _selector, that.options.formatMultipleSort(), Utils.sprintf(that.constants.html.icon, o.iconsPrefix, that.constants.icons.plus), that.options.formatAddLevel(), Utils.sprintf(that.constants.html.icon, o.iconsPrefix, that.constants.icons.minus), that.options.formatDeleteLevel(), that.options.formatColumn(), that.options.formatOrder(), that.options.formatCancel(), that.options.formatSort());
  1262. $('body').append($(sModal));
  1263. that.$sortModal = $(_id);
  1264. var $rows = that.$sortModal.find('tbody > tr');
  1265. that.$sortModal.off('click', '#add').on('click', '#add', function () {
  1266. var total = that.$sortModal.find('.multi-sort-name:first option').length;
  1267. var current = that.$sortModal.find('tbody tr').length;
  1268. if (current < total) {
  1269. current++;
  1270. that.addLevel();
  1271. that.setButtonStates();
  1272. }
  1273. });
  1274. that.$sortModal.off('click', '#delete').on('click', '#delete', function () {
  1275. var total = that.$sortModal.find('.multi-sort-name:first option').length;
  1276. var current = that.$sortModal.find('tbody tr').length;
  1277. if (current > 1 && current <= total) {
  1278. current--;
  1279. that.$sortModal.find('tbody tr:last').remove();
  1280. that.setButtonStates();
  1281. }
  1282. });
  1283. that.$sortModal.off('click', '.multi-sort-order-button').on('click', '.multi-sort-order-button', function () {
  1284. var $rows = that.$sortModal.find('tbody > tr');
  1285. var $alert = that.$sortModal.find('div.alert');
  1286. var fields = [];
  1287. var results = [];
  1288. that.options.sortPriority = $.map($rows, function (row) {
  1289. var $row = $(row);
  1290. var name = $row.find('.multi-sort-name').val();
  1291. var order = $row.find('.multi-sort-order').val();
  1292. fields.push(name);
  1293. return {
  1294. sortName: name,
  1295. sortOrder: order
  1296. };
  1297. });
  1298. var sorted_fields = fields.sort();
  1299. for (var i = 0; i < fields.length - 1; i++) {
  1300. if (sorted_fields[i + 1] === sorted_fields[i]) {
  1301. results.push(sorted_fields[i]);
  1302. }
  1303. }
  1304. if (results.length > 0) {
  1305. if ($alert.length === 0) {
  1306. $alert = "<div class=\"alert alert-danger\" role=\"alert\"><strong>".concat(that.options.formatDuplicateAlertTitle(), "</strong> ").concat(that.options.formatDuplicateAlertDescription(), "</div>");
  1307. $($alert).insertBefore(that.$sortModal.find('.bars'));
  1308. }
  1309. } else {
  1310. if ($alert.length === 1) {
  1311. $($alert).remove();
  1312. }
  1313. if ($.inArray($.fn.bootstrapTable.theme, ['bootstrap3', 'bootstrap4']) !== -1) {
  1314. that.$sortModal.modal('hide');
  1315. }
  1316. that.options.sortName = '';
  1317. if (that.options.sidePagination === 'server') {
  1318. var t = that.options.queryParams;
  1319. that.options.queryParams = function (params) {
  1320. params.multiSort = that.options.sortPriority;
  1321. return $.fn.bootstrapTable.utils.calculateObjectValue(that.options, t, [params]);
  1322. };
  1323. isSingleSort = false;
  1324. that.initServer(that.options.silentSort);
  1325. return;
  1326. }
  1327. that.onMultipleSort();
  1328. }
  1329. });
  1330. if (that.options.sortPriority === null || that.options.sortPriority.length === 0) {
  1331. if (that.options.sortName) {
  1332. that.options.sortPriority = [{
  1333. sortName: that.options.sortName,
  1334. sortOrder: that.options.sortOrder
  1335. }];
  1336. }
  1337. }
  1338. if (that.options.sortPriority !== null && that.options.sortPriority.length > 0) {
  1339. if ($rows.length < that.options.sortPriority.length && _typeof(that.options.sortPriority) === 'object') {
  1340. for (var i = 0; i < that.options.sortPriority.length; i++) {
  1341. that.addLevel(i, that.options.sortPriority[i]);
  1342. }
  1343. }
  1344. } else {
  1345. that.addLevel(0);
  1346. }
  1347. that.setButtonStates();
  1348. }
  1349. };
  1350. $.fn.bootstrapTable.methods.push('multipleSort');
  1351. $.extend($.fn.bootstrapTable.defaults, {
  1352. showMultiSort: false,
  1353. showMultiSortButton: true,
  1354. sortPriority: null,
  1355. onMultipleSort: function onMultipleSort() {
  1356. return false;
  1357. }
  1358. });
  1359. $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
  1360. 'multiple-sort.bs.table': 'onMultipleSort'
  1361. });
  1362. $.extend($.fn.bootstrapTable.locales, {
  1363. formatMultipleSort: function formatMultipleSort() {
  1364. return 'Multiple Sort';
  1365. },
  1366. formatAddLevel: function formatAddLevel() {
  1367. return 'Add Level';
  1368. },
  1369. formatDeleteLevel: function formatDeleteLevel() {
  1370. return 'Delete Level';
  1371. },
  1372. formatColumn: function formatColumn() {
  1373. return 'Column';
  1374. },
  1375. formatOrder: function formatOrder() {
  1376. return 'Order';
  1377. },
  1378. formatSortBy: function formatSortBy() {
  1379. return 'Sort by';
  1380. },
  1381. formatThenBy: function formatThenBy() {
  1382. return 'Then by';
  1383. },
  1384. formatSort: function formatSort() {
  1385. return 'Sort';
  1386. },
  1387. formatCancel: function formatCancel() {
  1388. return 'Cancel';
  1389. },
  1390. formatDuplicateAlertTitle: function formatDuplicateAlertTitle() {
  1391. return 'Duplicate(s) detected!';
  1392. },
  1393. formatDuplicateAlertDescription: function formatDuplicateAlertDescription() {
  1394. return 'Please remove or change any duplicate column.';
  1395. },
  1396. formatSortOrders: function formatSortOrders() {
  1397. return {
  1398. asc: 'Ascending',
  1399. desc: 'Descending'
  1400. };
  1401. }
  1402. });
  1403. $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
  1404. var BootstrapTable = $.fn.bootstrapTable.Constructor;
  1405. var _initToolbar = BootstrapTable.prototype.initToolbar;
  1406. BootstrapTable.prototype.initToolbar = function () {
  1407. var _this = this;
  1408. this.showToolbar = this.showToolbar || this.options.showMultiSort;
  1409. var that = this;
  1410. var sortModalSelector = "sortModal_".concat(this.$el.attr('id'));
  1411. var sortModalId = "#".concat(sortModalSelector);
  1412. this.$sortModal = $(sortModalId);
  1413. this.sortModalSelector = sortModalSelector;
  1414. if (that.options.sortPriority !== null) {
  1415. that.onMultipleSort();
  1416. }
  1417. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1418. args[_key] = arguments[_key];
  1419. }
  1420. _initToolbar.apply(this, Array.prototype.slice.apply(args));
  1421. if (that.options.sidePagination === 'server' && !isSingleSort && that.options.sortPriority !== null) {
  1422. var t = that.options.queryParams;
  1423. that.options.queryParams = function (params) {
  1424. params.multiSort = that.options.sortPriority;
  1425. return t(params);
  1426. };
  1427. }
  1428. if (this.options.showMultiSort) {
  1429. var $btnGroup = this.$toolbar.find('>.' + that.constants.classes.buttonsGroup.split(' ').join('.')).first();
  1430. var $multiSortBtn = this.$toolbar.find('div.multi-sort');
  1431. var o = that.options;
  1432. if (!$multiSortBtn.length && this.options.showMultiSortButton) {
  1433. $multiSortBtn = Utils.sprintf(that.constants.html.multipleSortButton, that.sortModalSelector, this.options.formatMultipleSort(), Utils.sprintf(that.constants.html.icon, o.iconsPrefix, o.icons.sort));
  1434. $btnGroup.append($multiSortBtn);
  1435. if ($.fn.bootstrapTable.theme === 'semantic') {
  1436. this.$toolbar.find('.multi-sort').on('click', function () {
  1437. $(sortModalId).modal('show');
  1438. });
  1439. } else if ($.fn.bootstrapTable.theme === 'materialize') {
  1440. this.$toolbar.find('.multi-sort').on('click', function () {
  1441. $(sortModalId).modal();
  1442. });
  1443. } else if ($.fn.bootstrapTable.theme === 'foundation') {
  1444. this.$toolbar.find('.multi-sort').on('click', function () {
  1445. if (!_this.foundationModal) {
  1446. // eslint-disable-next-line no-undef
  1447. _this.foundationModal = new Foundation.Reveal($(sortModalId));
  1448. }
  1449. _this.foundationModal.open();
  1450. });
  1451. } else if ($.fn.bootstrapTable.theme === 'bulma') {
  1452. this.$toolbar.find('.multi-sort').on('click', function () {
  1453. $('html').toggleClass('is-clipped');
  1454. $(sortModalId).toggleClass('is-active');
  1455. $('button[data-close]').one('click', function () {
  1456. $('html').toggleClass('is-clipped');
  1457. $(sortModalId).toggleClass('is-active');
  1458. });
  1459. });
  1460. }
  1461. showSortModal(that);
  1462. }
  1463. this.$el.on('sort.bs.table', function () {
  1464. isSingleSort = true;
  1465. });
  1466. this.$el.on('multiple-sort.bs.table', function () {
  1467. isSingleSort = false;
  1468. });
  1469. this.$el.on('load-success.bs.table', function () {
  1470. if (!isSingleSort && that.options.sortPriority !== null && _typeof(that.options.sortPriority) === 'object' && that.options.sidePagination !== 'server') {
  1471. that.onMultipleSort();
  1472. }
  1473. });
  1474. this.$el.on('column-switch.bs.table', function (field, checked) {
  1475. for (var i = 0; i < that.options.sortPriority.length; i++) {
  1476. if (that.options.sortPriority[i].sortName === checked) {
  1477. that.options.sortPriority.splice(i, 1);
  1478. }
  1479. }
  1480. that.assignSortableArrows();
  1481. that.$sortModal.remove();
  1482. showSortModal(that);
  1483. });
  1484. this.$el.on('reset-view.bs.table', function () {
  1485. if (!isSingleSort && that.options.sortPriority !== null && _typeof(that.options.sortPriority) === 'object') {
  1486. that.assignSortableArrows();
  1487. }
  1488. });
  1489. }
  1490. };
  1491. BootstrapTable.prototype.multipleSort = function () {
  1492. var that = this;
  1493. if (!isSingleSort && that.options.sortPriority !== null && _typeof(that.options.sortPriority) === 'object' && that.options.sidePagination !== 'server') {
  1494. that.onMultipleSort();
  1495. }
  1496. };
  1497. BootstrapTable.prototype.onMultipleSort = function () {
  1498. var that = this;
  1499. var cmp = function cmp(x, y) {
  1500. return x > y ? 1 : x < y ? -1 : 0;
  1501. };
  1502. var arrayCmp = function arrayCmp(a, b) {
  1503. var arr1 = [];
  1504. var arr2 = [];
  1505. for (var i = 0; i < that.options.sortPriority.length; i++) {
  1506. var order = that.options.sortPriority[i].sortOrder === 'desc' ? -1 : 1;
  1507. var aa = a[that.options.sortPriority[i].sortName];
  1508. var bb = b[that.options.sortPriority[i].sortName];
  1509. if (aa === undefined || aa === null) {
  1510. aa = '';
  1511. }
  1512. if (bb === undefined || bb === null) {
  1513. bb = '';
  1514. }
  1515. if ($.isNumeric(aa) && $.isNumeric(bb)) {
  1516. aa = parseFloat(aa);
  1517. bb = parseFloat(bb);
  1518. }
  1519. if (typeof aa !== 'string') {
  1520. aa = aa.toString();
  1521. }
  1522. arr1.push(order * cmp(aa, bb));
  1523. arr2.push(order * cmp(bb, aa));
  1524. }
  1525. return cmp(arr1, arr2);
  1526. };
  1527. this.data.sort(function (a, b) {
  1528. return arrayCmp(a, b);
  1529. });
  1530. this.initBody();
  1531. this.assignSortableArrows();
  1532. this.trigger('multiple-sort');
  1533. };
  1534. BootstrapTable.prototype.addLevel = function (index, sortPriority) {
  1535. var text = index === 0 ? this.options.formatSortBy() : this.options.formatThenBy();
  1536. this.$sortModal.find('tbody').append($('<tr>').append($('<td>').text(text)).append($('<td>').append($(Utils.sprintf(this.constants.html.multipleSortSelect, this.constants.classes.paginationDropdown, 'multi-sort-name')))).append($('<td>').append($(Utils.sprintf(this.constants.html.multipleSortSelect, this.constants.classes.paginationDropdown, 'multi-sort-order')))));
  1537. var $multiSortName = this.$sortModal.find('.multi-sort-name').last();
  1538. var $multiSortOrder = this.$sortModal.find('.multi-sort-order').last();
  1539. $.each(this.columns, function (i, column) {
  1540. if (column.sortable === false || column.visible === false) {
  1541. return true;
  1542. }
  1543. $multiSortName.append("<option value=\"".concat(column.field, "\">").concat(column.title, "</option>"));
  1544. });
  1545. $.each(this.options.formatSortOrders(), function (value, order) {
  1546. $multiSortOrder.append("<option value=\"".concat(value, "\">").concat(order, "</option>"));
  1547. });
  1548. if (sortPriority !== undefined) {
  1549. $multiSortName.find("option[value=\"".concat(sortPriority.sortName, "\"]")).attr('selected', true);
  1550. $multiSortOrder.find("option[value=\"".concat(sortPriority.sortOrder, "\"]")).attr('selected', true);
  1551. }
  1552. };
  1553. BootstrapTable.prototype.assignSortableArrows = function () {
  1554. var that = this;
  1555. var headers = that.$header.find('th');
  1556. for (var i = 0; i < headers.length; i++) {
  1557. for (var c = 0; c < that.options.sortPriority.length; c++) {
  1558. if ($(headers[i]).data('field') === that.options.sortPriority[c].sortName) {
  1559. $(headers[i]).find('.sortable').removeClass('desc asc').addClass(that.options.sortPriority[c].sortOrder);
  1560. }
  1561. }
  1562. }
  1563. };
  1564. BootstrapTable.prototype.setButtonStates = function () {
  1565. var total = this.$sortModal.find('.multi-sort-name:first option').length;
  1566. var current = this.$sortModal.find('tbody tr').length;
  1567. if (current === total) {
  1568. this.$sortModal.find('#add').attr('disabled', 'disabled');
  1569. }
  1570. if (current > 1) {
  1571. this.$sortModal.find('#delete').removeAttr('disabled');
  1572. }
  1573. if (current < total) {
  1574. this.$sortModal.find('#add').removeAttr('disabled');
  1575. }
  1576. if (current === 1) {
  1577. this.$sortModal.find('#delete').attr('disabled', 'disabled');
  1578. }
  1579. };
  1580. }));