text: /**
   * @author zhixin wen <wenzhixin2010@gmail.com>
   * extensions: https://github.com/kayalshri/tableExport.jquery.plugin
   */
  
  (function ($) {
      'use strict';
  
      var TYPE_NAME = {
          json: 'JSON',
          xml: 'XML',
          png: 'PNG',
          csv: 'CSV',
          txt: 'TXT',
          sql: 'SQL',
          doc: 'MS-Word',
          excel: 'MS-Excel',
          powerpoint: 'MS-Powerpoint',
          pdf: 'PDF'
      };
  
      $.extend($.fn.bootstrapTable.defaults, {
          showExport: false,
          // 'json', 'xml', 'png', 'csv', 'txt', 'sql', 'doc', 'excel', 'powerpoint', 'pdf'
          exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel']
      });
  
      var BootstrapTable = $.fn.bootstrapTable.Constructor,
          _initToolbar = BootstrapTable.prototype.initToolbar;
  
      BootstrapTable.prototype.initToolbar = function () {
          _initToolbar.apply(this, Array.prototype.slice.apply(arguments));
  
          if (this.options.showExport) {
              var that = this,
                  $btnGroup = this.$toolbar.find('>.btn-group'),
                  $export = $btnGroup.find('div.export');
  
              if (!$export.length) {
                  $export = $([
                      '<div class="export btn-group">',
                          '<button class="btn btn-default dropdown-toggle" ' +
                              'data-toggle="dropdown" type="button">',
                              '<i class="fa fa-download icon-th"></i> ',
                              '<span class="caret"></span>',
                          '</button>',
                          '<ul class="dropdown-menu" role="menu">',
                          '</ul>',
                      '</div>'].join('')).appendTo($btnGroup);
  
                  var $menu = $export.find('.dropdown-menu'),
                      exportTypes = this.options.exportTypes;
  
                  if (typeof this.options.exportTypes === 'string') {
                      var types = this.options.exportTypes.slice(1, -1).replace(/ /g, '').split(',');
  
                      exportTypes = [];
                      $.each(types, function (i, value) {
                          exportTypes.push(value.slice(1, -1));
                      });
                  }
                  $.each(exportTypes, function (i, type) {
                      if (TYPE_NAME.hasOwnProperty(type)) {
                          $menu.append(['<li data-type="' + type + '">',
                                  '<a href="javascript:void(0)">',
                                      TYPE_NAME[type],
                                  '</a>',
                              '</li>'].join(''));
                      }
                  });
  
                  $menu.find('li').click(function () {
                      var $this = $(this);
                       if ($('#select-list input[type=checkbox]:checked').length > 0) {
                          that.$el.tableExport({
                              type: $this.data('type'), 
                              escape: false,
                              onlyChecked: true
                          });
                      } else {
                          $( document ).ajaxComplete(function( event, request, settings ) {
                              if (settings.url.indexOf("/ref/admin/users/api/list.json") > -1) { 
                                  that.$el.tableExport({
                                      type: $this.data('type'), 
                                      escape: false
                                  });
                                  $(event.currentTarget).unbind('ajaxComplete');
                              }
                          });
                          $('.page-list ul li:last a').trigger('click');
                      }
                  });
              }
          }
      };
  })(jQuery);