@whitesev/pops 2.3.6 → 2.3.7

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/dist/index.amd.js CHANGED
@@ -1154,6 +1154,7 @@ define((function () { 'use strict';
1154
1154
  * })
1155
1155
  */
1156
1156
  ready(callback) {
1157
+ const that = this;
1157
1158
  if (typeof callback !== "function") {
1158
1159
  return;
1159
1160
  }
@@ -1199,7 +1200,7 @@ define((function () { 'use strict';
1199
1200
  function addDomReadyListener() {
1200
1201
  for (let index = 0; index < targetList.length; index++) {
1201
1202
  let item = targetList[index];
1202
- item.target.addEventListener(item.eventType, item.callback);
1203
+ that.on(item.target, item.eventType, item.callback);
1203
1204
  }
1204
1205
  }
1205
1206
  /**
@@ -1208,7 +1209,7 @@ define((function () { 'use strict';
1208
1209
  function removeDomReadyListener() {
1209
1210
  for (let index = 0; index < targetList.length; index++) {
1210
1211
  let item = targetList[index];
1211
- item.target.removeEventListener(item.eventType, item.callback);
1212
+ that.off(item.target, item.eventType, item.callback);
1212
1213
  }
1213
1214
  }
1214
1215
  if (checkDOMReadyState()) {
@@ -1490,9 +1491,7 @@ define((function () { 'use strict';
1490
1491
  eventNameList = [eventNameList];
1491
1492
  }
1492
1493
  eventNameList.forEach((eventName) => {
1493
- element.addEventListener(eventName, stopEvent, {
1494
- capture: Boolean(capture),
1495
- });
1494
+ this.on(element, eventName, stopEvent, { capture: Boolean(capture) });
1496
1495
  });
1497
1496
  }
1498
1497
  }
@@ -5141,57 +5140,101 @@ define((function () { 'use strict';
5141
5140
  if ($mask != null) {
5142
5141
  $anim.after($mask);
5143
5142
  }
5144
- /* 添加文件信息 */
5145
- config.folder.sort();
5146
- /**
5147
- * 创建文件夹元素
5148
- * @param fileName
5149
- * @param latestTime
5150
- * @param [fileSize="-"]
5151
- * @param isFolder
5152
- */
5153
- function createFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5154
- let origin_fileName = fileName;
5155
- let origin_latestTime = latestTime;
5156
- let origin_fileSize = fileSize;
5157
- let folderELement = popsDOMUtils.createElement("tr");
5158
- let fileNameElement = popsDOMUtils.createElement("td");
5159
- let fileTimeElement = popsDOMUtils.createElement("td");
5160
- let fileFormatSize = popsDOMUtils.createElement("td");
5161
- let fileType = "";
5162
- let fileIcon = Folder_ICON.folder;
5163
- if (isFolder) {
5164
- /* 文件夹 */
5165
- latestTime = "";
5166
- fileSize = "";
5167
- }
5168
- else {
5169
- /* 文件 */
5170
- fileIcon = "";
5171
- if (typeof latestTime === "number") {
5172
- latestTime = popsUtils.formatTime(latestTime);
5173
- }
5174
- if (typeof fileSize === "number") {
5175
- fileSize = popsUtils.formatByteToSize(fileSize);
5176
- }
5177
- for (let keyName in Folder_ICON) {
5178
- if (fileName.toLowerCase().endsWith("." + keyName)) {
5179
- fileType = keyName;
5180
- fileIcon = Folder_ICON[keyName];
5181
- break;
5182
- }
5143
+ class PopsFolder {
5144
+ init() {
5145
+ config.folder.sort();
5146
+ this.initFolderView(config.folder);
5147
+ /* 将数据存到全部文件的属性_config_中 */
5148
+ let allFilesElement = folderFileListBreadcrumbPrimaryElement.querySelector(".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child");
5149
+ Reflect.set(allFilesElement, "_config_", config.folder);
5150
+ /* 设置点击顶部的全部文件事件 */
5151
+ popsDOMUtils.on(allFilesElement, "click", (event) => {
5152
+ this.setBreadcrumbClickEvent(event, true, config.folder);
5153
+ });
5154
+ // 文件名的点击排序
5155
+ popsDOMUtils.on(folderListSortFileNameElement.closest("th"), "click", (event) => {
5156
+ this.arrowToSortFolderInfoView(folderListSortFileNameElement, event, "fileName");
5157
+ }, {
5158
+ capture: true,
5159
+ });
5160
+ // 修改事件的点击排序
5161
+ popsDOMUtils.on(folderListSortLatestTimeElement.closest("th"), "click", (event) => {
5162
+ this.arrowToSortFolderInfoView(folderListSortLatestTimeElement, event, "latestTime");
5163
+ }, {
5164
+ capture: true,
5165
+ });
5166
+ // 文件大小的点击排序
5167
+ popsDOMUtils.on(folderListSortFileSizeElement.closest("th"), "click", (event) => {
5168
+ this.arrowToSortFolderInfoView(folderListSortFileSizeElement, event, "fileSize");
5169
+ }, {
5170
+ capture: true,
5171
+ });
5172
+ /* 设置默认触发的arrow */
5173
+ if (config.sort.name === "fileName") {
5174
+ popsDOMUtils.trigger(folderListSortFileNameElement, "click", {
5175
+ notChangeSortRule: true,
5176
+ });
5183
5177
  }
5184
- if (!Boolean(fileIcon)) {
5185
- fileType = "Null";
5186
- fileIcon = Folder_ICON.Null;
5178
+ else if (config.sort.name === "latestTime") {
5179
+ popsDOMUtils.trigger(folderListSortLatestTimeElement, "click", {
5180
+ notChangeSortRule: true,
5181
+ });
5182
+ }
5183
+ else if (config.sort.name === "fileSize") {
5184
+ popsDOMUtils.trigger(folderListSortFileSizeElement, "click", {
5185
+ notChangeSortRule: true,
5186
+ });
5187
5187
  }
5188
5188
  }
5189
- folderELement.className = "pops-folder-list-table__body-row";
5190
- fileNameElement.className = "pops-folder-list-table__body-td";
5191
- fileTimeElement.className = "pops-folder-list-table__body-td";
5192
- fileFormatSize.className = "pops-folder-list-table__body-td";
5193
- PopsSafeUtils.setSafeHTML(fileNameElement,
5194
- /*html*/ `
5189
+ /**
5190
+ * 创建文件夹元素
5191
+ * @param fileName 文件名
5192
+ * @param latestTime 修改时间
5193
+ * @param [fileSize="-"] 文件大小
5194
+ * @param isFolder 是否是文件夹
5195
+ */
5196
+ createFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5197
+ let origin_fileName = fileName;
5198
+ let origin_latestTime = latestTime;
5199
+ let origin_fileSize = fileSize;
5200
+ let folderElement = popsDOMUtils.createElement("tr");
5201
+ let fileNameElement = popsDOMUtils.createElement("td");
5202
+ let fileTimeElement = popsDOMUtils.createElement("td");
5203
+ let fileFormatSize = popsDOMUtils.createElement("td");
5204
+ let fileType = "";
5205
+ let fileIcon = Folder_ICON.folder;
5206
+ if (isFolder) {
5207
+ /* 文件夹 */
5208
+ latestTime = "";
5209
+ fileSize = "";
5210
+ }
5211
+ else {
5212
+ /* 文件 */
5213
+ fileIcon = "";
5214
+ if (typeof latestTime === "number") {
5215
+ latestTime = popsUtils.formatTime(latestTime);
5216
+ }
5217
+ if (typeof fileSize === "number") {
5218
+ fileSize = popsUtils.formatByteToSize(fileSize);
5219
+ }
5220
+ for (let keyName in Folder_ICON) {
5221
+ if (fileName.toLowerCase().endsWith("." + keyName)) {
5222
+ fileType = keyName;
5223
+ fileIcon = Folder_ICON[keyName];
5224
+ break;
5225
+ }
5226
+ }
5227
+ if (!Boolean(fileIcon)) {
5228
+ fileType = "Null";
5229
+ fileIcon = Folder_ICON.Null;
5230
+ }
5231
+ }
5232
+ folderElement.className = "pops-folder-list-table__body-row";
5233
+ fileNameElement.className = "pops-folder-list-table__body-td";
5234
+ fileTimeElement.className = "pops-folder-list-table__body-td";
5235
+ fileFormatSize.className = "pops-folder-list-table__body-td";
5236
+ PopsSafeUtils.setSafeHTML(fileNameElement,
5237
+ /*html*/ `
5195
5238
  <div class="pops-folder-list-file-name cursor-p">
5196
5239
  <div>
5197
5240
  <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
@@ -5201,80 +5244,84 @@ define((function () { 'use strict';
5201
5244
  </div>
5202
5245
  </div>
5203
5246
  `);
5204
- PopsSafeUtils.setSafeHTML(fileTimeElement,
5205
- /*html*/ `
5247
+ PopsSafeUtils.setSafeHTML(fileTimeElement,
5248
+ /*html*/ `
5206
5249
  <div class="pops-folder-list__time">
5207
5250
  <span>${latestTime}</span>
5208
5251
  </div>
5209
5252
  `);
5210
- PopsSafeUtils.setSafeHTML(fileFormatSize,
5211
- /*html*/ `
5253
+ PopsSafeUtils.setSafeHTML(fileFormatSize,
5254
+ /*html*/ `
5212
5255
  <div class="pops-folder-list-format-size">
5213
5256
  <span>${fileSize}</span>
5214
5257
  </div>
5215
5258
  `);
5216
- /* 存储原来的值 */
5217
- let __value__ = {
5218
- fileName: origin_fileName,
5219
- latestTime: origin_latestTime,
5220
- fileSize: origin_fileSize,
5221
- isFolder: isFolder,
5222
- };
5223
- Reflect.set(fileNameElement, "__value__", __value__);
5224
- Reflect.set(fileTimeElement, "__value__", __value__);
5225
- Reflect.set(fileFormatSize, "__value__", __value__);
5226
- Reflect.set(folderELement, "__value__", __value__);
5227
- folderELement.appendChild(fileNameElement);
5228
- folderELement.appendChild(fileTimeElement);
5229
- folderELement.appendChild(fileFormatSize);
5230
- return {
5231
- folderELement,
5232
- fileNameElement,
5233
- fileTimeElement,
5234
- fileFormatSize,
5235
- };
5236
- }
5237
- /**
5238
- * 创建移动端文件夹元素
5239
- */
5240
- function createMobileFolderRowElement(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5241
- let origin_fileName = fileName;
5242
- let origin_latestTime = latestTime;
5243
- let origin_fileSize = fileSize;
5244
- let folderELement = popsDOMUtils.createElement("tr");
5245
- let fileNameElement = popsDOMUtils.createElement("td");
5246
- let fileType = "";
5247
- let fileIcon = Folder_ICON.folder;
5248
- if (isFolder) {
5249
- /* 文件夹 */
5250
- latestTime = "";
5251
- fileSize = "";
5259
+ /* 存储原来的值 */
5260
+ let __value__ = {
5261
+ fileName: origin_fileName,
5262
+ latestTime: origin_latestTime,
5263
+ fileSize: origin_fileSize,
5264
+ isFolder: isFolder,
5265
+ };
5266
+ Reflect.set(fileNameElement, "__value__", __value__);
5267
+ Reflect.set(fileTimeElement, "__value__", __value__);
5268
+ Reflect.set(fileFormatSize, "__value__", __value__);
5269
+ Reflect.set(folderElement, "__value__", __value__);
5270
+ folderElement.appendChild(fileNameElement);
5271
+ folderElement.appendChild(fileTimeElement);
5272
+ folderElement.appendChild(fileFormatSize);
5273
+ return {
5274
+ folderElement,
5275
+ fileNameElement,
5276
+ fileTimeElement,
5277
+ fileFormatSize,
5278
+ };
5252
5279
  }
5253
- else {
5254
- /* 文件 */
5255
- fileIcon = "";
5256
- if (typeof latestTime === "number") {
5257
- latestTime = popsUtils.formatTime(latestTime);
5258
- }
5259
- if (typeof fileSize === "number") {
5260
- fileSize = popsUtils.formatByteToSize(fileSize);
5261
- }
5262
- for (let keyName in Folder_ICON) {
5263
- if (fileName.toLowerCase().endsWith("." + keyName)) {
5264
- fileType = keyName;
5265
- fileIcon = Folder_ICON[keyName];
5266
- break;
5267
- }
5280
+ /**
5281
+ * 创建移动端文件夹元素
5282
+ * @param fileName 文件名
5283
+ * @param latestTime 创建时间
5284
+ * @param [fileSize="-"] 文件大小
5285
+ * @param isFolder 是否是文件夹
5286
+ */
5287
+ createFolderRowElementByMobile(fileName, latestTime = "-", fileSize = "-", isFolder = false) {
5288
+ let origin_fileName = fileName;
5289
+ let origin_latestTime = latestTime;
5290
+ let origin_fileSize = fileSize;
5291
+ let folderElement = popsDOMUtils.createElement("tr");
5292
+ let fileNameElement = popsDOMUtils.createElement("td");
5293
+ let fileType = "";
5294
+ let fileIcon = Folder_ICON.folder;
5295
+ if (isFolder) {
5296
+ /* 文件夹 */
5297
+ latestTime = "";
5298
+ fileSize = "";
5268
5299
  }
5269
- if (!Boolean(fileIcon)) {
5270
- fileType = "Null";
5271
- fileIcon = Folder_ICON.Null;
5300
+ else {
5301
+ /* 文件 */
5302
+ fileIcon = "";
5303
+ if (typeof latestTime === "number") {
5304
+ latestTime = popsUtils.formatTime(latestTime);
5305
+ }
5306
+ if (typeof fileSize === "number") {
5307
+ fileSize = popsUtils.formatByteToSize(fileSize);
5308
+ }
5309
+ for (let keyName in Folder_ICON) {
5310
+ if (fileName.toLowerCase().endsWith("." + keyName)) {
5311
+ fileType = keyName;
5312
+ fileIcon = Folder_ICON[keyName];
5313
+ break;
5314
+ }
5315
+ }
5316
+ if (!Boolean(fileIcon)) {
5317
+ fileType = "Null";
5318
+ fileIcon = Folder_ICON.Null;
5319
+ }
5272
5320
  }
5273
- }
5274
- folderELement.className = "pops-folder-list-table__body-row";
5275
- fileNameElement.className = "pops-folder-list-table__body-td";
5276
- PopsSafeUtils.setSafeHTML(fileNameElement,
5277
- /*html*/ `
5321
+ folderElement.className = "pops-folder-list-table__body-row";
5322
+ fileNameElement.className = "pops-folder-list-table__body-td";
5323
+ PopsSafeUtils.setSafeHTML(fileNameElement,
5324
+ /*html*/ `
5278
5325
  <div class="pops-folder-list-file-name pops-mobile-folder-list-file-name cursor-p">
5279
5326
  <img src="${fileIcon}" alt="${fileType}" class="pops-folder-list-file-icon u-file-icon u-file-icon--list">
5280
5327
  <div>
@@ -5283,139 +5330,138 @@ define((function () { 'use strict';
5283
5330
  </div>
5284
5331
  </div>
5285
5332
  `);
5286
- /* 存储原来的值 */
5287
- let __value__ = {
5288
- fileName: origin_fileName,
5289
- latestTime: origin_latestTime,
5290
- fileSize: origin_fileSize,
5291
- isFolder: isFolder,
5292
- };
5293
- Reflect.set(fileNameElement, "__value__", __value__);
5294
- Reflect.set(folderELement, "__value__", __value__);
5295
- folderELement.appendChild(fileNameElement);
5296
- return {
5297
- folderELement,
5298
- fileNameElement,
5299
- };
5300
- }
5301
- /**
5302
- * 清空每行的元素
5303
- */
5304
- function clearFolderRow() {
5305
- PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
5306
- }
5307
- /**
5308
- * 创建顶部导航的箭头图标
5309
- */
5310
- function createHeaderArrowIcon() {
5311
- let iconArrowElement = popsDOMUtils.createElement("div", {
5312
- className: "iconArrow",
5313
- });
5314
- return iconArrowElement;
5315
- }
5316
- /**
5317
- * 添加顶部导航
5318
- * @param folderName 文件夹名
5319
- * @param folderDataConfig 文件夹配置
5320
- */
5321
- function createHeaderFileLinkNavgiation(folderName, folderDataConfig) {
5322
- let spanElement = popsDOMUtils.createElement("span", {
5323
- className: "pops-folder-file-list-breadcrumb-allFiles cursor-p",
5324
- innerHTML: `<a>${folderName}</a>`,
5325
- _config_: folderDataConfig,
5326
- }, {
5327
- title: folderName,
5328
- });
5329
- return spanElement;
5330
- }
5331
- /**
5332
- * 顶部导航的点击事件
5333
- * @param event
5334
- * @param isTop 是否是全部文件按钮
5335
- * @param folderDataConfigList 配置
5336
- */
5337
- function breadcrumbAllFilesElementClickEvent(event, isTop, folderDataConfigList) {
5338
- clearFolderRow();
5339
- /* 获取当前的导航元素 */
5340
- let $click = event.target;
5341
- let currentBreadcrumb = $click.closest("span.pops-folder-file-list-breadcrumb-allFiles");
5342
- if (currentBreadcrumb) {
5343
- while (currentBreadcrumb.nextElementSibling) {
5344
- currentBreadcrumb.nextElementSibling.remove();
5333
+ /* 存储原来的值 */
5334
+ let __value__ = {
5335
+ fileName: origin_fileName,
5336
+ latestTime: origin_latestTime,
5337
+ fileSize: origin_fileSize,
5338
+ isFolder: isFolder,
5339
+ };
5340
+ Reflect.set(fileNameElement, "__value__", __value__);
5341
+ Reflect.set(folderElement, "__value__", __value__);
5342
+ folderElement.appendChild(fileNameElement);
5343
+ return {
5344
+ folderElement,
5345
+ fileNameElement,
5346
+ };
5347
+ }
5348
+ /**
5349
+ * 清空文件夹信息页面
5350
+ */
5351
+ clearFolderInfoView() {
5352
+ PopsSafeUtils.setSafeHTML(folderListBodyElement, "");
5353
+ }
5354
+ /**
5355
+ * 创建顶部导航的箭头图标
5356
+ */
5357
+ createHeaderArrowIcon() {
5358
+ let $arrowIcon = popsDOMUtils.createElement("div", {
5359
+ className: "iconArrow",
5360
+ });
5361
+ return $arrowIcon;
5362
+ }
5363
+ /**
5364
+ * 添加顶部导航元素
5365
+ * @param folderName 文件夹名
5366
+ * @param folderDataConfig 文件夹配置
5367
+ */
5368
+ createBreadcrumb(folderName, folderDataConfig) {
5369
+ let $breadcrumb = popsDOMUtils.createElement("span", {
5370
+ className: "pops-folder-file-list-breadcrumb-allFiles cursor-p",
5371
+ innerHTML: `<a>${folderName}</a>`,
5372
+ _config_: folderDataConfig,
5373
+ }, {
5374
+ title: folderName,
5375
+ });
5376
+ return $breadcrumb;
5377
+ }
5378
+ /**
5379
+ * 顶部导航的点击事件
5380
+ * @param clickEvent
5381
+ * @param isTop 是否是全部文件按钮
5382
+ * @param dataConfigList 配置
5383
+ */
5384
+ setBreadcrumbClickEvent(clickEvent, isTop, dataConfigList) {
5385
+ this.clearFolderInfoView();
5386
+ /* 获取当前的导航元素 */
5387
+ let $click = clickEvent.target;
5388
+ let currentBreadcrumb = $click.closest("span.pops-folder-file-list-breadcrumb-allFiles");
5389
+ if (currentBreadcrumb) {
5390
+ while (currentBreadcrumb.nextElementSibling) {
5391
+ currentBreadcrumb.nextElementSibling.remove();
5392
+ }
5393
+ }
5394
+ else {
5395
+ console.error("获取导航按钮失败");
5345
5396
  }
5397
+ let loadingMask = PopsLoading.init({
5398
+ parent: $content,
5399
+ content: {
5400
+ text: "获取文件列表中...",
5401
+ },
5402
+ mask: {
5403
+ enable: true,
5404
+ clickEvent: {
5405
+ toClose: false,
5406
+ toHide: false,
5407
+ },
5408
+ },
5409
+ addIndexCSS: false,
5410
+ });
5411
+ this.initFolderView(dataConfigList);
5412
+ loadingMask.close();
5346
5413
  }
5347
- else {
5348
- console.error("获取导航按钮失败");
5349
- }
5350
- let loadingMask = PopsLoading.init({
5351
- parent: $content,
5352
- content: {
5353
- text: "获取文件列表中...",
5354
- },
5355
- mask: {
5356
- enable: true,
5357
- clickEvent: {
5358
- toClose: false,
5359
- toHide: false,
5414
+ /**
5415
+ * 文件夹的点击事件 - 进入文件夹
5416
+ *
5417
+ * 先情况页面元素
5418
+ * @param clickEvent
5419
+ * @param dataConfig
5420
+ */
5421
+ async enterFolder(clickEvent, dataConfig) {
5422
+ this.clearFolderInfoView();
5423
+ let loadingMask = PopsLoading.init({
5424
+ parent: $content,
5425
+ content: {
5426
+ text: "获取文件列表中...",
5360
5427
  },
5361
- },
5362
- addIndexCSS: false,
5363
- });
5364
- addFolderElement(folderDataConfigList);
5365
- loadingMask.close();
5366
- }
5367
- /**
5368
- * 刷新文件列表界面信息
5369
- * @param event
5370
- * @param folderDataConfig
5371
- */
5372
- async function refreshFolderInfoClickEvent(event, folderDataConfig) {
5373
- clearFolderRow();
5374
- let loadingMask = PopsLoading.init({
5375
- parent: $content,
5376
- content: {
5377
- text: "获取文件列表中...",
5378
- },
5379
- mask: {
5380
- enable: true,
5381
- },
5382
- addIndexCSS: false,
5383
- });
5384
- if (typeof folderDataConfig.clickEvent === "function") {
5385
- let childConfig = await folderDataConfig.clickEvent(event, folderDataConfig);
5386
- /* 添加顶部导航的箭头 */
5387
- folderFileListBreadcrumbPrimaryElement.appendChild(createHeaderArrowIcon());
5388
- /* 添加顶部导航的链接文字 */
5389
- let breadcrumbAllFilesElement = createHeaderFileLinkNavgiation(folderDataConfig.fileName, childConfig);
5390
- folderFileListBreadcrumbPrimaryElement.appendChild(breadcrumbAllFilesElement);
5391
- /* 设置顶部导航点击事件 */
5392
- popsDOMUtils.on(breadcrumbAllFilesElement, "click", function (event) {
5393
- breadcrumbAllFilesElementClickEvent(event, false, childConfig);
5428
+ mask: {
5429
+ enable: true,
5430
+ },
5431
+ addIndexCSS: false,
5394
5432
  });
5395
- addFolderElement(childConfig);
5433
+ if (typeof dataConfig.clickEvent === "function") {
5434
+ let childConfig = await dataConfig.clickEvent(clickEvent, dataConfig);
5435
+ /* 添加顶部导航的箭头 */
5436
+ folderFileListBreadcrumbPrimaryElement.appendChild(this.createHeaderArrowIcon());
5437
+ /* 添加顶部导航的链接文字 */
5438
+ let breadcrumbAllFilesElement = this.createBreadcrumb(dataConfig.fileName, childConfig);
5439
+ folderFileListBreadcrumbPrimaryElement.appendChild(breadcrumbAllFilesElement);
5440
+ /* 设置顶部导航点击事件 */
5441
+ popsDOMUtils.on(breadcrumbAllFilesElement, "click", (event) => {
5442
+ this.setBreadcrumbClickEvent(event, false, childConfig);
5443
+ });
5444
+ this.initFolderView(childConfig);
5445
+ }
5446
+ loadingMask.close();
5396
5447
  }
5397
- loadingMask.close();
5398
- }
5399
- /**
5400
- * 设置文件点击事件
5401
- * @param targetElement
5402
- * @param _config_
5403
- */
5404
- function setFileClickEvent(targetElement, _config_) {
5405
- popsDOMUtils.on(targetElement, "click", async function (event) {
5406
- event?.preventDefault();
5407
- event?.stopPropagation();
5408
- event?.stopImmediatePropagation();
5409
- let linkElement = targetElement.querySelector("a");
5410
- if (typeof _config_.clickEvent === "function") {
5411
- let downloadInfo = await _config_.clickEvent(event, _config_);
5448
+ /**
5449
+ * 文件的点击事件 - 下载文件
5450
+ * @param $target
5451
+ * @param dataConfig
5452
+ */
5453
+ async downloadFile(clickEvent, $row, dataConfig) {
5454
+ popsDOMUtils.preventEvent(clickEvent);
5455
+ let $link = $row.querySelector("a");
5456
+ if (typeof dataConfig.clickEvent === "function") {
5457
+ let downloadInfo = await dataConfig.clickEvent(clickEvent, dataConfig);
5412
5458
  if (downloadInfo != null &&
5413
5459
  typeof downloadInfo === "object" &&
5414
5460
  !Array.isArray(downloadInfo) &&
5415
5461
  typeof downloadInfo.url === "string" &&
5416
5462
  downloadInfo.url.trim() !== "") {
5417
- linkElement.setAttribute("href", downloadInfo.url);
5418
- linkElement.setAttribute("target", "_blank");
5463
+ $link.setAttribute("href", downloadInfo.url);
5464
+ $link.setAttribute("target", "_blank");
5419
5465
  if (downloadInfo.autoDownload) {
5420
5466
  if (downloadInfo.mode == null || downloadInfo.mode === "") {
5421
5467
  /* 未设置mode的话默认为aBlank */
@@ -5459,215 +5505,190 @@ define((function () { 'use strict';
5459
5505
  }
5460
5506
  }
5461
5507
  }
5462
- });
5463
- }
5464
- /**
5465
- * 对配置进行排序
5466
- * @param folderDataConfigList
5467
- * @param sortName 比较的属性,默认fileName
5468
- * @param isDesc 是否降序,默认false(升序)
5469
- */
5470
- function sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
5471
- if (sortName === "fileName") {
5472
- // 如果是以文件名排序,文件夹优先放前面
5473
- let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
5474
- return value.isFolder;
5475
- });
5476
- let onlyFileDataConfigList = folderDataConfigList.filter((value) => {
5477
- return !value.isFolder;
5478
- });
5479
- // 文件夹排序
5480
- onlyFolderDataConfigList.sort((leftConfig, rightConfig) => {
5481
- let beforeVal = leftConfig[sortName].toString();
5482
- let afterVal = rightConfig[sortName].toString();
5483
- let compareVal = beforeVal.localeCompare(afterVal);
5484
- if (isDesc) {
5485
- /* 降序 */
5486
- if (compareVal > 0) {
5487
- compareVal = -1;
5508
+ }
5509
+ /**
5510
+ * 对配置进行排序
5511
+ * @param folderDataConfigList
5512
+ * @param sortName 比较的属性,默认fileName
5513
+ * @param isDesc 是否降序,默认false(升序)
5514
+ */
5515
+ sortFolderConfig(folderDataConfigList, sortName = "fileName", isDesc = false) {
5516
+ if (sortName === "fileName") {
5517
+ // 如果是以文件名排序,文件夹优先放前面
5518
+ let onlyFolderDataConfigList = folderDataConfigList.filter((value) => {
5519
+ return value.isFolder;
5520
+ });
5521
+ let onlyFileDataConfigList = folderDataConfigList.filter((value) => {
5522
+ return !value.isFolder;
5523
+ });
5524
+ // 文件夹排序
5525
+ onlyFolderDataConfigList.sort((leftConfig, rightConfig) => {
5526
+ let beforeVal = leftConfig[sortName].toString();
5527
+ let afterVal = rightConfig[sortName].toString();
5528
+ let compareVal = beforeVal.localeCompare(afterVal);
5529
+ if (isDesc) {
5530
+ /* 降序 */
5531
+ if (compareVal > 0) {
5532
+ compareVal = -1;
5533
+ }
5534
+ else if (compareVal < 0) {
5535
+ compareVal = 1;
5536
+ }
5488
5537
  }
5489
- else if (compareVal < 0) {
5490
- compareVal = 1;
5538
+ return compareVal;
5539
+ });
5540
+ // 文件名排序
5541
+ onlyFileDataConfigList.sort((leftConfig, rightConfig) => {
5542
+ let beforeVal = leftConfig[sortName].toString();
5543
+ let afterVal = rightConfig[sortName].toString();
5544
+ let compareVal = beforeVal.localeCompare(afterVal);
5545
+ if (isDesc) {
5546
+ /* 降序 */
5547
+ if (compareVal > 0) {
5548
+ compareVal = -1;
5549
+ }
5550
+ else if (compareVal < 0) {
5551
+ compareVal = 1;
5552
+ }
5491
5553
  }
5492
- }
5493
- return compareVal;
5494
- });
5495
- // 文件名排序
5496
- onlyFileDataConfigList.sort((leftConfig, rightConfig) => {
5497
- let beforeVal = leftConfig[sortName].toString();
5498
- let afterVal = rightConfig[sortName].toString();
5499
- let compareVal = beforeVal.localeCompare(afterVal);
5554
+ return compareVal;
5555
+ });
5500
5556
  if (isDesc) {
5501
- /* 降序 */
5502
- if (compareVal > 0) {
5503
- compareVal = -1;
5504
- }
5505
- else if (compareVal < 0) {
5506
- compareVal = 1;
5507
- }
5557
+ // 降序,文件夹在下面
5558
+ return [...onlyFileDataConfigList, ...onlyFolderDataConfigList];
5559
+ }
5560
+ else {
5561
+ // 升序,文件夹在上面
5562
+ return [...onlyFolderDataConfigList, ...onlyFileDataConfigList];
5508
5563
  }
5509
- return compareVal;
5510
- });
5511
- if (isDesc) {
5512
- // 降序,文件夹在下面
5513
- return [...onlyFileDataConfigList, ...onlyFolderDataConfigList];
5514
5564
  }
5515
5565
  else {
5516
- // 升序,文件夹在上面
5517
- return [...onlyFolderDataConfigList, ...onlyFileDataConfigList];
5518
- }
5519
- }
5520
- else {
5521
- folderDataConfigList.sort((beforeConfig, afterConfig) => {
5522
- let beforeVal = beforeConfig[sortName];
5523
- let afterVal = afterConfig[sortName];
5524
- if (sortName === "fileSize") {
5525
- /* 文件大小,进行Float转换 */
5526
- beforeVal = parseFloat(beforeVal.toString());
5527
- afterVal = parseFloat(afterVal.toString());
5528
- }
5529
- else if (sortName === "latestTime") {
5530
- /* 文件时间 */
5531
- beforeVal = new Date(beforeVal).getTime();
5532
- afterVal = new Date(afterVal).getTime();
5533
- }
5534
- if (beforeVal > afterVal) {
5535
- if (isDesc) {
5536
- /* 降序 */
5537
- return -1;
5566
+ folderDataConfigList.sort((beforeConfig, afterConfig) => {
5567
+ let beforeVal = beforeConfig[sortName];
5568
+ let afterVal = afterConfig[sortName];
5569
+ if (sortName === "fileSize") {
5570
+ /* 文件大小,进行Float转换 */
5571
+ beforeVal = parseFloat(beforeVal.toString());
5572
+ afterVal = parseFloat(afterVal.toString());
5538
5573
  }
5539
- else {
5540
- return 1;
5574
+ else if (sortName === "latestTime") {
5575
+ /* 文件时间 */
5576
+ beforeVal = new Date(beforeVal).getTime();
5577
+ afterVal = new Date(afterVal).getTime();
5541
5578
  }
5542
- }
5543
- else if (beforeVal < afterVal) {
5544
- if (isDesc) {
5545
- /* 降序 */
5546
- return 1;
5579
+ if (beforeVal > afterVal) {
5580
+ if (isDesc) {
5581
+ /* 降序 */
5582
+ return -1;
5583
+ }
5584
+ else {
5585
+ return 1;
5586
+ }
5587
+ }
5588
+ else if (beforeVal < afterVal) {
5589
+ if (isDesc) {
5590
+ /* 降序 */
5591
+ return 1;
5592
+ }
5593
+ else {
5594
+ return -1;
5595
+ }
5547
5596
  }
5548
5597
  else {
5549
- return -1;
5598
+ return 0;
5550
5599
  }
5600
+ });
5601
+ return folderDataConfigList;
5602
+ }
5603
+ }
5604
+ /**
5605
+ * 添加文件夹/文件行元素
5606
+ * @param dataConfig 配置
5607
+ */
5608
+ initFolderView(dataConfig) {
5609
+ // 先对文件夹、文件进行排序
5610
+ this.sortFolderConfig(dataConfig, config.sort.name, config.sort.isDesc);
5611
+ dataConfig.forEach((item) => {
5612
+ if (item.isFolder) {
5613
+ let { folderElement, fileNameElement } = popsUtils.isPhone()
5614
+ ? this.createFolderRowElementByMobile(item.fileName, "", "", true)
5615
+ : this.createFolderRowElement(item.fileName, "", "", true);
5616
+ // 文件夹 - 点击事件
5617
+ popsDOMUtils.on(fileNameElement, "click", (event) => {
5618
+ // 进入文件夹
5619
+ this.enterFolder(event, item);
5620
+ });
5621
+ folderListBodyElement.appendChild(folderElement);
5551
5622
  }
5552
5623
  else {
5553
- return 0;
5624
+ let { folderElement, fileNameElement } = popsUtils.isPhone()
5625
+ ? this.createFolderRowElementByMobile(item.fileName, item.latestTime, item.fileSize, false)
5626
+ : this.createFolderRowElement(item.fileName, item.latestTime, item.fileSize, false);
5627
+ // 文件 - 点击事件
5628
+ popsDOMUtils.on(fileNameElement, "click", (event) => {
5629
+ // 下载文件
5630
+ this.downloadFile(event, fileNameElement, item);
5631
+ });
5632
+ folderListBodyElement.appendChild(folderElement);
5554
5633
  }
5555
5634
  });
5556
- return folderDataConfigList;
5557
5635
  }
5558
- }
5559
- /**
5560
- * 添加元素
5561
- * @param _config_
5562
- */
5563
- function addFolderElement(_config_) {
5564
- sortFolderConfig(_config_, config.sort.name, config.sort.isDesc);
5565
- _config_.forEach((item) => {
5566
- if (item["isFolder"]) {
5567
- let { folderELement, fileNameElement } = popsUtils.isPhone()
5568
- ? createMobileFolderRowElement(item["fileName"], "", "", true)
5569
- : createFolderRowElement(item["fileName"], "", "", true);
5570
- popsDOMUtils.on(fileNameElement, "click", (event) => {
5571
- refreshFolderInfoClickEvent(event, item);
5572
- });
5573
- folderListBodyElement.appendChild(folderELement);
5636
+ /**
5637
+ * 移除所有箭头的被访问状态
5638
+ */
5639
+ removeArrowActiveStatus() {
5640
+ [
5641
+ ...Array.from(folderListSortFileNameElement.querySelectorAll(".pops-folder-icon-active")),
5642
+ ...Array.from(folderListSortLatestTimeElement.querySelectorAll(".pops-folder-icon-active")),
5643
+ ...Array.from(folderListSortFileSizeElement.querySelectorAll(".pops-folder-icon-active")),
5644
+ ].forEach((ele) => ele.classList.remove("pops-folder-icon-active"));
5645
+ }
5646
+ /**
5647
+ * 修改导航箭头的状态
5648
+ */
5649
+ changeArrowActive(arrowUp, arrowDown, isDesc) {
5650
+ this.removeArrowActiveStatus();
5651
+ if (isDesc) {
5652
+ arrowDown.classList.add("pops-folder-icon-active");
5574
5653
  }
5575
5654
  else {
5576
- let { folderELement, fileNameElement } = popsUtils.isPhone()
5577
- ? createMobileFolderRowElement(item["fileName"], item.latestTime, item.fileSize, false)
5578
- : createFolderRowElement(item["fileName"], item.latestTime, item.fileSize, false);
5579
- setFileClickEvent(fileNameElement, item);
5580
- folderListBodyElement.appendChild(folderELement);
5655
+ arrowUp.classList.add("pops-folder-icon-active");
5581
5656
  }
5582
- });
5583
- }
5584
- addFolderElement(config.folder);
5585
- /* 将数据存到全部文件的属性_config_中 */
5586
- let allFilesElement = folderFileListBreadcrumbPrimaryElement.querySelector(".pops-folder-list .pops-folder-file-list-breadcrumb-allFiles:first-child");
5587
- allFilesElement._config_ = config.folder;
5588
- /* 设置点击顶部的全部文件事件 */
5589
- popsDOMUtils.on(allFilesElement, "click", (event) => {
5590
- breadcrumbAllFilesElementClickEvent(event, true, config.folder);
5591
- });
5592
- /* 移除所有的当前排序的arrow */
5593
- function removeAllArrowActive() {
5594
- [
5595
- ...Array.from(folderListSortFileNameElement.querySelectorAll(".pops-folder-icon-active")),
5596
- ...Array.from(folderListSortLatestTimeElement.querySelectorAll(".pops-folder-icon-active")),
5597
- ...Array.from(folderListSortFileSizeElement.querySelectorAll(".pops-folder-icon-active")),
5598
- ].forEach((ele) => ele.classList.remove("pops-folder-icon-active"));
5599
- }
5600
- /* 设置当前的排序的arrow */
5601
- function changeArrowActive(arrowUp, arrowDown, isDesc) {
5602
- removeAllArrowActive();
5603
- if (isDesc) {
5604
- arrowDown.classList.add("pops-folder-icon-active");
5605
- }
5606
- else {
5607
- arrowUp.classList.add("pops-folder-icon-active");
5608
5657
  }
5609
- }
5610
- /**
5611
- * 排序按钮的点击事件
5612
- * @param {PointerEvent} target
5613
- * @param {HTMLElement} event
5614
- * @param {string} sortName
5615
- */
5616
- function arrowSortClickEvent(target, event, sortName) {
5617
- if (!event["notChangeSortRule"]) {
5618
- config.sort.name = sortName;
5619
- config.sort.isDesc = !config.sort.isDesc;
5620
- }
5621
- let arrowUp = target.querySelector(".pops-folder-icon-arrow-up");
5622
- let arrowDown = target.querySelector(".pops-folder-icon-arrow-down");
5623
- changeArrowActive(arrowUp, arrowDown, config.sort.isDesc);
5624
- if (typeof config.sort.callback === "function" &&
5625
- config.sort.callback(target, event, config.sort.name, config.sort.isDesc)) {
5626
- return;
5658
+ /**
5659
+ * 排序按钮的点击事件
5660
+ * @param target
5661
+ * @param event
5662
+ * @param sortName
5663
+ */
5664
+ arrowToSortFolderInfoView(target, event, sortName) {
5665
+ const notChangeSortRule = Reflect.get(event, "notChangeSortRule");
5666
+ if (!notChangeSortRule) {
5667
+ config.sort.name = sortName;
5668
+ config.sort.isDesc = !config.sort.isDesc;
5669
+ }
5670
+ let arrowUp = target.querySelector(".pops-folder-icon-arrow-up");
5671
+ let arrowDown = target.querySelector(".pops-folder-icon-arrow-down");
5672
+ this.changeArrowActive(arrowUp, arrowDown, config.sort.isDesc);
5673
+ if (typeof config.sort.callback === "function" &&
5674
+ config.sort.callback(target, event, config.sort.name, config.sort.isDesc)) {
5675
+ return;
5676
+ }
5677
+ let childrenList = [];
5678
+ Array.from(folderListBodyElement.children).forEach((trElement) => {
5679
+ let __value__ = Reflect.get(trElement, "__value__");
5680
+ Reflect.set(__value__, "target", trElement);
5681
+ childrenList.push(__value__);
5682
+ });
5683
+ let sortedConfigList = this.sortFolderConfig(childrenList, config.sort.name, config.sort.isDesc);
5684
+ sortedConfigList.forEach((item) => {
5685
+ folderListBodyElement.appendChild(item.target);
5686
+ });
5627
5687
  }
5628
- let childrenList = [];
5629
- Array.from(folderListBodyElement.children).forEach((trElement) => {
5630
- let __value__ = trElement["__value__"];
5631
- __value__["target"] = trElement;
5632
- childrenList.push(__value__);
5633
- });
5634
- let sortedConfigList = sortFolderConfig(childrenList, config.sort.name, config.sort.isDesc);
5635
- sortedConfigList.forEach((item) => {
5636
- folderListBodyElement.appendChild(item.target);
5637
- });
5638
- }
5639
- /* 设置当前排序的图标按钮 */
5640
- popsDOMUtils.on(folderListSortFileNameElement.closest("th"), "click", function (event) {
5641
- arrowSortClickEvent(folderListSortFileNameElement, event, "fileName");
5642
- }, {
5643
- capture: true,
5644
- });
5645
- popsDOMUtils.on(folderListSortLatestTimeElement.closest("th"), "click", void 0, function (event) {
5646
- arrowSortClickEvent(folderListSortLatestTimeElement, event, "latestTime");
5647
- }, {
5648
- capture: true,
5649
- });
5650
- popsDOMUtils.on(folderListSortFileSizeElement.closest("th"), "click", void 0, function (event) {
5651
- arrowSortClickEvent(folderListSortFileSizeElement, event, "fileSize");
5652
- }, {
5653
- capture: true,
5654
- });
5655
- /* 设置默认触发的arrow */
5656
- if (config.sort.name === "fileName") {
5657
- popsDOMUtils.trigger(folderListSortFileNameElement, "click", {
5658
- notChangeSortRule: true,
5659
- });
5660
- }
5661
- else if (config.sort.name === "latestTime") {
5662
- popsDOMUtils.trigger(folderListSortLatestTimeElement, "click", {
5663
- notChangeSortRule: true,
5664
- });
5665
- }
5666
- else if (config.sort.name === "fileSize") {
5667
- popsDOMUtils.trigger(folderListSortFileSizeElement, "click", {
5668
- notChangeSortRule: true,
5669
- });
5670
5688
  }
5689
+ const popsFolder = new PopsFolder();
5690
+ popsFolder.init();
5691
+ Reflect.set($pops, "data-pops-folder", popsFolder);
5671
5692
  /* 拖拽 */
5672
5693
  if (config.drag) {
5673
5694
  PopsInstanceUtils.drag($pops, {
@@ -11624,7 +11645,7 @@ define((function () { 'use strict';
11624
11645
  /** 配置 */
11625
11646
  config = {
11626
11647
  /** 版本号 */
11627
- version: "2025.8.17",
11648
+ version: "2025.8.30",
11628
11649
  cssText: PopsCSS,
11629
11650
  /** icon图标的svg代码 */
11630
11651
  iconSVG: PopsIcon.$data,