@lmjs/core 2.1.24 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ws.js CHANGED
@@ -992,16 +992,12 @@ function syncViewFiles() {
992
992
  } else if (nodes[0] == n) {
993
993
  renderView(nodes[0], null, View.props ?? {});
994
994
  } else {
995
- // 2026-09-22: force=true — this really is
996
- // the subview's own file content changing
997
- // (deepCompare already confirmed that,
998
- // above), so it must bypass renderView()'s
999
- // new "already mounted, skip" gate (added
1000
- // to stop updateVXRs() from rebuilding
1001
- // every subview on every unrelated render
1002
- // pass) or a hot-reloaded subview file
1003
- // would never actually refresh.
1004
- renderView(n, true, {}, 'views', undefined, undefined, true);
995
+ // A subview can be nested at any depth (a
996
+ // footer inside a guide sub-page), so
997
+ // searching one views[] list misses most of
998
+ // them. Re-rendering the current page mounts
999
+ // every subview fresh from the updated files.
1000
+ renderView(nodes[0], null, View.props ?? {});
1005
1001
  }
1006
1002
  }
1007
1003
  }
@@ -1036,23 +1032,15 @@ function syncViewFiles() {
1036
1032
  }
1037
1033
  }
1038
1034
  }
1039
- // for (var key in tpls) {
1040
- // if (_ovcD['tpls'].hasOwnProperty(key)) {
1041
- // if (!deepCompare(_ovcD['tpls'][key], tpls[key])) {
1042
- // cl("Changed the " + "tpl " + atob(key));
1043
- // _ovcD['tpls'][key] = tpls[key];
1044
- // let n = atob(key)
1045
- // .split("src/tpls/")
1046
- // .join("")
1047
- // .split(".tpl")
1048
- // .join("");
1049
- // $('[tpl="' + n + '"]')
1050
- // .removeData("_status")
1051
- // .removeData("_re");
1052
- // globalWatch();
1053
- // }
1054
- // }
1055
- // }
1035
+ // tpls/comps render inline in their host views, so any
1036
+ // template change means re-rendering the current page.
1037
+ let tpls = _files["tpls"] || {};
1038
+ let tplsChanged = !deepCompare(clone(_ovcD['tpls'] || {}), clone(tpls));
1039
+ if (tplsChanged) {
1040
+ _ovcD['tpls'] = tpls;
1041
+ let nodes = getURLNodes();
1042
+ renderView(nodes[0], null, View.props ?? {});
1043
+ }
1056
1044
  }
1057
1045
  });
1058
1046
  }
@@ -883,7 +883,10 @@ $.fn.priorityOn = function (type, selector, data, fn) {
883
883
  for (var t in types) {
884
884
  $this.on(types[t], selector, data, fn);
885
885
 
886
- var currentBindings = $._data(this, "events")[types[t]];
886
+ // Reordering needs real jQuery's private event table; the
887
+ // lightweight shim has none, so there it's a plain .on().
888
+ if (typeof $._data !== "function") continue;
889
+ var currentBindings = ($._data(this, "events") || {})[types[t]];
887
890
  if ($.isArray(currentBindings)) {
888
891
  currentBindings.unshift(currentBindings.pop());
889
892
  }
@@ -892,6 +895,22 @@ $.fn.priorityOn = function (type, selector, data, fn) {
892
895
  return this;
893
896
  };
894
897
 
898
+ $.fn.lock = function () {
899
+ if ($(this).is('form')) {
900
+ $(this).find('[type="submit"]').attr('disabled', 'disabled');
901
+ $(this).find('button:not([type])').attr('disabled', 'disabled');
902
+ }
903
+ return this;
904
+ };
905
+
906
+ $.fn.unlock = function () {
907
+ if ($(this).is('form')) {
908
+ $(this).find('[type="submit"]').removeAttr('disabled');
909
+ $(this).find('button:not([type])').removeAttr('disabled');
910
+ }
911
+ return this;
912
+ };
913
+
895
914
  $.fn.onClose = function (selector, data, fn) {
896
915
  this.each(function () {
897
916
  var el = $(this);
@@ -2109,7 +2128,7 @@ function renderPlugins() {
2109
2128
  if (editor.is("[mini]")) TB = miniTB;
2110
2129
  else if (editor.is("[full]")) TB = fullTB;
2111
2130
 
2112
- if (CKEDITOR !== undefined) {
2131
+ if (typeof CKEDITOR !== "undefined") {
2113
2132
  /*CKEDITOR.plugins.addExternal( 'autocomplete', 'https://s.beacdn.com/j/autocomplete/plugin.js' );*/
2114
2133
  CKEDITOR.replace(this, {
2115
2134
  uiColor: "#ffffff",
@@ -2798,6 +2817,25 @@ function renderPlugins() {
2798
2817
  format: "rgba",
2799
2818
  });
2800
2819
  });
2820
+
2821
+ $('lmlst:not(.binded)').each(function () {
2822
+ var el = $(this);
2823
+ el.addClass('binded');
2824
+ let _conf = el.attr(':config');
2825
+ let conf = null;
2826
+ if (_conf) {
2827
+ // V1 eval'd this globally; V2 view vars live in the reactive
2828
+ // scope, so resolve it the way @-handler expressions are.
2829
+ try {
2830
+ conf = (typeof _evalEventScopedExpr === 'function')
2831
+ ? _evalEventScopedExpr(el[0]._ownerRe, _conf)
2832
+ : eval(_conf);
2833
+ } catch (x) {
2834
+ conf = null;
2835
+ }
2836
+ }
2837
+ el[0].list = new __myList(el, conf || {});
2838
+ });
2801
2839
  }
2802
2840
 
2803
2841
  function dtp(el, t) {
@@ -4443,6 +4481,429 @@ function ObjFromArr(a, v, k = 'objectId') {
4443
4481
  return obj;
4444
4482
  }
4445
4483
 
4484
+ // V1's <lmlst :config="..." @query="..."> data table/grid component
4485
+ // (core.js:5302-5717), ported verbatim. Initialized by renderPlugins().
4486
+ class __myList {
4487
+ el = null;
4488
+ data = [];
4489
+ config = {
4490
+ viewType: 'dataTable',
4491
+ show: 10,
4492
+ page: 1,
4493
+ order: {
4494
+ column: null,
4495
+ order: "asc",
4496
+ },
4497
+ columns: {},
4498
+ total: 0,
4499
+ pagination: {
4500
+ middle: "",
4501
+ },
4502
+ itemRender: function (k, obj) {
4503
+ let val = "";
4504
+ if (obj.hasOwnProperty(k)) val = obj[k];
4505
+ return val;
4506
+ },
4507
+ gridRender: function (obj) {
4508
+ return obj;
4509
+ },
4510
+ gridPlaceholder: function () {
4511
+ return "---";
4512
+ },
4513
+ itemPlaceholder: function (k) {
4514
+ return "---";
4515
+ },
4516
+ rowClassRender: function (obj) {
4517
+ return "";
4518
+ },
4519
+ gridClassRender: function (obj) {
4520
+ return "";
4521
+ },
4522
+ emptyRender: function (obj) {
4523
+ return `<div class="ov bgb5 op60"><span class="fs26 cc cb pb120">No Data!</span></div>`;
4524
+ }
4525
+ };
4526
+ state = 'loading';
4527
+
4528
+ constructor(el, config) {
4529
+ this.el = el;
4530
+ if (config && typeof config === "object") this.config = { ...this.config, ...config };
4531
+ this.el.trigger("query-list", [this, this.config, "initiated"]);
4532
+ this.render();
4533
+ }
4534
+
4535
+ render() {
4536
+ let self = this;
4537
+ var html = ``;
4538
+ if (this.el) {
4539
+ html = ``;
4540
+
4541
+ if (this.config.viewType.toLowerCase() == 'datagrid') {
4542
+ this.el.removeClass('dataTable').addClass('dataGrid');
4543
+ html +=
4544
+ `
4545
+ <lmlst-body>
4546
+ `;
4547
+
4548
+ // cl(this.state);
4549
+ if (this.state == 'empty') {
4550
+ html += self.config.emptyRender();
4551
+ } else if (this.state == 'loading') {
4552
+ for (let i = 0; i < this.config.show; i++) {
4553
+ html += self.config.gridPlaceholder();
4554
+ }
4555
+ } else {
4556
+ for (let i = 0; i < (this.data.length <= this.config.show ? this.data.length : this.config.show); i++) {
4557
+ const data = this.data[i];
4558
+ html += self.config.gridRender(data);
4559
+ }
4560
+ }
4561
+ html +=
4562
+ `
4563
+ </lmlst-body>
4564
+ `;
4565
+
4566
+ if (this.state != 'empty') {
4567
+ html += `
4568
+ <lmlst-footer class="lh36 r ez-f">
4569
+ <ul style="list-style-type: none;">
4570
+ `;
4571
+
4572
+ const pagings = this.pagination(this.config.page);
4573
+
4574
+
4575
+
4576
+
4577
+
4578
+
4579
+ if (pagings.hasStart) {
4580
+ if (self.config.page > 1) html += `<li page="1"><span class='iconify cc fs14' data-icon='fa-solid:angle-double-left'></span></li>`;
4581
+ else html += `<li><span class='iconify cc fs14' data-icon='fa-solid:angle-double-left'></span></li>`;
4582
+ }
4583
+ if (pagings.hasPrev) {
4584
+ if (self.config.page > 1) html += `<li page="` + (pagings.current - 1 > 0 ? pagings.current - 1 : 1) + `"><span class='iconify cc fs14' data-icon='fa-solid:angle-left'></span></li>`;
4585
+ else html += `<li><span class='iconify cc fs14' data-icon='fa-solid:angle-left'></span></li>`;
4586
+ }
4587
+
4588
+
4589
+
4590
+ // if (pagings.hasStart && self.config.page > 2) html += `<li page="1"><span class='iconify cc fs14' data-icon='fa-solid:angle-double-left'></span></li>`;
4591
+ // if (pagings.hasPrev && self.config.page > 2) html += `<li page="` + (pagings.current - 1 > 0 ? pagings.current - 1 : 1) + `"><span class='iconify cc fs14' data-icon='fa-solid:angle-left'></span></li>`;
4592
+
4593
+ if (pagings.totalpages > 1) pagings.first.forEach(function (page) {
4594
+ html += `<li class='pointer ` + (self.config.page == page ? 'active' : '') + `' page="` + page + `">` + page + `</li>`
4595
+ });
4596
+
4597
+ html += (pagings.totalpages > 5 ? `<li>` + pagings.middle + `</li>` : '');
4598
+
4599
+ if (pagings.totalpages > 1) pagings.last.forEach(function (page) {
4600
+ html += `<li class='pointer ` + (self.config.page == page ? 'active' : '') + `' page="` + page + `">` + page + `</li>`
4601
+ });
4602
+
4603
+
4604
+
4605
+ if (pagings.hasNext) {
4606
+ if (self.config.page != pagings.totalpages) html += `<li page="` + (pagings.current * 1 + 1 < pagings.totalpages ? pagings.current * 1 + 1 : pagings.totalpages) + `"><span class='iconify cc fs14' data-icon='fa-solid:angle-right'></span></li>`;
4607
+ else html += `<li><span class='iconify cc fs14' data-icon='fa-solid:angle-right'></span></li>`;
4608
+ }
4609
+ if (pagings.hasEnd) {
4610
+ if (self.config.page != pagings.totalpages)
4611
+ html += `<li page="` + pagings.totalpages + `"><span class='iconify cc fs14' data-icon='fa-solid:angle-double-right'></span></li>`;
4612
+ else html += `<li><span class='iconify cc fs14' data-icon='fa-solid:angle-double-right'></span></li>`;
4613
+ }
4614
+ // if (pagings.hasNext && self.config.page < pagings.totalpages - 2) html += `<li page="` + (pagings.current * 1 + 1 < pagings.totalpages ? pagings.current * 1 + 1 : pagings.totalpages) + `"><span class='iconify cc fs14' data-icon='fa-solid:angle-right'></span></li>`;
4615
+ // if (pagings.hasEnd && self.config.page < pagings.totalpages - 2) html += `<li page="` + pagings.totalpages + `"><span class='iconify cc fs14' data-icon='fa-solid:angle-double-right'></span></li>`;
4616
+
4617
+
4618
+ html += `</ul>`;
4619
+ html +=
4620
+ `
4621
+ </lmlst-footer>
4622
+ `
4623
+ ;
4624
+ }
4625
+ } else {
4626
+ this.el.removeClass('dataGrid').addClass('dataTable');
4627
+ html +=
4628
+ `
4629
+ <lmlst-header class="ps ez-f" wrapper>
4630
+ <div scsc="list" dgsc class="grab">
4631
+ <ul class="b p0">
4632
+ <li>
4633
+ <div class="tsh ez-f">
4634
+ <div></div>
4635
+ `;
4636
+ for (const k in this.config.columns) {
4637
+ const col = this.config.columns[k];
4638
+ if (!isObject(col)) continue;
4639
+ if (col?.hide) continue;
4640
+
4641
+ html +=
4642
+ `
4643
+ <div class="`+ (col.mini ? 'mini' : '') + `"><span class=vm>` + col.title + ` </span>` + (col?.sort ? `<span ` + 'order="' + (this.config.order.order == 'asc' ? 'desc' : 'asc') + '" column="' + k + '"' + ` class="iconify vm" ` + (k == this.config.order.column ?
4644
+ (this.config.order.order == 'asc'
4645
+ ? ` data-icon="fluent:arrow-up-24-regular" `
4646
+ : ' data-icon="fluent:arrow-down-24-regular" ')
4647
+ : ` data-icon="fluent:arrow-sort-24-regular" `) + `></span>` : ``) + `</div>
4648
+ `;
4649
+ }
4650
+ html +=
4651
+ `
4652
+ <div></div>
4653
+ </div>
4654
+ </li>
4655
+ </ul>
4656
+ </div>
4657
+ </lmlst-header>
4658
+ <lmlst-body scsc="list" dgsc class="`+ (this.state != 'empty' ? 'grab' : '') + `">
4659
+ `;
4660
+
4661
+ // cl(this.state);
4662
+ if (this.state == 'empty') {
4663
+ html += self.config.emptyRender();
4664
+ } else if (this.state == 'loading') {
4665
+
4666
+ for (let i = 0; i < this.config.show; i++) {
4667
+ html +=
4668
+ `
4669
+ <ul class="shimmer">
4670
+ <li>
4671
+ <div class="bgw80 round sh tsh ez-f ` + self.config.rowClassRender({}) + `">
4672
+ <div></div>
4673
+ `;
4674
+
4675
+ for (const k in this.config.columns) {
4676
+ if (!isObject(this.config.columns[k])) continue;
4677
+ if (this.config.columns[k]?.hide) continue;
4678
+ html += `<div class="` + (this.config.columns[k].mini ? 'mini' : '') + `">` + self.config.itemPlaceholder(k) + `</div>`;
4679
+ }
4680
+
4681
+ html +=
4682
+ `
4683
+ <div>
4684
+ <div></div>
4685
+
4686
+ </div>
4687
+ </li>
4688
+ </ul>
4689
+ `;
4690
+ }
4691
+ } else {
4692
+
4693
+ for (let i = 0; i < (this.data.length <= this.config.show ? this.data.length : this.config.show); i++) {
4694
+ const data = this.data[i];
4695
+
4696
+ html +=
4697
+ `
4698
+ <ul class="p0">
4699
+ <li>
4700
+ <div class="bgw80 round sh tsh ez-f ` + self.config.rowClassRender(data) + `">
4701
+ <div></div>
4702
+ `;
4703
+
4704
+ for (const k in this.config.columns) {
4705
+ const col = this.config.columns[k];
4706
+ if (!isObject(col)) continue;
4707
+ if (col?.hide) continue;
4708
+
4709
+ html +=
4710
+ `
4711
+ <div class="`+ (col.mini ? 'mini' : '') + `">` + self.config.itemRender(k, data) + `</div>
4712
+ `;
4713
+ }
4714
+
4715
+ html +=
4716
+ `
4717
+ <div></div>
4718
+ </div>
4719
+ </li>
4720
+ </ul>
4721
+ `;
4722
+ }
4723
+ }
4724
+ html +=
4725
+ `
4726
+ </div>
4727
+ </div>
4728
+ </lmlst-body>
4729
+ `;
4730
+ if (this.state != 'empty') {
4731
+ html += `
4732
+ <lmlst-footer class="ov pf bgw ta sh50 lh36 r z100 ez-f">
4733
+ <ul style="list-style-type: none;">
4734
+ `;
4735
+
4736
+ const pagings = this.pagination(this.config.page);
4737
+
4738
+ if (pagings.hasStart) {
4739
+ if (self.config.page > 2) html += `<li page="1"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`;
4740
+ else html += `<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`;
4741
+ }
4742
+ if (pagings.hasPrev) {
4743
+ if (self.config.page > 1) html += `<li page="` + (pagings.current - 1 > 0 ? pagings.current - 1 : 1) + `"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`;
4744
+ else html += `<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`;
4745
+ }
4746
+
4747
+ if (pagings.totalpages > 1) pagings.first.forEach(function (page) {
4748
+ html += `<li class='pointer ` + (self.config.page == page ? 'active' : '') + `' page="` + page + `">` + page + `</li>`
4749
+ });
4750
+
4751
+ if (pagings.totalpages > 5) html += `<li>` + pagings.middle + `</li>`;
4752
+
4753
+ if (pagings.totalpages > 1) pagings.last.forEach(function (page) {
4754
+ html += `<li class='pointer ` + (self.config.page == page ? 'active' : '') + `' page="` + page + `">` + page + `</li>`
4755
+ });
4756
+
4757
+
4758
+ if (pagings.hasNext) {
4759
+ if (self.config.page != pagings.totalpages) html += `<li page="` + (pagings.current * 1 + 1 < pagings.totalpages ? pagings.current * 1 + 1 : pagings.totalpages) + `"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`;
4760
+ else html += `<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`;
4761
+ }
4762
+ if (pagings.hasEnd) {
4763
+ if (self.config.page != pagings.totalpages)
4764
+ html += `<li page="` + pagings.totalpages + `"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`;
4765
+ else html += `<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`;
4766
+ }
4767
+
4768
+
4769
+ html += `</ul>`;
4770
+ html +=
4771
+ `
4772
+ </lmlst-footer>
4773
+ `
4774
+ ;
4775
+ }
4776
+ }
4777
+
4778
+ this.el.html(html);
4779
+ globalWatch();
4780
+ }
4781
+ }
4782
+
4783
+ refresh() {
4784
+ this.el.trigger("query-list", [this, this.config, "refresh"]);
4785
+ }
4786
+
4787
+ setPage(p) {
4788
+ this.config.page = p;
4789
+ }
4790
+ setOrder(o) {
4791
+ this.config.order = o;
4792
+ }
4793
+ setLoading() {
4794
+ this.state = 'loading';
4795
+ this.render();
4796
+ }
4797
+ setData(data) {
4798
+ this.data = data;
4799
+ if (data.length) this.state = 'loaded';
4800
+ else this.state = 'empty';
4801
+ this.render();
4802
+ }
4803
+
4804
+ pagination(currPage) {
4805
+ var show = this.config.show;
4806
+ var total = this.config.total;
4807
+ var totalpages = Math.ceil((total) / show);
4808
+
4809
+ if (currPage > totalpages) currPage = totalpages;
4810
+ if (currPage <= 0) currPage = 1;
4811
+ if (currPage > totalpages) currPage = totalpages;
4812
+ var previousPage = currPage - 1;
4813
+ var nextPage = currPage * 1 + 1;
4814
+ let weight = currPage <= totalpages / 2 ? "left" : "right";
4815
+
4816
+ var result = {
4817
+ hasStart: false,
4818
+ hasEnd: false,
4819
+ first: [],
4820
+ totalpages: totalpages,
4821
+ middle: this.config.pagination.middle,
4822
+ last: [],
4823
+ weight: weight,
4824
+ current: currPage,
4825
+ };
4826
+
4827
+ if (totalpages > 5) {
4828
+ result.hasEnd = true;
4829
+ result.hasStart = true;
4830
+ result.hasPrev = true;
4831
+ result.hasNext = true;
4832
+ if (currPage < totalpages * 1 - 2) {
4833
+ if (currPage > 1) {
4834
+ result.first = [previousPage, currPage, nextPage];
4835
+ result.last = [totalpages * 1 - 1, totalpages];
4836
+ } else {
4837
+ result.first = [currPage, nextPage, nextPage * 1 + 1];
4838
+ result.last = [totalpages * 1 - 1, totalpages];
4839
+ }
4840
+ } else {
4841
+ if (currPage >= totalpages) {
4842
+ result.first = [1, 2];
4843
+ result.last = [previousPage * 1 - 1, previousPage, currPage];
4844
+ }
4845
+ else if (currPage == totalpages * 1 - 2) {
4846
+ result.first = [1, 2];
4847
+ result.last = [previousPage, currPage, nextPage, totalpages];
4848
+ } else {
4849
+ result.first = [1, 2];
4850
+ result.last = [previousPage, currPage, nextPage];
4851
+ }
4852
+ }
4853
+ } else if (totalpages > 0 && totalpages <= 5) {
4854
+ for (var i = 0; i < totalpages; i++) {
4855
+ if (
4856
+ weight == "left" &&
4857
+ result.first.length < Math.trunc(totalpages / 2) + 1
4858
+ ) {
4859
+ result.first.push(i * 1 + 1);
4860
+ } else if (
4861
+ weight == "right" &&
4862
+ result.first.length < Math.trunc(totalpages / 2)
4863
+ ) {
4864
+ result.first.push(i * 1 + 1);
4865
+ } else {
4866
+ result.last.push(i * 1 + 1);
4867
+ }
4868
+ }
4869
+ }
4870
+ return result;
4871
+
4872
+ }
4873
+
4874
+ }
4875
+
4876
+ $("body").on("query-list", "lmlst", function (ev, list, config, type) {
4877
+ processEv(ev, $(this), "query", list, config, type);
4878
+ });
4879
+
4880
+ $("body").on("click touch", "[page]", function (ev) {
4881
+ let el = $(this);
4882
+ let host = el.closest("lmlst")[0];
4883
+ if (!host || !host.list) return;
4884
+ let list = host.list;
4885
+ list.setPage(el.attr("page"));
4886
+ list.setLoading();
4887
+ list.el.trigger("query-list", [list, list.config, "page-changed"]);
4888
+ });
4889
+
4890
+ $("body").on("click touch", "[order]", function (ev) {
4891
+ let el = $(this);
4892
+ let host = el.closest("lmlst")[0];
4893
+ if (!host || !host.list) return;
4894
+ let list = host.list;
4895
+ list.setPage(1);
4896
+ list.setOrder({
4897
+ column: el.attr("column") ?? null,
4898
+ order:
4899
+ list.config.order.column != el.attr("column")
4900
+ ? "asc"
4901
+ : el.attr("order") ?? "asc",
4902
+ });
4903
+ list.setLoading();
4904
+ list.el.trigger("query-list", [list, list.config, "order-changed"]);
4905
+ });
4906
+
4446
4907
  // 2026-09-22: the real gesture-dispatch mechanism — tap/doubletap/
4447
4908
  // singletap/taphold/clickhold/tap2/tap2hold/tapstart/tapend/tapmove/
4448
4909
  // swipe(+4 directions)/swipeend. Every one of lstnrs.js's own real