Browse Source

Merge branch 'develop' into fix/4577

Dustin Utecht 6 years ago
parent
commit
dd63b8be43

+ 15 - 1
.npmignore

@@ -1,2 +1,16 @@
-tools
+_gh_pages
+.github
+.sass-cache
 site
 site
+tools
+_config.yml
+.browserslistrc
+.eslintrc.js
+.stylelintrc
+.travis.yml
+CONTRIBUTING.md
+deploy_key.enc
+deploy.sh
+DONATORS.md
+Gemfile
+Gemfile.lock

+ 0 - 6
site/_includes/docs-navbar.html

@@ -33,11 +33,6 @@
           Online Editor
           Online Editor
         </a>
         </a>
       </li>
       </li>
-      <li class="nav-item {% if page.title == "Donate" %}active{% endif %}">
-        <a class="nav-link" href="{{ site.baseurl }}/donate">
-          Donate
-        </a>
-      </li>
       <li class="nav-item {% if page.title == "News" %}active{% endif %}">
       <li class="nav-item {% if page.title == "News" %}active{% endif %}">
         <a class="nav-link" href="{{ site.baseurl }}/news">
         <a class="nav-link" href="{{ site.baseurl }}/news">
           News
           News
@@ -48,7 +43,6 @@
           href="https://blog.bootstrap-table.com"
           href="https://blog.bootstrap-table.com"
           target="_blank">
           target="_blank">
           Blog
           Blog
-          <span class="badge badge-warning">New</span>
         </a>
         </a>
       </li>
       </li>
     </ul>
     </ul>

+ 3 - 1
site/docs/api/events.md

@@ -191,6 +191,8 @@ $('#table').on('event-name.bs.table', function (e, arg1, arg2, ...) {
   Fires when remote data is loaded successfully, the parameters contain:
   Fires when remote data is loaded successfully, the parameters contain:
 
 
   * `data`: the remote data.
   * `data`: the remote data.
+  * `status`: the status code of `jqXHR` (from 1.15.5).
+  * `jqXHR`: jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the [jqXHR Type](http://api.jquery.com/Types/#jqXHR) (from 1.15.5).
 
 
 ## onLoadError
 ## onLoadError
 
 
@@ -367,7 +369,7 @@ $('#table').on('event-name.bs.table', function (e, arg1, arg2, ...) {
 
 
 - **jQuery Event:** `scroll-body.bs.table`
 - **jQuery Event:** `scroll-body.bs.table`
 
 
-- **Parameter:**: `undefined`
+- **Parameter:**: `$tableBody` (from 1.15.5)
 
 
 - **Detail:**
 - **Detail:**
 
 

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

@@ -471,6 +471,7 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
   Before load remote data, handler the response data format, the parameters object contains:
   Before load remote data, handler the response data format, the parameters object contains:
 
 
   * `res`: the response data.
   * `res`: the response data.
+  * `jqXHR`: jqXHR object, which is a superset of the XMLHTTPRequest object. For more information, see the [jqXHR Type](http://api.jquery.com/Types/#jqXHR) (from 1.15.5).
 
 
 - **Default:** `function(res) { return res }`
 - **Default:** `function(res) { return res }`
 
 

+ 0 - 60
site/donate.md

@@ -1,60 +0,0 @@
----
-layout: simple
-title: Donate
-description: If you like Bootstrap Table, if your project uses Bootstrap Table, if you want Bootstrap Table do better...
-redirect_from:
-  - "/zh-cn/donate/"
-  - "/es/donate/"
----
-
-Bootstrap Table is an MIT licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing. You can support Bootstrap Table development via the following methods:
-
-<table class="table donate">
-<tbody>
-  <tr>
-    <td width="200"><h3>Give us a Star<br>⭐️⭐️⭐️</h3></td>
-    <td><img src="{{ site.base_url }}/assets/images/paypalLogo.png"></td>
-    <td><img src="{{ site.base_url }}/assets/images/alipayLogo.png"></td>
-    <td><img src="{{ site.base_url }}/assets/images/weixinLogo.png"></td>
-    <td><h3>Share The Love</h3></td>
-  </tr>
-  <tr>
-    <td>
-      <a class="github-button" href="https://github.com/wenzhixin/bootstrap-table" data-size="large" data-show-count="true" aria-label="Star wenzhixin/bootstrap-table on GitHub">Star</a>
-    </td>
-    <td>
-      <a class="paypal" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZDHP676FQDUT6">
-        <img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif">
-      </a>
-    </td>
-    <td><img src="{{ site.base_url }}/assets/images/alipay.jpg"></td>
-    <td><img src="{{ site.base_url }}/assets/images/weixin.png"></td>
-    <td>
-      <span style="color: silver;">Share on: </span>
-      <div id="share-buttons">
-        <a class="twitter" href="http://twitter.com/home?status={{ site.url }}" target="_blank" title="Share this on Twitter">
-          {% include icons/twitter.svg %}
-        </a>
-
-        <a class="facebook" href="http://www.facebook.com/share.php?u={{ site.url }}" target="_blank" title="Share this on Facebook">
-          {% include icons/facebook.svg %}
-        </a>
-
-        <a class="linkedin" href="https://www.linkedin.com/shareArticle?mini=true&amp;url={{ site.url }}&amp;title=&amp;summary=&amp;source=" target="_blank" title="Share this on Linkedin">
-          {% include icons/linkedin.svg %}
-        </a>
-
-        <a class="mail" href="mailto:?&amp;body={{ site.url }}" target="_blank" title="Share this through Email">
-          {% include icons/mail.svg %}
-        </a>
-      </div>
-
-      <p class="share-desc">
-      If you like Bootstrap Table, but you do not have any money to spare, please share the love by posting something about this website on social media. You can use the buttons above. They will share the homepage. Thank you, you are the best!
-      </p>
-    </td>
-  </tr>
-</tbody>
-</table>
-
-{% include opencollective.html %}

+ 37 - 22
src/bootstrap-table.js

@@ -646,7 +646,9 @@ class BootstrapTable {
         o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.clearSearch) : '',
         o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.clearSearch) : '',
         o.showButtonText ? o.formatClearSearch() : ''
         o.showButtonText ? o.formatClearSearch() : ''
       )
       )
-      const searchInputHtml = `<input class="${this.constants.classes.input}${Utils.sprintf(' input-%s', o.iconSize)} search-input" type="text" placeholder="${o.formatSearch()}">`
+      const searchInputHtml = `<input class="${this.constants.classes.input}
+        ${Utils.sprintf(' %s%s', this.constants.classes.inputPrefix, o.iconSize)}
+        search-input" type="text" placeholder="${o.formatSearch()}">`
       let searchInputFinalHtml = searchInputHtml
       let searchInputFinalHtml = searchInputHtml
 
 
       if (o.showSearchButton || o.showSearchClearButton) {
       if (o.showSearchButton || o.showSearchClearButton) {
@@ -665,25 +667,38 @@ class BootstrapTable {
 
 
       this.$toolbar.append(html.join(''))
       this.$toolbar.append(html.join(''))
       const $searchInput = this.$toolbar.find('.search input')
       const $searchInput = this.$toolbar.find('.search input')
-      $search = o.showSearchButton ? this.$toolbar.find('.search button[name=search]') : $searchInput
+      const handleInputEvent = () => {
+        const eventTriggers = Utils.isIEBrowser() ? 'mouseup' : 'keyup drop blur'
+        $searchInput.off(eventTriggers).on(eventTriggers, event => {
+          if (o.searchOnEnterKey && event.keyCode !== 13) {
+            return
+          }
 
 
-      const eventTriggers = o.showSearchButton ? 'click' :
-        (Utils.isIEBrowser() ? 'mouseup' : 'keyup drop blur')
+          if ([37, 38, 39, 40].includes(event.keyCode)) {
+            return
+          }
 
 
-      $search.off(eventTriggers).on(eventTriggers, event => {
-        if (o.searchOnEnterKey && event.keyCode !== 13) {
-          return
-        }
+          clearTimeout(timeoutId) // doesn't matter if it's 0
+          timeoutId = setTimeout(() => {
+            this.onSearch(event)
+          }, o.searchTimeOut)
+        })
+      }
 
 
-        if ([37, 38, 39, 40].includes(event.keyCode)) {
-          return
-        }
+      if (o.showSearchButton) {
+        this.$toolbar.find('.search button[name=search]').off('click').on('click', event => {
+          clearTimeout(timeoutId) // doesn't matter if it's 0
+          timeoutId = setTimeout(() => {
+            this.onSearch({currentTarget: $searchInput})
+          }, o.searchTimeOut)
+        })
 
 
-        clearTimeout(timeoutId) // doesn't matter if it's 0
-        timeoutId = setTimeout(() => {
-          this.onSearch(o.showSearchButton ? {currentTarget: $searchInput} : event)
-        }, o.searchTimeOut)
-      })
+        if (o.searchOnEnterKey) {
+          handleInputEvent()
+        }
+      } else {
+        handleInputEvent()
+      }
 
 
       if (o.showSearchClearButton) {
       if (o.showSearchClearButton) {
         this.$toolbar.find('.search button[name=clearSearch]').click(() => {
         this.$toolbar.find('.search button[name=clearSearch]').click(() => {
@@ -1444,7 +1459,7 @@ class BootstrapTable {
       const item = this.data[rowIndex]
       const item = this.data[rowIndex]
       const index = this.options.cardView ? $cardViewArr.index($cardViewTarget) : $td[0].cellIndex
       const index = this.options.cardView ? $cardViewArr.index($cardViewTarget) : $td[0].cellIndex
       const fields = this.getVisibleFields()
       const fields = this.getVisibleFields()
-      const field = fields[this.options.detailView && this.detailViewIcon && !this.options.cardView ? index - 1 : index]
+      const field = fields[this.options.detailView && this.options.detailViewIcon && !this.options.cardView ? index - 1 : index]
       const column = this.columns[this.fieldsColumnsIndex[field]]
       const column = this.columns[this.fieldsColumnsIndex[field]]
       const value = Utils.getItemField(item, field, this.options.escape)
       const value = Utils.getItemField(item, field, this.options.escape)
 
 
@@ -1612,12 +1627,12 @@ class BootstrapTable {
       cache: this.options.cache,
       cache: this.options.cache,
       contentType: this.options.contentType,
       contentType: this.options.contentType,
       dataType: this.options.dataType,
       dataType: this.options.dataType,
-      success: _res => {
+      success: (_res, textStatus, jqXHR) => {
         const res = Utils.calculateObjectValue(this.options,
         const res = Utils.calculateObjectValue(this.options,
-          this.options.responseHandler, [_res], _res)
+          this.options.responseHandler, [_res, jqXHR], _res)
 
 
         this.load(res)
         this.load(res)
-        this.trigger('load-success', res)
+        this.trigger('load-success', res, jqXHR.status, jqXHR)
         if (!silent) {
         if (!silent) {
           this.hideLoading()
           this.hideLoading()
         }
         }
@@ -1909,8 +1924,6 @@ class BootstrapTable {
   horizontalScroll () {
   horizontalScroll () {
     // horizontal scroll event
     // horizontal scroll event
     // TODO: it's probably better improving the layout than binding to scroll event
     // TODO: it's probably better improving the layout than binding to scroll event
-
-    this.trigger('scroll-body')
     this.$tableBody.off('scroll').on('scroll', ({currentTarget}) => {
     this.$tableBody.off('scroll').on('scroll', ({currentTarget}) => {
       if (this.options.showHeader && this.options.height) {
       if (this.options.showHeader && this.options.height) {
         this.$tableHeader.scrollLeft($(currentTarget).scrollLeft())
         this.$tableHeader.scrollLeft($(currentTarget).scrollLeft())
@@ -1919,6 +1932,8 @@ class BootstrapTable {
       if (this.options.showFooter && !this.options.cardView) {
       if (this.options.showFooter && !this.options.cardView) {
         this.$tableFooter.scrollLeft($(currentTarget).scrollLeft())
         this.$tableFooter.scrollLeft($(currentTarget).scrollLeft())
       }
       }
+
+      this.trigger('scroll-body', $(currentTarget))
     })
     })
   }
   }
 
 

+ 2 - 0
src/constants/index.js

@@ -36,6 +36,7 @@ const CONSTANTS = {
       buttonsDropdown: 'btn-group',
       buttonsDropdown: 'btn-group',
       pull: 'pull',
       pull: 'pull',
       inputGroup: 'input-group',
       inputGroup: 'input-group',
+      inputPrefix: 'input-',
       input: 'form-control',
       input: 'form-control',
       paginationDropdown: 'btn-group dropdown',
       paginationDropdown: 'btn-group dropdown',
       dropup: 'dropup',
       dropup: 'dropup',
@@ -81,6 +82,7 @@ const CONSTANTS = {
       buttonsDropdown: 'btn-group',
       buttonsDropdown: 'btn-group',
       pull: 'float',
       pull: 'float',
       inputGroup: 'btn-group',
       inputGroup: 'btn-group',
+      inputPrefix: 'form-control-',
       input: 'form-control',
       input: 'form-control',
       paginationDropdown: 'btn-group dropdown',
       paginationDropdown: 'btn-group dropdown',
       dropup: 'dropup',
       dropup: 'dropup',

+ 38 - 20
src/extensions/export/bootstrap-table-export.js

@@ -86,7 +86,25 @@ $.BootstrapTable = class extends $.BootstrapTable {
 
 
     let $menu = $(this.constants.html.toolbarDropdown.join(''))
     let $menu = $(this.constants.html.toolbarDropdown.join(''))
 
 
-    this.$export = $(`
+    let exportTypes = o.exportTypes
+
+    if (typeof exportTypes === 'string') {
+      const types = exportTypes.slice(1, -1).replace(/ /g, '').split(',')
+      exportTypes = types.map(t => t.slice(1, -1))
+    }
+
+    this.$export = $(exportTypes.length === 1 ? `
+      <div class="export ${this.constants.classes.buttonsDropdown}"
+      data-type="${exportTypes[0]}">
+      <button class="${this.constants.buttonsClass}"
+      aria-label="Export"
+      type="button"
+      title="${o.formatExport()}">
+      ${o.showButtonIcons ? Utils.sprintf(this.constants.html.icon, o.iconsPrefix, o.icons.export) : ''}
+      ${o.showButtonText ? o.formatExport() : ''}
+      </button>
+      </div>
+    ` : `
       <div class="export ${this.constants.classes.buttonsDropdown}">
       <div class="export ${this.constants.classes.buttonsDropdown}">
       <button class="${this.constants.buttonsClass} dropdown-toggle"
       <button class="${this.constants.buttonsClass} dropdown-toggle"
       aria-label="Export"
       aria-label="Export"
@@ -99,31 +117,31 @@ $.BootstrapTable = class extends $.BootstrapTable {
       </button>
       </button>
       </div>
       </div>
     `).appendTo($btnGroup)
     `).appendTo($btnGroup)
-    this.$export.append($menu)
 
 
-    this.updateExportButton()
-
-    let exportTypes = o.exportTypes
+    let $items = this.$export
 
 
-    if (typeof exportTypes === 'string') {
-      const types = exportTypes.slice(1, -1).replace(/ /g, '').split(',')
-      exportTypes = types.map(t => t.slice(1, -1))
-    }
+    if (exportTypes.length > 1) {
+      this.$export.append($menu)
 
 
-    // themes support
-    if ($menu.children().length) {
-      $menu = $menu.children().eq(0)
-    }
-    for (const type of exportTypes) {
-      if (TYPE_NAME.hasOwnProperty(type)) {
-        const $item = $(Utils.sprintf(this.constants.html.pageDropdownItem,
-          '', TYPE_NAME[type]))
-        $item.attr('data-type', type)
-        $menu.append($item)
+      // themes support
+      if ($menu.children().length) {
+        $menu = $menu.children().eq(0)
+      }
+      for (const type of exportTypes) {
+        if (TYPE_NAME.hasOwnProperty(type)) {
+          const $item = $(Utils.sprintf(this.constants.html.pageDropdownItem,
+            '', TYPE_NAME[type]))
+          $item.attr('data-type', type)
+          $menu.append($item)
+        }
       }
       }
+
+      $items = $menu.children()
     }
     }
 
 
-    $menu.children().click(e => {
+    this.updateExportButton()
+
+    $items.click(e => {
       e.preventDefault()
       e.preventDefault()
 
 
       const type = $(e.currentTarget).data('type')
       const type = $(e.currentTarget).data('type')