Browse Source

Added loadingFontSize option

zhixin 5 years ago
parent
commit
f6d5e28f6d
3 changed files with 22 additions and 4 deletions
  1. 13 0
      site/docs/api/table-options.md
  2. 8 4
      src/bootstrap-table.js
  3. 1 0
      src/constants/index.js

+ 13 - 0
site/docs/api/table-options.md

@@ -602,6 +602,19 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
 
 - **Example:** [Table Locale](https://examples.bootstrap-table.com/#options/table-locale.html)
 
+## loadingFontSize
+
+- **Attribute:** `data-loading-font-size`
+
+- **Type:** `String`
+
+- **Detail:**
+
+  To define the font size of the loading text, the default value is `'auto'`, it will be calculated automatically according to the table width, between 12px and 32px.
+
+- **Default:** `'auto'`
+
+- **Example:** [Loading Font Size](https://examples.bootstrap-table.com/#options/loading-font-size.html)
 
 ## loadingTemplate
 

+ 8 - 4
src/bootstrap-table.js

@@ -2696,12 +2696,16 @@ class BootstrapTable {
   showLoading () {
     this.$tableLoading.css('display', 'flex')
 
-    let fontSize = this.$tableLoading.width() * 0.04
+    let fontSize = this.options.loadingFontSize
 
-    fontSize = Math.max(12, fontSize)
-    fontSize = Math.min(32, fontSize)
+    if (this.options.loadingFontSize === 'auto') {
+      fontSize = this.$tableLoading.width() * 0.04
+      fontSize = Math.max(12, fontSize)
+      fontSize = Math.min(32, fontSize)
+      fontSize = `${fontSize}px`
+    }
 
-    this.$tableLoading.find('.loading-text').css('font-size', `${fontSize}px`)
+    this.$tableLoading.find('.loading-text').css('font-size', fontSize)
   }
 
   hideLoading () {

+ 1 - 0
src/constants/index.js

@@ -236,6 +236,7 @@ const DEFAULTS = {
   html: CONSTANTS.html,
   iconSize: undefined,
   iconsPrefix: CONSTANTS.iconsPrefix, // glyphicon or fa(font-awesome)
+  loadingFontSize: 'auto',
   loadingTemplate (loadingMessage) {
     return `<span class="loading-wrap">
       <span class="loading-text">${loadingMessage}</span>