Contact Form Entries – Contact Form 7, WPforms and more - Version 1.1.1

Version Description

  • fixed "per-page" option in front end entries table.
Download this release

Release Info

Developer CRMPerks
Plugin Icon 128x128 Contact Form Entries – Contact Form 7, WPforms and more
Version 1.1.1
Comparing to
See all releases

Code changes from version 1.1.0 to 1.1.1

contact-form-entries.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Contact Form Entries
4
  * Description: Save form submissions to the database from <a href="https://wordpress.org/plugins/contact-form-7/">Contact Form 7</a>, <a href="https://wordpress.org/plugins/jetpack/">JetPack Contact Form</a>, <a href="https://wordpress.org/plugins/ninja-forms/">Ninja Forms</a>, <a href="https://wordpress.org/plugins/formidable/">Formidable Forms</a>, <a href="http://codecanyon.net/item/quform-wordpress-form-builder/706149">Quform</a>, <a href="https://wordpress.org/plugins/cforms2/">cformsII</a>, <a href="https://wordpress.org/plugins/contact-form-plugin/">Contact Form by BestWebSoft</a>, <a href="https://wordpress.org/plugins/ultimate-form-builder-lite/">Ultimate Form Builder</a>, <a href="https://wordpress.org/plugins/caldera-forms/">Caldera Forms</a> and <a href="https://wordpress.org/plugins/wpforms-lite/">WP Forms</a>.
5
- * Version: 1.1.0
6
  * Requires at least: 3.8
7
  * Tested up to: 5.4
8
  * Author URI: https://www.crmperks.com
@@ -26,7 +26,7 @@ class vxcf_form {
26
  public static $type = "vxcf_form";
27
  public static $path = '';
28
 
29
- public static $version = '1.1.0';
30
  public static $upload_folder = 'crm_perks_uploads';
31
  public static $db_version='';
32
  public static $base_url='';
@@ -45,6 +45,7 @@ class vxcf_form {
45
  public static $forms;
46
  public static $form_id;
47
  public static $user_id;
 
48
  public static $form_id_string;
49
  public static $form_fields;
50
  public static $form_fields_temp;
@@ -64,11 +65,13 @@ add_action('init', array($this,'init'));
64
  add_filter('crmperks_forms_field_validation_message',array($this,'validate_crmperks_field'),10,4);
65
  }
66
 
 
67
  public function init(){
68
  //save screen and url for all forms
69
  add_action('wp_footer', array($this,'footer_js'),33);
70
- wp_register_script( 'vx-tablesorter-js', self::$base_url. 'js/jquery.tablesorter.min.js',array('jquery') );
71
  wp_register_script( 'vx-tablepager-js', self::$base_url. 'js/jquery.tablesorter.pager.js',array('jquery') );
 
72
 
73
  //$fields=$this->get_form_fields('wp_118');
74
  //$form=cfx_form::get_form('1'); var_dump($form['fields']); die();
@@ -97,7 +100,7 @@ public function setup_main(){
97
  add_action('ufbl_email_send', array(&$this, 'create_entry_ul'),30);
98
  add_action('grunion_pre_message_sent', array(&$this, 'create_entry_jp'),30,3);
99
  add_filter('crmperks_forms_new_submission', array(&$this, 'create_entry_vf'),40,3);
100
- add_action( 'woocommerce_checkout_update_order_meta',array(&$this,'create_entry_wc'), 30, 2 );
101
  add_action( 'wpforms_process_entry_save',array(&$this,'create_entry_wp'), 30, 4 );
102
  // add_action('cntctfrm_get_attachment_data', array(&$this, 'create_entry_be'),30);
103
  // add_filter('si_contact_email_fields_posted', array($this, 'test'),10,2);
@@ -150,14 +153,25 @@ require_once(self::$path . "includes/crmperks-cf.php");
150
  require_once(self::$path . "includes/plugin-pages.php");
151
  self::$pages=new vxcf_form_pages();
152
  $pro_file=self::$path . 'pro/pro.php';
153
- if(file_exists($pro_file)){ include_once($pro_file); }
154
  $pro_file=self::$path . 'pro/add-ons.php';
155
  if(file_exists($pro_file)){ include_once($pro_file); }
156
  $pro_file=self::$path . 'wp/crmperks-notices.php';
157
  if(file_exists($pro_file)){ include_once($pro_file); }
158
  //$forms=vxcf_form::get_forms();
159
  }
160
-
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
 
163
 
@@ -249,10 +263,25 @@ vxcf_form::$form_fields=$fields;
249
  $start='0';
250
  if(!empty($atts['start'])){
251
  $start=$atts['start'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  }
253
  $page_size='3';
254
- if(!empty($atts['page-size'])){
255
- $page_size=$atts['page-size'];
256
  }
257
  $offset=$this->time_offset();
258
  $req=array('start'=>$start,'vx_links'=>'false');
@@ -260,7 +289,7 @@ vxcf_form::$form_fields=$fields;
260
  $req['user_id']=!empty($atts['user-id']) ? (int)$atts['user-id'] : get_current_user_id();
261
  }
262
  $data=vxcf_form::get_data_object();
263
- $entries=$data->get_entries($form_id,$limit,$req);
264
  $leads=array();
265
  if(!empty($entries['result'])){
266
  $leads=$entries['result'];
@@ -269,11 +298,13 @@ $leads=$entries['result'];
269
  $base_url=vxcf_form::get_base_url();
270
  if(!empty($atts['sortable'])){
271
  wp_enqueue_script( 'vx-tablesorter-js');
 
272
  if(!empty($atts['pager'])){
273
  wp_enqueue_script( 'vx-tablepager-js');
274
  }
275
  wp_enqueue_style('vx-tablesorter-css');
276
  }
 
277
  /* foreach($leads as $lead){
278
 
279
  foreach($fields as $field){
@@ -299,7 +330,7 @@ $field_label= date('M-d-Y H:i:s',$field_label);
299
 
300
  } die('-----------');*/
301
  ob_start();
302
- include(self::$path . "templates/leads-table.php");
303
  return ob_get_clean();
304
  }
305
 
@@ -1541,7 +1572,8 @@ public static function get_forms(){
1541
  // function submission($components, $contact_form, $mail)
1542
  //prepare list of contact forms --
1543
  /// *NOTE* CF7 changed how it stores forms at some point, support legacy?
1544
- $all_forms=get_option('vxcf_all_forms',array());
 
1545
 
1546
  if(!is_array($all_forms)){
1547
  $all_forms=array();
@@ -1737,8 +1769,8 @@ $forms_arr=isset($all_forms['ul']['forms']) && is_array($all_forms['ul']['forms'
1737
  }
1738
  $all_forms['ul']=array('label'=>'Ultimate Contact Form Builder','forms'=>$forms_arr);
1739
  }
1740
- if(class_exists('Woocommerce')){
1741
- $all_forms['wc']=array('label'=>'WooCommerce','forms'=>array('1'=>'Woocommerce'));
1742
  }
1743
  if(function_exists('cntctfrm_settings')){
1744
 
@@ -2332,11 +2364,11 @@ public static function check_option_value($options,$value){
2332
  return array_values($arr);
2333
  }
2334
 
2335
- public static function get_entries($form_id,$per_page,$page=''){
2336
  $data=array();
2337
  $data_obj=vxcf_form::get_data_object();
2338
  if(!empty($form_id)){
2339
- $data= $data_obj->get_entries($form_id,$per_page);
2340
  if(!empty($data['result'])){
2341
  $data['result']=apply_filters('vxcf_entries_plugin_leads_table',$data['result'],$form_id,$page);
2342
  } }
@@ -2367,11 +2399,14 @@ public static function link_to_settings( $tab='entries' ) {
2367
 
2368
  return $url;
2369
  }
2370
- public static function set_form_fields(){
2371
 
2372
  if(empty(self::$form_fields)){
2373
  self::$forms=$forms=vxcf_form::get_forms();
2374
- self::$form_id=esc_sql(vxcf_form::post('form_id'));
 
 
 
2375
  if(empty(self::$form_id) && !empty(self::$forms)){
2376
  $form_key=key($forms);
2377
  if(isset($forms[$form_key]['forms']) && is_array($forms[$form_key]['forms'])){
@@ -2576,6 +2611,69 @@ $u_agent=$_SERVER['HTTP_USER_AGENT'];
2576
  );
2577
  }
2578
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2579
  public function vx_id(){
2580
  $vx_id='';
2581
  if(!empty($_COOKIE['vx_user'])){
2
  /**
3
  * Plugin Name: Contact Form Entries
4
  * Description: Save form submissions to the database from <a href="https://wordpress.org/plugins/contact-form-7/">Contact Form 7</a>, <a href="https://wordpress.org/plugins/jetpack/">JetPack Contact Form</a>, <a href="https://wordpress.org/plugins/ninja-forms/">Ninja Forms</a>, <a href="https://wordpress.org/plugins/formidable/">Formidable Forms</a>, <a href="http://codecanyon.net/item/quform-wordpress-form-builder/706149">Quform</a>, <a href="https://wordpress.org/plugins/cforms2/">cformsII</a>, <a href="https://wordpress.org/plugins/contact-form-plugin/">Contact Form by BestWebSoft</a>, <a href="https://wordpress.org/plugins/ultimate-form-builder-lite/">Ultimate Form Builder</a>, <a href="https://wordpress.org/plugins/caldera-forms/">Caldera Forms</a> and <a href="https://wordpress.org/plugins/wpforms-lite/">WP Forms</a>.
5
+ * Version: 1.1.1
6
  * Requires at least: 3.8
7
  * Tested up to: 5.4
8
  * Author URI: https://www.crmperks.com
26
  public static $type = "vxcf_form";
27
  public static $path = '';
28
 
29
+ public static $version = '1.1.1';
30
  public static $upload_folder = 'crm_perks_uploads';
31
  public static $db_version='';
32
  public static $base_url='';
45
  public static $forms;
46
  public static $form_id;
47
  public static $user_id;
48
+ public static $is_pr;
49
  public static $form_id_string;
50
  public static $form_fields;
51
  public static $form_fields_temp;
65
  add_filter('crmperks_forms_field_validation_message',array($this,'validate_crmperks_field'),10,4);
66
  }
67
 
68
+
69
  public function init(){
70
  //save screen and url for all forms
71
  add_action('wp_footer', array($this,'footer_js'),33);
72
+ wp_register_script( 'vx-tablesorter-js', self::$base_url. 'js/jquery.tablesorter.js',array('jquery') );
73
  wp_register_script( 'vx-tablepager-js', self::$base_url. 'js/jquery.tablesorter.pager.js',array('jquery') );
74
+ wp_register_script( 'vx-tablewidgets-js', self::$base_url. 'js/jquery.tablesorter.widgets.js',array('jquery') );
75
 
76
  //$fields=$this->get_form_fields('wp_118');
77
  //$form=cfx_form::get_form('1'); var_dump($form['fields']); die();
100
  add_action('ufbl_email_send', array(&$this, 'create_entry_ul'),30);
101
  add_action('grunion_pre_message_sent', array(&$this, 'create_entry_jp'),30,3);
102
  add_filter('crmperks_forms_new_submission', array(&$this, 'create_entry_vf'),40,3);
103
+ //add_action( 'woocommerce_checkout_update_order_meta',array(&$this,'create_entry_wc'), 30, 2 );
104
  add_action( 'wpforms_process_entry_save',array(&$this,'create_entry_wp'), 30, 4 );
105
  // add_action('cntctfrm_get_attachment_data', array(&$this, 'create_entry_be'),30);
106
  // add_filter('si_contact_email_fields_posted', array($this, 'test'),10,2);
153
  require_once(self::$path . "includes/plugin-pages.php");
154
  self::$pages=new vxcf_form_pages();
155
  $pro_file=self::$path . 'pro/pro.php';
156
+ if(file_exists($pro_file)){ include_once($pro_file); self::$is_pr='1'; }
157
  $pro_file=self::$path . 'pro/add-ons.php';
158
  if(file_exists($pro_file)){ include_once($pro_file); }
159
  $pro_file=self::$path . 'wp/crmperks-notices.php';
160
  if(file_exists($pro_file)){ include_once($pro_file); }
161
  //$forms=vxcf_form::get_forms();
162
  }
163
+ if(!empty($_GET['vx_crm_form_action']) && $_GET['vx_crm_form_action'] == 'download_csv'){
164
+ $key=$this->post('vx_crm_key');
165
+ $form_ids=get_option('vx_crm_forms_ids');
166
+ if(is_array($form_ids)){
167
+ $form_id=array_search($key,$form_ids);
168
+ if(!empty($form_id)){
169
+ vxcf_form::set_form_fields($form_id);
170
+ self::download_csv($form_id,array('vx_links'=>'false'));
171
+ die();
172
+ }
173
+ }
174
+ }
175
  }
176
 
177
 
263
  $start='0';
264
  if(!empty($atts['start'])){
265
  $start=$atts['start'];
266
+ }
267
+ $search=$export='';
268
+ if($this->do_actions() ){
269
+ if(!empty($atts['search'])){
270
+ $search=$atts['search'];
271
+ }
272
+ if(!empty($atts['export'])){
273
+ $form_ids=get_option('vx_crm_forms_ids');
274
+ if(!is_array($form_ids)){ $form_ids=array(); }
275
+ if(!isset($form_ids[$form_id])){
276
+ $form_ids[$form_id]=rand(99999,999999999).uniqid().time().rand(999,9999999).uniqid();
277
+ update_option('vx_crm_forms_ids',$form_ids);
278
+ }
279
+ $export=$form_ids[$form_id];
280
+ }
281
  }
282
  $page_size='3';
283
+ if(!empty($atts['per-page'])){
284
+ $page_size=$atts['per-page'];
285
  }
286
  $offset=$this->time_offset();
287
  $req=array('start'=>$start,'vx_links'=>'false');
289
  $req['user_id']=!empty($atts['user-id']) ? (int)$atts['user-id'] : get_current_user_id();
290
  }
291
  $data=vxcf_form::get_data_object();
292
+ $entries=$data->get_entries($form_id,$limit,$req);
293
  $leads=array();
294
  if(!empty($entries['result'])){
295
  $leads=$entries['result'];
298
  $base_url=vxcf_form::get_base_url();
299
  if(!empty($atts['sortable'])){
300
  wp_enqueue_script( 'vx-tablesorter-js');
301
+ wp_enqueue_script( 'vx-tablewidgets-js');
302
  if(!empty($atts['pager'])){
303
  wp_enqueue_script( 'vx-tablepager-js');
304
  }
305
  wp_enqueue_style('vx-tablesorter-css');
306
  }
307
+ $leads_table=apply_filters('crmperks_entries_template',self::$path . "templates/leads-table.php");
308
  /* foreach($leads as $lead){
309
 
310
  foreach($fields as $field){
330
 
331
  } die('-----------');*/
332
  ob_start();
333
+ include($leads_table);
334
  return ob_get_clean();
335
  }
336
 
1572
  // function submission($components, $contact_form, $mail)
1573
  //prepare list of contact forms --
1574
  /// *NOTE* CF7 changed how it stores forms at some point, support legacy?
1575
+ //$all_forms=get_option('vxcf_all_forms',array()); //disable saving forms
1576
+ $all_forms=array();
1577
 
1578
  if(!is_array($all_forms)){
1579
  $all_forms=array();
1769
  }
1770
  $all_forms['ul']=array('label'=>'Ultimate Contact Form Builder','forms'=>$forms_arr);
1771
  }
1772
+ if(class_exists('Woocommerce')){ //disable woo
1773
+ // $all_forms['wc']=array('label'=>'WooCommerce','forms'=>array('1'=>'Woocommerce'));
1774
  }
1775
  if(function_exists('cntctfrm_settings')){
1776
 
2364
  return array_values($arr);
2365
  }
2366
 
2367
+ public static function get_entries($form_id,$per_page,$page='',$req=array()){
2368
  $data=array();
2369
  $data_obj=vxcf_form::get_data_object();
2370
  if(!empty($form_id)){
2371
+ $data= $data_obj->get_entries($form_id,$per_page,$req);
2372
  if(!empty($data['result'])){
2373
  $data['result']=apply_filters('vxcf_entries_plugin_leads_table',$data['result'],$form_id,$page);
2374
  } }
2399
 
2400
  return $url;
2401
  }
2402
+ public static function set_form_fields($form_id=''){
2403
 
2404
  if(empty(self::$form_fields)){
2405
  self::$forms=$forms=vxcf_form::get_forms();
2406
+ if(empty($form_id)){
2407
+ $form_id=vxcf_form::post('form_id');
2408
+ }
2409
+ self::$form_id=esc_sql($form_id);
2410
  if(empty(self::$form_id) && !empty(self::$forms)){
2411
  $form_key=key($forms);
2412
  if(isset($forms[$form_key]['forms']) && is_array($forms[$form_key]['forms'])){
2611
  );
2612
  }
2613
 
2614
+ public static function download_csv($form_id,$req=array()){
2615
+ header('Content-disposition: attachment; filename='.date("Y-m-d",current_time('timestamp')).'.csv');
2616
+ header("Content-Transfer-Encoding: binary");
2617
+
2618
+ $now = gmdate("D, d M Y H:i:s");
2619
+ header("Expires: Tue, 03 Jul 2000 06:00:00 GMT");
2620
+ header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
2621
+ header("Last-Modified: {$now} GMT");
2622
+ // force download
2623
+ header("Content-Type: application/force-download");
2624
+ header("Content-Type: application/octet-stream");
2625
+ header("Content-Type: application/download");
2626
+ $data=vxcf_form::get_entries($form_id,'all','',$req);
2627
+ $leads=$data['result'];
2628
+ $extra_keys=array('vxbrowser'=>'browser','vxurl'=>'url','vxscreen'=>'screen','vxcreated'=>'created','vxupdated'=>'updated');
2629
+ $fields=vxcf_form::$form_fields;
2630
+ //echo json_encode($fields);
2631
+ $field_titles=array('#');
2632
+ if(is_array($fields)){
2633
+ foreach($fields as $field){
2634
+ $field_titles[]=$field['label'];
2635
+ }
2636
+ }
2637
+ // $field_titles[]=__('Created','contact-form-entries');
2638
+
2639
+ $fp = fopen('php://output', 'w');
2640
+ // fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
2641
+ fputcsv($fp, $field_titles);
2642
+ $sno=0;
2643
+ foreach($leads as $lead_row){
2644
+ $row=!empty($lead_row['detail']) ? $lead_row['detail'] : array();
2645
+ $sno++;
2646
+ $_row=array($sno);
2647
+ foreach($fields as $k=>$field){
2648
+ $val='';
2649
+ if(!empty($field['name']) && isset($row[$field['name'].'_field'])){
2650
+ $val=maybe_unserialize($row[$field['name'].'_field']);
2651
+ }
2652
+ if(isset($extra_keys[$k]) && isset($lead_row[$extra_keys[$k]])){
2653
+ if($k == 'vxbrowser'){
2654
+ $val=isset($lead_row['browser']) ? $lead_row['browser'].' ' : '';
2655
+ $val.=isset($lead_row['os']) ? $lead_row['os'] : '';
2656
+ }else{
2657
+ $val=$lead_row[$extra_keys[$k]];
2658
+ }
2659
+ }
2660
+ if(is_array($val)){
2661
+ $val=implode(' - ',$val);
2662
+ }
2663
+ // if(function_exists('mb_convert_encoding')){
2664
+ // $val=mb_convert_encoding($val, $charset);
2665
+ // }
2666
+ $_row[]=$val;
2667
+
2668
+ }
2669
+
2670
+ $_row[]=$lead_row['created'];
2671
+
2672
+ fputcsv($fp, $_row);
2673
+ }
2674
+ fclose($fp);
2675
+
2676
+ }
2677
  public function vx_id(){
2678
  $vx_id='';
2679
  if(!empty($_COOKIE['vx_user'])){
includes/data.php CHANGED
@@ -350,7 +350,7 @@ $sql.=" order by $order_by $order ";
350
  $results=$wpdb->get_results($sql, ARRAY_A);
351
  //echo json_encode($results); die();
352
  // $re = $wpdb->get_results('SELECT FOUND_ROWS();', ARRAY_A);
353
- //
354
  $leads=array();
355
  if(isset($results) && is_array($results) && count($results)>0){
356
  foreach($results as $v){
@@ -362,11 +362,13 @@ if(!empty(vxcf_form::$form_fields)){
362
  $sql_d="SELECT id,lead_id";
363
  foreach(vxcf_form::$form_fields as $k=>$v){
364
  if(!empty($v['is_main'])){ continue; }
 
365
  $sql_d.=", MAX(if(`name`='$k', `value`, null )) AS '".$k."_field'";
366
  }
367
  $sql_d.=' FROM '.$detail.' where lead_id in('.implode(',',$ids).') GROUP BY `lead_id` ';
368
 
369
  $res= $wpdb->get_results($sql_d, ARRAY_A);
 
370
  //echo $sql_d.'-----<hr>'.json_encode($res).'<-------'.$wpdb->last_error.'----<hr>'; //die();
371
  if(!empty($res)){
372
  foreach($res as $v){
350
  $results=$wpdb->get_results($sql, ARRAY_A);
351
  //echo json_encode($results); die();
352
  // $re = $wpdb->get_results('SELECT FOUND_ROWS();', ARRAY_A);
353
+
354
  $leads=array();
355
  if(isset($results) && is_array($results) && count($results)>0){
356
  foreach($results as $v){
362
  $sql_d="SELECT id,lead_id";
363
  foreach(vxcf_form::$form_fields as $k=>$v){
364
  if(!empty($v['is_main'])){ continue; }
365
+ $k=$v['name'];
366
  $sql_d.=", MAX(if(`name`='$k', `value`, null )) AS '".$k."_field'";
367
  }
368
  $sql_d.=' FROM '.$detail.' where lead_id in('.implode(',',$ids).') GROUP BY `lead_id` ';
369
 
370
  $res= $wpdb->get_results($sql_d, ARRAY_A);
371
+ //var_dump($res,vxcf_form::$form_fields);
372
  //echo $sql_d.'-----<hr>'.json_encode($res).'<-------'.$wpdb->last_error.'----<hr>'; //die();
373
  if(!empty($res)){
374
  foreach($res as $v){
includes/plugin-pages.php CHANGED
@@ -22,6 +22,7 @@ public static $related_leads;
22
  *
23
  */
24
  public function __construct(){
 
25
  $this->data=vxcf_form::get_data_object();
26
 
27
  global $pagenow;
@@ -38,6 +39,7 @@ add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
38
  add_action( 'vx_cf_meta_boxes_right', array($this,'related_entries_cf'),10,3 );
39
  add_action( 'vx_cf_add_meta_box_right', array($this,'add_meta_box'),9,2 );
40
  //creates the subnav left menu
 
41
  add_filter("admin_menu", array($this, 'main_menu'), 27);
42
  add_filter('vx_entries_plugin_tabs', array($this, 'create_menu'), 16);
43
  add_filter('vx_entries_plugin_tab_sections', array($this, 'settings_section'), 10);
@@ -58,6 +60,7 @@ add_filter('wp_privacy_personal_data_erasers',array($this,'remove_personal_data'
58
 
59
  }
60
 
 
61
  public function mapping_page_settings(){
62
 
63
  $sections=apply_filters('vx_entries_plugin_tab_sections',array());
@@ -534,7 +537,7 @@ add_action("load-$hook", array($this,'screen_options')); //toplevel_page_vxcf_le
534
  //2=hide cols
535
  //3=update_hidden_cols
536
  }
537
- $this->setup_plugin();
538
  }
539
  /**
540
  * plugin admin features
@@ -675,57 +678,14 @@ die();
675
 
676
  if(vxcf_form::post('vx_tab_action_'.vxcf_form::$id)=="export_log"){
677
  check_admin_referer('vx_nonce','vx_nonce');
678
- if(current_user_can(vxcf_form::$id."_edit_settings")){
679
- header('Content-disposition: attachment; filename='.date("Y-m-d",current_time('timestamp')).'.csv');
680
- header('Content-Type: application/excel');
681
- $this->data=vxcf_form::get_data_object();
 
682
  vxcf_form::set_form_fields();
683
  $form_id=vxcf_form::$form_id;
684
- $data=vxcf_form::get_entries($form_id,'all');
685
- $leads=$data['result'];
686
- $extra_keys=array('vxbrowser'=>'browser','vxurl'=>'url','vxscreen'=>'screen','vxcreated'=>'created','vxupdated'=>'updated');
687
- $fields=vxcf_form::$form_fields;
688
- //var_dump($fields); die();
689
- $field_titles=array('#');
690
- if(is_array($fields)){
691
- foreach($fields as $field){
692
- $field_titles[]=$field['label'];
693
- }
694
- }
695
- // $field_titles[]=__('Created','contact-form-entries');
696
-
697
- $fp = fopen('php://output', 'w');
698
- fputcsv($fp, $field_titles);
699
- $sno=0;
700
- foreach($leads as $lead_row){
701
- $row=!empty($lead_row['detail']) ? $lead_row['detail'] : array();
702
- $sno++;
703
- $_row=array($sno);
704
- foreach($fields as $k=>$field){
705
- $val='';
706
- if(!empty($field['name']) && isset($row[$field['name'].'_field'])){
707
- $val=maybe_unserialize($row[$field['name'].'_field']);
708
- }
709
- if(isset($extra_keys[$k]) && isset($lead_row[$extra_keys[$k]])){
710
- if($k == 'vxbrowser'){
711
- $val=isset($lead_row['browser']) ? $lead_row['browser'].' ' : '';
712
- $val.=isset($lead_row['os']) ? $lead_row['os'] : '';
713
- }else{
714
- $val=$lead_row[$extra_keys[$k]];
715
- }
716
- }
717
- if(is_array($val)){
718
- $val=implode(' - ',$val);
719
- }
720
- $_row[]=$val;
721
-
722
- }
723
-
724
- $_row[]=$lead_row['created'];
725
-
726
- fputcsv($fp, $_row);
727
- }
728
- fclose($fp);
729
  die();
730
  }}
731
 
22
  *
23
  */
24
  public function __construct(){
25
+
26
  $this->data=vxcf_form::get_data_object();
27
 
28
  global $pagenow;
39
  add_action( 'vx_cf_meta_boxes_right', array($this,'related_entries_cf'),10,3 );
40
  add_action( 'vx_cf_add_meta_box_right', array($this,'add_meta_box'),9,2 );
41
  //creates the subnav left menu
42
+ add_filter("admin_init", array($this, 'setup_plugin'), 2);
43
  add_filter("admin_menu", array($this, 'main_menu'), 27);
44
  add_filter('vx_entries_plugin_tabs', array($this, 'create_menu'), 16);
45
  add_filter('vx_entries_plugin_tab_sections', array($this, 'settings_section'), 10);
60
 
61
  }
62
 
63
+
64
  public function mapping_page_settings(){
65
 
66
  $sections=apply_filters('vx_entries_plugin_tab_sections',array());
537
  //2=hide cols
538
  //3=update_hidden_cols
539
  }
540
+ //$this->setup_plugin();
541
  }
542
  /**
543
  * plugin admin features
678
 
679
  if(vxcf_form::post('vx_tab_action_'.vxcf_form::$id)=="export_log"){
680
  check_admin_referer('vx_nonce','vx_nonce');
681
+ if(current_user_can(vxcf_form::$id."_edit_settings")){
682
+
683
+ // get charset
684
+ //$charset = get_bloginfo( 'charset' );
685
+ //$this->data=vxcf_form::get_data_object();
686
  vxcf_form::set_form_fields();
687
  $form_id=vxcf_form::$form_id;
688
+ vxcf_form::download_csv($form_id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
689
  die();
690
  }}
691
 
js/jquery.tablesorter.js ADDED
@@ -0,0 +1,2914 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! TableSorter (FORK) v2.31.3 *//*
2
+ * Client-side table sorting with ease!
3
+ * @requires jQuery v1.2.6+
4
+ *
5
+ * Copyright (c) 2007 Christian Bach
6
+ * fork maintained by Rob Garrison
7
+ *
8
+ * Examples and original docs at: http://tablesorter.com
9
+ * Dual licensed under the MIT and GPL licenses:
10
+ * http://www.opensource.org/licenses/mit-license.php
11
+ * http://www.gnu.org/licenses/gpl.html
12
+ *
13
+ * @type jQuery
14
+ * @name tablesorter (FORK)
15
+ * @cat Plugins/Tablesorter
16
+ * @author Christian Bach - christian.bach@polyester.se
17
+ * @contributor Rob Garrison - https://github.com/Mottie/tablesorter
18
+ * @docs (fork) - https://mottie.github.io/tablesorter/docs/
19
+ */
20
+ /*jshint browser:true, jquery:true, unused:false, expr: true */
21
+ ;( function( $ ) {
22
+ 'use strict';
23
+ var ts = $.tablesorter = {
24
+
25
+ version : '2.31.3',
26
+
27
+ parsers : [],
28
+ widgets : [],
29
+ defaults : {
30
+
31
+ // *** appearance
32
+ theme : 'default', // adds tablesorter-{theme} to the table for styling
33
+ widthFixed : false, // adds colgroup to fix widths of columns
34
+ showProcessing : false, // show an indeterminate timer icon in the header when the table is sorted or filtered.
35
+
36
+ headerTemplate : '{content}',// header layout template (HTML ok); {content} = innerHTML, {icon} = <i/> // class from cssIcon
37
+ onRenderTemplate : null, // function( index, template ) { return template; }, // template is a string
38
+ onRenderHeader : null, // function( index ) {}, // nothing to return
39
+
40
+ // *** functionality
41
+ cancelSelection : true, // prevent text selection in the header
42
+ tabIndex : true, // add tabindex to header for keyboard accessibility
43
+ dateFormat : 'mmddyyyy', // other options: 'ddmmyyy' or 'yyyymmdd'
44
+ sortMultiSortKey : 'shiftKey', // key used to select additional columns
45
+ sortResetKey : 'ctrlKey', // key used to remove sorting on a column
46
+ usNumberFormat : true, // false for German '1.234.567,89' or French '1 234 567,89'
47
+ delayInit : false, // if false, the parsed table contents will not update until the first sort
48
+ serverSideSorting: false, // if true, server-side sorting should be performed because client-side sorting will be disabled, but the ui and events will still be used.
49
+ resort : true, // default setting to trigger a resort after an 'update', 'addRows', 'updateCell', etc has completed
50
+
51
+ // *** sort options
52
+ headers : {}, // set sorter, string, empty, locked order, sortInitialOrder, filter, etc.
53
+ ignoreCase : true, // ignore case while sorting
54
+ sortForce : null, // column(s) first sorted; always applied
55
+ sortList : [], // Initial sort order; applied initially; updated when manually sorted
56
+ sortAppend : null, // column(s) sorted last; always applied
57
+ sortStable : false, // when sorting two rows with exactly the same content, the original sort order is maintained
58
+
59
+ sortInitialOrder : 'asc', // sort direction on first click
60
+ sortLocaleCompare: false, // replace equivalent character (accented characters)
61
+ sortReset : false, // third click on the header will reset column to default - unsorted
62
+ sortRestart : false, // restart sort to 'sortInitialOrder' when clicking on previously unsorted columns
63
+
64
+ emptyTo : 'bottom', // sort empty cell to bottom, top, none, zero, emptyMax, emptyMin
65
+ stringTo : 'max', // sort strings in numerical column as max, min, top, bottom, zero
66
+ duplicateSpan : true, // colspan cells in the tbody will have duplicated content in the cache for each spanned column
67
+ textExtraction : 'basic', // text extraction method/function - function( node, table, cellIndex ) {}
68
+ textAttribute : 'data-text',// data-attribute that contains alternate cell text (used in default textExtraction function)
69
+ textSorter : null, // choose overall or specific column sorter function( a, b, direction, table, columnIndex ) [alt: ts.sortText]
70
+ numberSorter : null, // choose overall numeric sorter function( a, b, direction, maxColumnValue )
71
+
72
+ // *** widget options
73
+ initWidgets : true, // apply widgets on tablesorter initialization
74
+ widgetClass : 'widget-{name}', // table class name template to match to include a widget
75
+ widgets : [], // method to add widgets, e.g. widgets: ['zebra']
76
+ widgetOptions : {
77
+ zebra : [ 'even', 'odd' ] // zebra widget alternating row class names
78
+ },
79
+
80
+ // *** callbacks
81
+ initialized : null, // function( table ) {},
82
+
83
+ // *** extra css class names
84
+ tableClass : '',
85
+ cssAsc : '',
86
+ cssDesc : '',
87
+ cssNone : '',
88
+ cssHeader : '',
89
+ cssHeaderRow : '',
90
+ cssProcessing : '', // processing icon applied to header during sort/filter
91
+
92
+ cssChildRow : 'tablesorter-childRow', // class name indiciating that a row is to be attached to its parent
93
+ cssInfoBlock : 'tablesorter-infoOnly', // don't sort tbody with this class name (only one class name allowed here!)
94
+ cssNoSort : 'tablesorter-noSort', // class name added to element inside header; clicking on it won't cause a sort
95
+ cssIgnoreRow : 'tablesorter-ignoreRow',// header row to ignore; cells within this row will not be added to c.$headers
96
+
97
+ cssIcon : 'tablesorter-icon', // if this class does not exist, the {icon} will not be added from the headerTemplate
98
+ cssIconNone : '', // class name added to the icon when there is no column sort
99
+ cssIconAsc : '', // class name added to the icon when the column has an ascending sort
100
+ cssIconDesc : '', // class name added to the icon when the column has a descending sort
101
+ cssIconDisabled : '', // class name added to the icon when the column has a disabled sort
102
+
103
+ // *** events
104
+ pointerClick : 'click',
105
+ pointerDown : 'mousedown',
106
+ pointerUp : 'mouseup',
107
+
108
+ // *** selectors
109
+ selectorHeaders : '> thead th, > thead td',
110
+ selectorSort : 'th, td', // jQuery selector of content within selectorHeaders that is clickable to trigger a sort
111
+ selectorRemove : '.remove-me',
112
+
113
+ // *** advanced
114
+ debug : false,
115
+
116
+ // *** Internal variables
117
+ headerList: [],
118
+ empties: {},
119
+ strings: {},
120
+ parsers: [],
121
+
122
+ // *** parser options for validator; values must be falsy!
123
+ globalize: 0,
124
+ imgAttr: 0
125
+
126
+ // removed: widgetZebra: { css: ['even', 'odd'] }
127
+
128
+ },
129
+
130
+ // internal css classes - these will ALWAYS be added to
131
+ // the table and MUST only contain one class name - fixes #381
132
+ css : {
133
+ table : 'tablesorter',
134
+ cssHasChild: 'tablesorter-hasChildRow',
135
+ childRow : 'tablesorter-childRow',
136
+ colgroup : 'tablesorter-colgroup',
137
+ header : 'tablesorter-header',
138
+ headerRow : 'tablesorter-headerRow',
139
+ headerIn : 'tablesorter-header-inner',
140
+ icon : 'tablesorter-icon',
141
+ processing : 'tablesorter-processing',
142
+ sortAsc : 'tablesorter-headerAsc',
143
+ sortDesc : 'tablesorter-headerDesc',
144
+ sortNone : 'tablesorter-headerUnSorted'
145
+ },
146
+
147
+ // labels applied to sortable headers for accessibility (aria) support
148
+ language : {
149
+ sortAsc : 'Ascending sort applied, ',
150
+ sortDesc : 'Descending sort applied, ',
151
+ sortNone : 'No sort applied, ',
152
+ sortDisabled : 'sorting is disabled',
153
+ nextAsc : 'activate to apply an ascending sort',
154
+ nextDesc : 'activate to apply a descending sort',
155
+ nextNone : 'activate to remove the sort'
156
+ },
157
+
158
+ regex : {
159
+ templateContent : /\{content\}/g,
160
+ templateIcon : /\{icon\}/g,
161
+ templateName : /\{name\}/i,
162
+ spaces : /\s+/g,
163
+ nonWord : /\W/g,
164
+ formElements : /(input|select|button|textarea)/i,
165
+
166
+ // *** sort functions ***
167
+ // regex used in natural sort
168
+ // chunk/tokenize numbers & letters
169
+ chunk : /(^([+\-]?(?:\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,
170
+ // replace chunks @ ends
171
+ chunks : /(^\\0|\\0$)/,
172
+ hex : /^0x[0-9a-f]+$/i,
173
+
174
+ // *** formatFloat ***
175
+ comma : /,/g,
176
+ digitNonUS : /[\s|\.]/g,
177
+ digitNegativeTest : /^\s*\([.\d]+\)/,
178
+ digitNegativeReplace : /^\s*\(([.\d]+)\)/,
179
+
180
+ // *** isDigit ***
181
+ digitTest : /^[\-+(]?\d+[)]?$/,
182
+ digitReplace : /[,.'"\s]/g
183
+
184
+ },
185
+
186
+ // digit sort, text location
187
+ string : {
188
+ max : 1,
189
+ min : -1,
190
+ emptymin : 1,
191
+ emptymax : -1,
192
+ zero : 0,
193
+ none : 0,
194
+ 'null' : 0,
195
+ top : true,
196
+ bottom : false
197
+ },
198
+
199
+ keyCodes : {
200
+ enter : 13
201
+ },
202
+
203
+ // placeholder date parser data (globalize)
204
+ dates : {},
205
+
206
+ // These methods can be applied on table.config instance
207
+ instanceMethods : {},
208
+
209
+ /*
210
+ ▄█████ ██████ ██████ ██ ██ █████▄
211
+ ▀█▄ ██▄▄ ██ ██ ██ ██▄▄██
212
+ ▀█▄ ██▀▀ ██ ██ ██ ██▀▀▀
213
+ █████▀ ██████ ██ ▀████▀ ██
214
+ */
215
+
216
+ setup : function( table, c ) {
217
+ // if no thead or tbody, or tablesorter is already present, quit
218
+ if ( !table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true ) {
219
+ if ( ts.debug(c, 'core') ) {
220
+ if ( table.hasInitialized ) {
221
+ console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
222
+ } else {
223
+ console.error( 'Stopping initialization! No table, thead or tbody', table );
224
+ }
225
+ }
226
+ return;
227
+ }
228
+
229
+ var tmp = '',
230
+ $table = $( table ),
231
+ meta = $.metadata;
232
+ // initialization flag
233
+ table.hasInitialized = false;
234
+ // table is being processed flag
235
+ table.isProcessing = true;
236
+ // make sure to store the config object
237
+ table.config = c;
238
+ // save the settings where they read
239
+ $.data( table, 'tablesorter', c );
240
+ if ( ts.debug(c, 'core') ) {
241
+ console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter v' + ts.version );
242
+ $.data( table, 'startoveralltimer', new Date() );
243
+ }
244
+
245
+ // removing this in version 3 (only supports jQuery 1.7+)
246
+ c.supportsDataObject = ( function( version ) {
247
+ version[ 0 ] = parseInt( version[ 0 ], 10 );
248
+ return ( version[ 0 ] > 1 ) || ( version[ 0 ] === 1 && parseInt( version[ 1 ], 10 ) >= 4 );
249
+ })( $.fn.jquery.split( '.' ) );
250
+ // ensure case insensitivity
251
+ c.emptyTo = c.emptyTo.toLowerCase();
252
+ c.stringTo = c.stringTo.toLowerCase();
253
+ c.last = { sortList : [], clickedIndex : -1 };
254
+ // add table theme class only if there isn't already one there
255
+ if ( !/tablesorter\-/.test( $table.attr( 'class' ) ) ) {
256
+ tmp = ( c.theme !== '' ? ' tablesorter-' + c.theme : '' );
257
+ }
258
+
259
+ // give the table a unique id, which will be used in namespace binding
260
+ if ( !c.namespace ) {
261
+ c.namespace = '.tablesorter' + Math.random().toString( 16 ).slice( 2 );
262
+ } else {
263
+ // make sure namespace starts with a period & doesn't have weird characters
264
+ c.namespace = '.' + c.namespace.replace( ts.regex.nonWord, '' );
265
+ }
266
+
267
+ c.table = table;
268
+ c.$table = $table
269
+ // add namespace to table to allow bindings on extra elements to target
270
+ // the parent table (e.g. parser-input-select)
271
+ .addClass( ts.css.table + ' ' + c.tableClass + tmp + ' ' + c.namespace.slice(1) )
272
+ .attr( 'role', 'grid' );
273
+ c.$headers = $table.find( c.selectorHeaders );
274
+
275
+ c.$table.children().children( 'tr' ).attr( 'role', 'row' );
276
+ c.$tbodies = $table.children( 'tbody:not(.' + c.cssInfoBlock + ')' ).attr({
277
+ 'aria-live' : 'polite',
278
+ 'aria-relevant' : 'all'
279
+ });
280
+ if ( c.$table.children( 'caption' ).length ) {
281
+ tmp = c.$table.children( 'caption' )[ 0 ];
282
+ if ( !tmp.id ) { tmp.id = c.namespace.slice( 1 ) + 'caption'; }
283
+ c.$table.attr( 'aria-labelledby', tmp.id );
284
+ }
285
+ c.widgetInit = {}; // keep a list of initialized widgets
286
+ // change textExtraction via data-attribute
287
+ c.textExtraction = c.$table.attr( 'data-text-extraction' ) || c.textExtraction || 'basic';
288
+ // build headers
289
+ ts.buildHeaders( c );
290
+ // fixate columns if the users supplies the fixedWidth option
291
+ // do this after theme has been applied
292
+ ts.fixColumnWidth( table );
293
+ // add widgets from class name
294
+ ts.addWidgetFromClass( table );
295
+ // add widget options before parsing (e.g. grouping widget has parser settings)
296
+ ts.applyWidgetOptions( table );
297
+ // try to auto detect column type, and store in tables config
298
+ ts.setupParsers( c );
299
+ // start total row count at zero
300
+ c.totalRows = 0;
301
+ // only validate options while debugging. See #1528
302
+ if (c.debug) {
303
+ ts.validateOptions( c );
304
+ }
305
+ // build the cache for the tbody cells
306
+ // delayInit will delay building the cache until the user starts a sort
307
+ if ( !c.delayInit ) { ts.buildCache( c ); }
308
+ // bind all header events and methods
309
+ ts.bindEvents( table, c.$headers, true );
310
+ ts.bindMethods( c );
311
+ // get sort list from jQuery data or metadata
312
+ // in jQuery < 1.4, an error occurs when calling $table.data()
313
+ if ( c.supportsDataObject && typeof $table.data().sortlist !== 'undefined' ) {
314
+ c.sortList = $table.data().sortlist;
315
+ } else if ( meta && ( $table.metadata() && $table.metadata().sortlist ) ) {
316
+ c.sortList = $table.metadata().sortlist;
317
+ }
318
+ // apply widget init code
319
+ ts.applyWidget( table, true );
320
+ // if user has supplied a sort list to constructor
321
+ if ( c.sortList.length > 0 ) {
322
+ // save sortList before any sortAppend is added
323
+ c.last.sortList = c.sortList;
324
+ ts.sortOn( c, c.sortList, {}, !c.initWidgets );
325
+ } else {
326
+ ts.setHeadersCss( c );
327
+ if ( c.initWidgets ) {
328
+ // apply widget format
329
+ ts.applyWidget( table, false );
330
+ }
331
+ }
332
+
333
+ // show processesing icon
334
+ if ( c.showProcessing ) {
335
+ $table
336
+ .unbind( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace )
337
+ .bind( 'sortBegin' + c.namespace + ' sortEnd' + c.namespace, function( e ) {
338
+ clearTimeout( c.timerProcessing );
339
+ ts.isProcessing( table );
340
+ if ( e.type === 'sortBegin' ) {
341
+ c.timerProcessing = setTimeout( function() {
342
+ ts.isProcessing( table, true );
343
+ }, 500 );
344
+ }
345
+ });
346
+ }
347
+
348
+ // initialized
349
+ table.hasInitialized = true;
350
+ table.isProcessing = false;
351
+ if ( ts.debug(c, 'core') ) {
352
+ console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) );
353
+ if ( ts.debug(c, 'core') && console.groupEnd ) { console.groupEnd(); }
354
+ }
355
+ $table.triggerHandler( 'tablesorter-initialized', table );
356
+ if ( typeof c.initialized === 'function' ) {
357
+ c.initialized( table );
358
+ }
359
+ },
360
+
361
+ bindMethods : function( c ) {
362
+ var $table = c.$table,
363
+ namespace = c.namespace,
364
+ events = ( 'sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete ' +
365
+ 'sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup ' +
366
+ 'mouseleave ' ).split( ' ' )
367
+ .join( namespace + ' ' );
368
+ // apply easy methods that trigger bound events
369
+ $table
370
+ .unbind( events.replace( ts.regex.spaces, ' ' ) )
371
+ .bind( 'sortReset' + namespace, function( e, callback ) {
372
+ e.stopPropagation();
373
+ // using this.config to ensure functions are getting a non-cached version of the config
374
+ ts.sortReset( this.config, function( table ) {
375
+ if (table.isApplyingWidgets) {
376
+ // multiple triggers in a row... filterReset, then sortReset - see #1361
377
+ // wait to update widgets
378
+ setTimeout( function() {
379
+ ts.applyWidget( table, '', callback );
380
+ }, 100 );
381
+ } else {
382
+ ts.applyWidget( table, '', callback );
383
+ }
384
+ });
385
+ })
386
+ .bind( 'updateAll' + namespace, function( e, resort, callback ) {
387
+ e.stopPropagation();
388
+ ts.updateAll( this.config, resort, callback );
389
+ })
390
+ .bind( 'update' + namespace + ' updateRows' + namespace, function( e, resort, callback ) {
391
+ e.stopPropagation();
392
+ ts.update( this.config, resort, callback );
393
+ })
394
+ .bind( 'updateHeaders' + namespace, function( e, callback ) {
395
+ e.stopPropagation();
396
+ ts.updateHeaders( this.config, callback );
397
+ })
398
+ .bind( 'updateCell' + namespace, function( e, cell, resort, callback ) {
399
+ e.stopPropagation();
400
+ ts.updateCell( this.config, cell, resort, callback );
401
+ })
402
+ .bind( 'addRows' + namespace, function( e, $row, resort, callback ) {
403
+ e.stopPropagation();
404
+ ts.addRows( this.config, $row, resort, callback );
405
+ })
406
+ .bind( 'updateComplete' + namespace, function() {
407
+ this.isUpdating = false;
408
+ })
409
+ .bind( 'sorton' + namespace, function( e, list, callback, init ) {
410
+ e.stopPropagation();
411
+ ts.sortOn( this.config, list, callback, init );
412
+ })
413
+ .bind( 'appendCache' + namespace, function( e, callback, init ) {
414
+ e.stopPropagation();
415
+ ts.appendCache( this.config, init );
416
+ if ( $.isFunction( callback ) ) {
417
+ callback( this );
418
+ }
419
+ })
420
+ // $tbodies variable is used by the tbody sorting widget
421
+ .bind( 'updateCache' + namespace, function( e, callback, $tbodies ) {
422
+ e.stopPropagation();
423
+ ts.updateCache( this.config, callback, $tbodies );
424
+ })
425
+ .bind( 'applyWidgetId' + namespace, function( e, id ) {
426
+ e.stopPropagation();
427
+ ts.applyWidgetId( this, id );
428
+ })
429
+ .bind( 'applyWidgets' + namespace, function( e, callback ) {
430
+ e.stopPropagation();
431
+ // apply widgets (false = not initializing)
432
+ ts.applyWidget( this, false, callback );
433
+ })
434
+ .bind( 'refreshWidgets' + namespace, function( e, all, dontapply ) {
435
+ e.stopPropagation();
436
+ ts.refreshWidgets( this, all, dontapply );
437
+ })
438
+ .bind( 'removeWidget' + namespace, function( e, name, refreshing ) {
439
+ e.stopPropagation();
440
+ ts.removeWidget( this, name, refreshing );
441
+ })
442
+ .bind( 'destroy' + namespace, function( e, removeClasses, callback ) {
443
+ e.stopPropagation();
444
+ ts.destroy( this, removeClasses, callback );
445
+ })
446
+ .bind( 'resetToLoadState' + namespace, function( e ) {
447
+ e.stopPropagation();
448
+ // remove all widgets
449
+ ts.removeWidget( this, true, false );
450
+ var tmp = $.extend( true, {}, c.originalSettings );
451
+ // restore original settings; this clears out current settings, but does not clear
452
+ // values saved to storage.
453
+ c = $.extend( true, {}, ts.defaults, tmp );
454
+ c.originalSettings = tmp;
455
+ this.hasInitialized = false;
456
+ // setup the entire table again
457
+ ts.setup( this, c );
458
+ });
459
+ },
460
+
461
+ bindEvents : function( table, $headers, core ) {
462
+ table = $( table )[ 0 ];
463
+ var tmp,
464
+ c = table.config,
465
+ namespace = c.namespace,
466
+ downTarget = null;
467
+ if ( core !== true ) {
468
+ $headers.addClass( namespace.slice( 1 ) + '_extra_headers' );
469
+ tmp = ts.getClosest( $headers, 'table' );
470
+ if ( tmp.length && tmp[ 0 ].nodeName === 'TABLE' && tmp[ 0 ] !== table ) {
471
+ $( tmp[ 0 ] ).addClass( namespace.slice( 1 ) + '_extra_table' );
472
+ }
473
+ }
474
+ tmp = ( c.pointerDown + ' ' + c.pointerUp + ' ' + c.pointerClick + ' sort keyup ' )
475
+ .replace( ts.regex.spaces, ' ' )
476
+ .split( ' ' )
477
+ .join( namespace + ' ' );
478
+ // apply event handling to headers and/or additional headers (stickyheaders, scroller, etc)
479
+ $headers
480
+ // http://stackoverflow.com/questions/5312849/jquery-find-self;
481
+ .find( c.selectorSort )
482
+ .add( $headers.filter( c.selectorSort ) )
483
+ .unbind( tmp )
484
+ .bind( tmp, function( e, external ) {
485
+ var $cell, cell, temp,
486
+ $target = $( e.target ),
487
+ // wrap event type in spaces, so the match doesn't trigger on inner words
488
+ type = ' ' + e.type + ' ';
489
+ // only recognize left clicks
490
+ if ( ( ( e.which || e.button ) !== 1 && !type.match( ' ' + c.pointerClick + ' | sort | keyup ' ) ) ||
491
+ // allow pressing enter
492
+ ( type === ' keyup ' && e.which !== ts.keyCodes.enter ) ||
493
+ // allow triggering a click event (e.which is undefined) & ignore physical clicks
494
+ ( type.match( ' ' + c.pointerClick + ' ' ) && typeof e.which !== 'undefined' ) ) {
495
+ return;
496
+ }
497
+ // ignore mouseup if mousedown wasn't on the same target
498
+ if ( type.match( ' ' + c.pointerUp + ' ' ) && downTarget !== e.target && external !== true ) {
499
+ return;
500
+ }
501
+ // set target on mousedown
502
+ if ( type.match( ' ' + c.pointerDown + ' ' ) ) {
503
+ downTarget = e.target;
504
+ // preventDefault needed or jQuery v1.3.2 and older throws an
505
+ // "Uncaught TypeError: handler.apply is not a function" error
506
+ temp = $target.jquery.split( '.' );
507
+ if ( temp[ 0 ] === '1' && temp[ 1 ] < 4 ) { e.preventDefault(); }
508
+ return;
509
+ }
510
+ downTarget = null;
511
+ $cell = ts.getClosest( $( this ), '.' + ts.css.header );
512
+ // prevent sort being triggered on form elements
513
+ if ( ts.regex.formElements.test( e.target.nodeName ) ||
514
+ // nosort class name, or elements within a nosort container
515
+ $target.hasClass( c.cssNoSort ) || $target.parents( '.' + c.cssNoSort ).length > 0 ||
516
+ // disabled cell directly clicked
517
+ $cell.hasClass( 'sorter-false' ) ||
518
+ // elements within a button
519
+ $target.parents( 'button' ).length > 0 ) {
520
+ return !c.cancelSelection;
521
+ }
522
+ if ( c.delayInit && ts.isEmptyObject( c.cache ) ) {
523
+ ts.buildCache( c );
524
+ }
525
+ // use column index from data-attribute or index of current row; fixes #1116
526
+ c.last.clickedIndex = $cell.attr( 'data-column' ) || $cell.index();
527
+ cell = c.$headerIndexed[ c.last.clickedIndex ][0];
528
+ if ( cell && !cell.sortDisabled ) {
529
+ ts.initSort( c, cell, e );
530
+ }
531
+ });
532
+ if ( c.cancelSelection ) {
533
+ // cancel selection
534
+ $headers
535
+ .attr( 'unselectable', 'on' )
536
+ .bind( 'selectstart', false )
537
+ .css({
538
+ 'user-select' : 'none',
539
+ 'MozUserSelect' : 'none' // not needed for jQuery 1.8+
540
+ });
541
+ }
542
+ },
543
+
544
+ buildHeaders : function( c ) {
545
+ var $temp, icon, timer, indx;
546
+ c.headerList = [];
547
+ c.headerContent = [];
548
+ c.sortVars = [];
549
+ if ( ts.debug(c, 'core') ) {
550
+ timer = new Date();
551
+ }
552
+ // children tr in tfoot - see issue #196 & #547
553
+ // don't pass table.config to computeColumnIndex here - widgets (math) pass it to "quickly" index tbody cells
554
+ c.columns = ts.computeColumnIndex( c.$table.children( 'thead, tfoot' ).children( 'tr' ) );
555
+ // add icon if cssIcon option exists
556
+ icon = c.cssIcon ?
557
+ '<i class="' + ( c.cssIcon === ts.css.icon ? ts.css.icon : c.cssIcon + ' ' + ts.css.icon ) + '"></i>' :
558
+ '';
559
+ // redefine c.$headers here in case of an updateAll that replaces or adds an entire header cell - see #683
560
+ c.$headers = $( $.map( c.$table.find( c.selectorHeaders ), function( elem, index ) {
561
+ var configHeaders, header, column, template, tmp,
562
+ $elem = $( elem );
563
+ // ignore cell (don't add it to c.$headers) if row has ignoreRow class
564
+ if ( ts.getClosest( $elem, 'tr' ).hasClass( c.cssIgnoreRow ) ) { return; }
565
+ // transfer data-column to element if not th/td - #1459
566
+ if ( !/(th|td)/i.test( elem.nodeName ) ) {
567
+ tmp = ts.getClosest( $elem, 'th, td' );
568
+ $elem.attr( 'data-column', tmp.attr( 'data-column' ) );
569
+ }
570
+ // make sure to get header cell & not column indexed cell
571
+ configHeaders = ts.getColumnData( c.table, c.headers, index, true );
572
+ // save original header content
573
+ c.headerContent[ index ] = $elem.html();
574
+ // if headerTemplate is empty, don't reformat the header cell
575
+ if ( c.headerTemplate !== '' && !$elem.find( '.' + ts.css.headerIn ).length ) {
576
+ // set up header template
577
+ template = c.headerTemplate
578
+ .replace( ts.regex.templateContent, $elem.html() )
579
+ .replace( ts.regex.templateIcon, $elem.find( '.' + ts.css.icon ).length ? '' : icon );
580
+ if ( c.onRenderTemplate ) {
581
+ header = c.onRenderTemplate.apply( $elem, [ index, template ] );
582
+ // only change t if something is returned
583
+ if ( header && typeof header === 'string' ) {
584
+ template = header;
585
+ }
586
+ }
587
+ $elem.html( '<div class="' + ts.css.headerIn + '">' + template + '</div>' ); // faster than wrapInner
588
+ }
589
+ if ( c.onRenderHeader ) {
590
+ c.onRenderHeader.apply( $elem, [ index, c, c.$table ] );
591
+ }
592
+ column = parseInt( $elem.attr( 'data-column' ), 10 );
593
+ elem.column = column;
594
+ tmp = ts.getOrder( ts.getData( $elem, configHeaders, 'sortInitialOrder' ) || c.sortInitialOrder );
595
+ // this may get updated numerous times if there are multiple rows
596
+ c.sortVars[ column ] = {
597
+ count : -1, // set to -1 because clicking on the header automatically adds one
598
+ order : tmp ?
599
+ ( c.sortReset ? [ 1, 0, 2 ] : [ 1, 0 ] ) : // desc, asc, unsorted
600
+ ( c.sortReset ? [ 0, 1, 2 ] : [ 0, 1 ] ), // asc, desc, unsorted
601
+ lockedOrder : false,
602
+ sortedBy : ''
603
+ };
604
+ tmp = ts.getData( $elem, configHeaders, 'lockedOrder' ) || false;
605
+ if ( typeof tmp !== 'undefined' && tmp !== false ) {
606
+ c.sortVars[ column ].lockedOrder = true;
607
+ c.sortVars[ column ].order = ts.getOrder( tmp ) ? [ 1, 1 ] : [ 0, 0 ];
608
+ }
609
+ // add cell to headerList
610
+ c.headerList[ index ] = elem;
611
+ $elem.addClass( ts.css.header + ' ' + c.cssHeader );
612
+ // add to parent in case there are multiple rows
613
+ ts.getClosest( $elem, 'tr' )
614
+ .addClass( ts.css.headerRow + ' ' + c.cssHeaderRow )
615
+ .attr( 'role', 'row' );
616
+ // allow keyboard cursor to focus on element
617
+ if ( c.tabIndex ) {
618
+ $elem.attr( 'tabindex', 0 );
619
+ }
620
+ return elem;
621
+ }) );
622
+ // cache headers per column
623
+ c.$headerIndexed = [];
624
+ for ( indx = 0; indx < c.columns; indx++ ) {
625
+ // colspan in header making a column undefined
626
+ if ( ts.isEmptyObject( c.sortVars[ indx ] ) ) {
627
+ c.sortVars[ indx ] = {};
628
+ }
629
+ // Use c.$headers.parent() in case selectorHeaders doesn't point to the th/td
630
+ $temp = c.$headers.filter( '[data-column="' + indx + '"]' );
631
+ // target sortable column cells, unless there are none, then use non-sortable cells
632
+ // .last() added in jQuery 1.4; use .filter(':last') to maintain compatibility with jQuery v1.2.6
633
+ c.$headerIndexed[ indx ] = $temp.length ?
634
+ $temp.not( '.sorter-false' ).length ?
635
+ $temp.not( '.sorter-false' ).filter( ':last' ) :
636
+ $temp.filter( ':last' ) :
637
+ $();
638
+ }
639
+ c.$table.find( c.selectorHeaders ).attr({
640
+ scope: 'col',
641
+ role : 'columnheader'
642
+ });
643
+ // enable/disable sorting
644
+ ts.updateHeader( c );
645
+ if ( ts.debug(c, 'core') ) {
646
+ console.log( 'Built headers:' + ts.benchmark( timer ) );
647
+ console.log( c.$headers );
648
+ }
649
+ },
650
+
651
+ // Use it to add a set of methods to table.config which will be available for all tables.
652
+ // This should be done before table initialization
653
+ addInstanceMethods : function( methods ) {
654
+ $.extend( ts.instanceMethods, methods );
655
+ },
656
+
657
+ /*
658
+ █████▄ ▄████▄ █████▄ ▄█████ ██████ █████▄ ▄█████
659
+ ██▄▄██ ██▄▄██ ██▄▄██ ▀█▄ ██▄▄ ██▄▄██ ▀█▄
660
+ ██▀▀▀ ██▀▀██ ██▀██ ▀█▄ ██▀▀ ██▀██ ▀█▄
661
+ ██ ██ ██ ██ ██ █████▀ ██████ ██ ██ █████▀
662
+ */
663
+ setupParsers : function( c, $tbodies ) {
664
+ var rows, list, span, max, colIndex, indx, header, configHeaders,
665
+ noParser, parser, extractor, time, tbody, len,
666
+ table = c.table,
667
+ tbodyIndex = 0,
668
+ debug = ts.debug(c, 'core'),
669
+ debugOutput = {};
670
+ // update table bodies in case we start with an empty table
671
+ c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
672
+ tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
673
+ len = tbody.length;
674
+ if ( len === 0 ) {
675
+ return debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : '';
676
+ } else if ( debug ) {
677
+ time = new Date();
678
+ console[ console.group ? 'group' : 'log' ]( 'Detecting parsers for each column' );
679
+ }
680
+ list = {
681
+ extractors: [],
682
+ parsers: []
683
+ };
684
+ while ( tbodyIndex < len ) {
685
+ rows = tbody[ tbodyIndex ].rows;
686
+ if ( rows.length ) {
687
+ colIndex = 0;
688
+ max = c.columns;
689
+ for ( indx = 0; indx < max; indx++ ) {
690
+ header = c.$headerIndexed[ colIndex ];
691
+ if ( header && header.length ) {
692
+ // get column indexed table cell; adding true parameter fixes #1362 but
693
+ // it would break backwards compatibility...
694
+ configHeaders = ts.getColumnData( table, c.headers, colIndex ); // , true );
695
+ // get column parser/extractor
696
+ extractor = ts.getParserById( ts.getData( header, configHeaders, 'extractor' ) );
697
+ parser = ts.getParserById( ts.getData( header, configHeaders, 'sorter' ) );
698
+ noParser = ts.getData( header, configHeaders, 'parser' ) === 'false';
699
+ // empty cells behaviour - keeping emptyToBottom for backwards compatibility
700
+ c.empties[colIndex] = (
701
+ ts.getData( header, configHeaders, 'empty' ) ||
702
+ c.emptyTo || ( c.emptyToBottom ? 'bottom' : 'top' ) ).toLowerCase();
703
+ // text strings behaviour in numerical sorts
704
+ c.strings[colIndex] = (
705
+ ts.getData( header, configHeaders, 'string' ) ||
706
+ c.stringTo ||
707
+ 'max' ).toLowerCase();
708
+ if ( noParser ) {
709
+ parser = ts.getParserById( 'no-parser' );
710
+ }
711
+ if ( !extractor ) {
712
+ // For now, maybe detect someday
713
+ extractor = false;
714
+ }
715
+ if ( !parser ) {
716
+ parser = ts.detectParserForColumn( c, rows, -1, colIndex );
717
+ }
718
+ if ( debug ) {
719
+ debugOutput[ '(' + colIndex + ') ' + header.text() ] = {
720
+ parser : parser.id,
721
+ extractor : extractor ? extractor.id : 'none',
722
+ string : c.strings[ colIndex ],
723
+ empty : c.empties[ colIndex ]
724
+ };
725
+ }
726
+ list.parsers[ colIndex ] = parser;
727
+ list.extractors[ colIndex ] = extractor;
728
+ span = header[ 0 ].colSpan - 1;
729
+ if ( span > 0 ) {
730
+ colIndex += span;
731
+ max += span;
732
+ while ( span + 1 > 0 ) {
733
+ // set colspan columns to use the same parsers & extractors
734
+ list.parsers[ colIndex - span ] = parser;
735
+ list.extractors[ colIndex - span ] = extractor;
736
+ span--;
737
+ }
738
+ }
739
+ }
740
+ colIndex++;
741
+ }
742
+ }
743
+ tbodyIndex += ( list.parsers.length ) ? len : 1;
744
+ }
745
+ if ( debug ) {
746
+ if ( !ts.isEmptyObject( debugOutput ) ) {
747
+ console[ console.table ? 'table' : 'log' ]( debugOutput );
748
+ } else {
749
+ console.warn( ' No parsers detected!' );
750
+ }
751
+ console.log( 'Completed detecting parsers' + ts.benchmark( time ) );
752
+ if ( console.groupEnd ) { console.groupEnd(); }
753
+ }
754
+ c.parsers = list.parsers;
755
+ c.extractors = list.extractors;
756
+ },
757
+
758
+ addParser : function( parser ) {
759
+ var indx,
760
+ len = ts.parsers.length,
761
+ add = true;
762
+ for ( indx = 0; indx < len; indx++ ) {
763
+ if ( ts.parsers[ indx ].id.toLowerCase() === parser.id.toLowerCase() ) {
764
+ add = false;
765
+ }
766
+ }
767
+ if ( add ) {
768
+ ts.parsers[ ts.parsers.length ] = parser;
769
+ }
770
+ },
771
+
772
+ getParserById : function( name ) {
773
+ /*jshint eqeqeq:false */ // eslint-disable-next-line eqeqeq
774
+ if ( name == 'false' ) { return false; }
775
+ var indx,
776
+ len = ts.parsers.length;
777
+ for ( indx = 0; indx < len; indx++ ) {
778
+ if ( ts.parsers[ indx ].id.toLowerCase() === ( name.toString() ).toLowerCase() ) {
779
+ return ts.parsers[ indx ];
780
+ }
781
+ }
782
+ return false;
783
+ },
784
+
785
+ detectParserForColumn : function( c, rows, rowIndex, cellIndex ) {
786
+ var cur, $node, row,
787
+ indx = ts.parsers.length,
788
+ node = false,
789
+ nodeValue = '',
790
+ debug = ts.debug(c, 'core'),
791
+ keepLooking = true;
792
+ while ( nodeValue === '' && keepLooking ) {
793
+ rowIndex++;
794
+ row = rows[ rowIndex ];
795
+ // stop looking after 50 empty rows
796
+ if ( row && rowIndex < 50 ) {
797
+ if ( row.className.indexOf( ts.cssIgnoreRow ) < 0 ) {
798
+ node = rows[ rowIndex ].cells[ cellIndex ];
799
+ nodeValue = ts.getElementText( c, node, cellIndex );
800
+ $node = $( node );
801
+ if ( debug ) {
802
+ console.log( 'Checking if value was empty on row ' + rowIndex + ', column: ' +
803
+ cellIndex + ': "' + nodeValue + '"' );
804
+ }
805
+ }
806
+ } else {
807
+ keepLooking = false;
808
+ }
809
+ }
810
+ while ( --indx >= 0 ) {
811
+ cur = ts.parsers[ indx ];
812
+ // ignore the default text parser because it will always be true
813
+ if ( cur && cur.id !== 'text' && cur.is && cur.is( nodeValue, c.table, node, $node ) ) {
814
+ return cur;
815
+ }
816
+ }
817
+ // nothing found, return the generic parser (text)
818
+ return ts.getParserById( 'text' );
819
+ },
820
+
821
+ getElementText : function( c, node, cellIndex ) {
822
+ if ( !node ) { return ''; }
823
+ var tmp,
824
+ extract = c.textExtraction || '',
825
+ // node could be a jquery object
826
+ // http://jsperf.com/jquery-vs-instanceof-jquery/2
827
+ $node = node.jquery ? node : $( node );
828
+ if ( typeof extract === 'string' ) {
829
+ // check data-attribute first when set to 'basic'; don't use node.innerText - it's really slow!
830
+ // http://www.kellegous.com/j/2013/02/27/innertext-vs-textcontent/
831
+ if ( extract === 'basic' && typeof ( tmp = $node.attr( c.textAttribute ) ) !== 'undefined' ) {
832
+ return $.trim( tmp );
833
+ }
834
+ return $.trim( node.textContent || $node.text() );
835
+ } else {
836
+ if ( typeof extract === 'function' ) {
837
+ return $.trim( extract( $node[ 0 ], c.table, cellIndex ) );
838
+ } else if ( typeof ( tmp = ts.getColumnData( c.table, extract, cellIndex ) ) === 'function' ) {
839
+ return $.trim( tmp( $node[ 0 ], c.table, cellIndex ) );
840
+ }
841
+ }
842
+ // fallback
843
+ return $.trim( $node[ 0 ].textContent || $node.text() );
844
+ },
845
+
846
+ // centralized function to extract/parse cell contents
847
+ getParsedText : function( c, cell, colIndex, txt ) {
848
+ if ( typeof txt === 'undefined' ) {
849
+ txt = ts.getElementText( c, cell, colIndex );
850
+ }
851
+ // if no parser, make sure to return the txt
852
+ var val = '' + txt,
853
+ parser = c.parsers[ colIndex ],
854
+ extractor = c.extractors[ colIndex ];
855
+ if ( parser ) {
856
+ // do extract before parsing, if there is one
857
+ if ( extractor && typeof extractor.format === 'function' ) {
858
+ txt = extractor.format( txt, c.table, cell, colIndex );
859
+ }
860
+ // allow parsing if the string is empty, previously parsing would change it to zero,
861
+ // in case the parser needs to extract data from the table cell attributes
862
+ val = parser.id === 'no-parser' ? '' :
863
+ // make sure txt is a string (extractor may have converted it)
864
+ parser.format( '' + txt, c.table, cell, colIndex );
865
+ if ( c.ignoreCase && typeof val === 'string' ) {
866
+ val = val.toLowerCase();
867
+ }
868
+ }
869
+ return val;
870
+ },
871
+
872
+ /*
873
+ ▄████▄ ▄████▄ ▄████▄ ██ ██ ██████
874
+ ██ ▀▀ ██▄▄██ ██ ▀▀ ██▄▄██ ██▄▄
875
+ ██ ▄▄ ██▀▀██ ██ ▄▄ ██▀▀██ ██▀▀
876
+ ▀████▀ ██ ██ ▀████▀ ██ ██ ██████
877
+ */
878
+ buildCache : function( c, callback, $tbodies ) {
879
+ var cache, val, txt, rowIndex, colIndex, tbodyIndex, $tbody, $row,
880
+ cols, $cells, cell, cacheTime, totalRows, rowData, prevRowData,
881
+ colMax, span, cacheIndex, hasParser, max, len, index,
882
+ table = c.table,
883
+ parsers = c.parsers,
884
+ debug = ts.debug(c, 'core');
885
+ // update tbody variable
886
+ c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
887
+ $tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies,
888
+ c.cache = {};
889
+ c.totalRows = 0;
890
+ // if no parsers found, return - it's an empty table.
891
+ if ( !parsers ) {
892
+ return debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : '';
893
+ }
894
+ if ( debug ) {
895
+ cacheTime = new Date();
896
+ }
897
+ // processing icon
898
+ if ( c.showProcessing ) {
899
+ ts.isProcessing( table, true );
900
+ }
901
+ for ( tbodyIndex = 0; tbodyIndex < $tbody.length; tbodyIndex++ ) {
902
+ colMax = []; // column max value per tbody
903
+ cache = c.cache[ tbodyIndex ] = {
904
+ normalized: [] // array of normalized row data; last entry contains 'rowData' above
905
+ // colMax: # // added at the end
906
+ };
907
+
908
+ totalRows = ( $tbody[ tbodyIndex ] && $tbody[ tbodyIndex ].rows.length ) || 0;
909
+ for ( rowIndex = 0; rowIndex < totalRows; ++rowIndex ) {
910
+ rowData = {
911
+ // order: original row order #
912
+ // $row : jQuery Object[]
913
+ child: [], // child row text (filter widget)
914
+ raw: [] // original row text
915
+ };
916
+ /** Add the table data to main data array */
917
+ $row = $( $tbody[ tbodyIndex ].rows[ rowIndex ] );
918
+ cols = [];
919
+ // ignore "remove-me" rows
920
+ if ( $row.hasClass( c.selectorRemove.slice(1) ) ) {
921
+ continue;
922
+ }
923
+ // if this is a child row, add it to the last row's children and continue to the next row
924
+ // ignore child row class, if it is the first row
925
+ if ( $row.hasClass( c.cssChildRow ) && rowIndex !== 0 ) {
926
+ len = cache.normalized.length - 1;
927
+ prevRowData = cache.normalized[ len ][ c.columns ];
928
+ prevRowData.$row = prevRowData.$row.add( $row );
929
+ // add 'hasChild' class name to parent row
930
+ if ( !$row.prev().hasClass( c.cssChildRow ) ) {
931
+ $row.prev().addClass( ts.css.cssHasChild );
932
+ }
933
+ // save child row content (un-parsed!)
934
+ $cells = $row.children( 'th, td' );
935
+ len = prevRowData.child.length;
936
+ prevRowData.child[ len ] = [];
937
+ // child row content does not account for colspans/rowspans; so indexing may be off
938
+ cacheIndex = 0;
939
+ max = c.columns;
940
+ for ( colIndex = 0; colIndex < max; colIndex++ ) {
941
+ cell = $cells[ colIndex ];
942
+ if ( cell ) {
943
+ prevRowData.child[ len ][ colIndex ] = ts.getParsedText( c, cell, colIndex );
944
+ span = $cells[ colIndex ].colSpan - 1;
945
+ if ( span > 0 ) {
946
+ cacheIndex += span;
947
+ max += span;
948
+ }
949
+ }
950
+ cacheIndex++;
951
+ }
952
+ // go to the next for loop
953
+ continue;
954
+ }
955
+ rowData.$row = $row;
956
+ rowData.order = rowIndex; // add original row position to rowCache
957
+ cacheIndex = 0;
958
+ max = c.columns;
959
+ for ( colIndex = 0; colIndex < max; ++colIndex ) {
960
+ cell = $row[ 0 ].cells[ colIndex ];
961
+ if ( cell && cacheIndex < c.columns ) {
962
+ hasParser = typeof parsers[ cacheIndex ] !== 'undefined';
963
+ if ( !hasParser && debug ) {
964
+ console.warn( 'No parser found for row: ' + rowIndex + ', column: ' + colIndex +
965
+ '; cell containing: "' + $(cell).text() + '"; does it have a header?' );
966
+ }
967
+ val = ts.getElementText( c, cell, cacheIndex );
968
+ rowData.raw[ cacheIndex ] = val; // save original row text
969
+ // save raw column text even if there is no parser set
970
+ txt = ts.getParsedText( c, cell, cacheIndex, val );
971
+ cols[ cacheIndex ] = txt;
972
+ if ( hasParser && ( parsers[ cacheIndex ].type || '' ).toLowerCase() === 'numeric' ) {
973
+ // determine column max value (ignore sign)
974
+ colMax[ cacheIndex ] = Math.max( Math.abs( txt ) || 0, colMax[ cacheIndex ] || 0 );
975
+ }
976
+ // allow colSpan in tbody
977
+ span = cell.colSpan - 1;
978
+ if ( span > 0 ) {
979
+ index = 0;
980
+ while ( index <= span ) {
981
+ // duplicate text (or not) to spanned columns
982
+ // instead of setting duplicate span to empty string, use textExtraction to try to get a value
983
+ // see http://stackoverflow.com/q/36449711/145346
984
+ txt = c.duplicateSpan || index === 0 ?
985
+ txt :
986
+ typeof c.textExtraction !== 'string' ?
987
+ ts.getElementText( c, cell, cacheIndex + index ) || '' :
988
+ '';
989
+ rowData.raw[ cacheIndex + index ] = txt;
990
+ cols[ cacheIndex + index ] = txt;
991
+ index++;
992
+ }
993
+ cacheIndex += span;
994
+ max += span;
995
+ }
996
+ }
997
+ cacheIndex++;
998
+ }
999
+ // ensure rowData is always in the same location (after the last column)
1000
+ cols[ c.columns ] = rowData;
1001
+ cache.normalized[ cache.normalized.length ] = cols;
1002
+ }
1003
+ cache.colMax = colMax;
1004
+ // total up rows, not including child rows
1005
+ c.totalRows += cache.normalized.length;
1006
+
1007
+ }
1008
+ if ( c.showProcessing ) {
1009
+ ts.isProcessing( table ); // remove processing icon
1010
+ }
1011
+ if ( debug ) {
1012
+ len = Math.min( 5, c.cache[ 0 ].normalized.length );
1013
+ console[ console.group ? 'group' : 'log' ]( 'Building cache for ' + c.totalRows +
1014
+ ' rows (showing ' + len + ' rows in log) and ' + c.columns + ' columns' +
1015
+ ts.benchmark( cacheTime ) );
1016
+ val = {};
1017
+ for ( colIndex = 0; colIndex < c.columns; colIndex++ ) {
1018
+ for ( cacheIndex = 0; cacheIndex < len; cacheIndex++ ) {
1019
+ if ( !val[ 'row: ' + cacheIndex ] ) {
1020
+ val[ 'row: ' + cacheIndex ] = {};
1021
+ }
1022
+ val[ 'row: ' + cacheIndex ][ c.$headerIndexed[ colIndex ].text() ] =
1023
+ c.cache[ 0 ].normalized[ cacheIndex ][ colIndex ];
1024
+ }
1025
+ }
1026
+ console[ console.table ? 'table' : 'log' ]( val );
1027
+ if ( console.groupEnd ) { console.groupEnd(); }
1028
+ }
1029
+ if ( $.isFunction( callback ) ) {
1030
+ callback( table );
1031
+ }
1032
+ },
1033
+
1034
+ getColumnText : function( table, column, callback, rowFilter ) {
1035
+ table = $( table )[0];
1036
+ var tbodyIndex, rowIndex, cache, row, tbodyLen, rowLen, raw, parsed, $cell, result,
1037
+ hasCallback = typeof callback === 'function',
1038
+ allColumns = column === 'all',
1039
+ data = { raw : [], parsed: [], $cell: [] },
1040
+ c = table.config;
1041
+ if ( ts.isEmptyObject( c ) ) {
1042
+ if ( ts.debug(c, 'core') ) {
1043
+ console.warn( 'No cache found - aborting getColumnText function!' );
1044
+ }
1045
+ } else {
1046
+ tbodyLen = c.$tbodies.length;
1047
+ for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
1048
+ cache = c.cache[ tbodyIndex ].normalized;
1049
+ rowLen = cache.length;
1050
+ for ( rowIndex = 0; rowIndex < rowLen; rowIndex++ ) {
1051
+ row = cache[ rowIndex ];
1052
+ if ( rowFilter && !row[ c.columns ].$row.is( rowFilter ) ) {
1053
+ continue;
1054
+ }
1055
+ result = true;
1056
+ parsed = ( allColumns ) ? row.slice( 0, c.columns ) : row[ column ];
1057
+ row = row[ c.columns ];
1058
+ raw = ( allColumns ) ? row.raw : row.raw[ column ];
1059
+ $cell = ( allColumns ) ? row.$row.children() : row.$row.children().eq( column );
1060
+ if ( hasCallback ) {
1061
+ result = callback({
1062
+ tbodyIndex : tbodyIndex,
1063
+ rowIndex : rowIndex,
1064
+ parsed : parsed,
1065
+ raw : raw,
1066
+ $row : row.$row,
1067
+ $cell : $cell
1068
+ });
1069
+ }
1070
+ if ( result !== false ) {
1071
+ data.parsed[ data.parsed.length ] = parsed;
1072
+ data.raw[ data.raw.length ] = raw;
1073
+ data.$cell[ data.$cell.length ] = $cell;
1074
+ }
1075
+ }
1076
+ }
1077
+ // return everything
1078
+ return data;
1079
+ }
1080
+ },
1081
+
1082
+ /*
1083
+ ██ ██ █████▄ █████▄ ▄████▄ ██████ ██████
1084
+ ██ ██ ██▄▄██ ██ ██ ██▄▄██ ██ ██▄▄
1085
+ ██ ██ ██▀▀▀ ██ ██ ██▀▀██ ██ ██▀▀
1086
+ ▀████▀ ██ █████▀ ██ ██ ██ ██████
1087
+ */
1088
+ setHeadersCss : function( c ) {
1089
+ var indx, column,
1090
+ list = c.sortList,
1091
+ len = list.length,
1092
+ none = ts.css.sortNone + ' ' + c.cssNone,
1093
+ css = [ ts.css.sortAsc + ' ' + c.cssAsc, ts.css.sortDesc + ' ' + c.cssDesc ],
1094
+ cssIcon = [ c.cssIconAsc, c.cssIconDesc, c.cssIconNone ],
1095
+ aria = [ 'ascending', 'descending' ],
1096
+ updateColumnSort = function($el, index) {
1097
+ $el
1098
+ .removeClass( none )
1099
+ .addClass( css[ index ] )
1100
+ .attr( 'aria-sort', aria[ index ] )
1101
+ .find( '.' + ts.css.icon )
1102
+ .removeClass( cssIcon[ 2 ] )
1103
+ .addClass( cssIcon[ index ] );
1104
+ },
1105
+ // find the footer
1106
+ $extras = c.$table
1107
+ .find( 'tfoot tr' )
1108
+ .children( 'td, th' )
1109
+ .add( $( c.namespace + '_extra_headers' ) )
1110
+ .removeClass( css.join( ' ' ) ),
1111
+ // remove all header information
1112
+ $sorted = c.$headers
1113
+ .add( $( 'thead ' + c.namespace + '_extra_headers' ) )
1114
+ .removeClass( css.join( ' ' ) )
1115
+ .addClass( none )
1116
+ .attr( 'aria-sort', 'none' )
1117
+ .find( '.' + ts.css.icon )
1118
+ .removeClass( cssIcon.join( ' ' ) )
1119
+ .end();
1120
+ // add css none to all sortable headers
1121
+ $sorted
1122
+ .not( '.sorter-false' )
1123
+ .find( '.' + ts.css.icon )
1124
+ .addClass( cssIcon[ 2 ] );
1125
+ // add disabled css icon class
1126
+ if ( c.cssIconDisabled ) {
1127
+ $sorted
1128
+ .filter( '.sorter-false' )
1129
+ .find( '.' + ts.css.icon )
1130
+ .addClass( c.cssIconDisabled );
1131
+ }
1132
+ for ( indx = 0; indx < len; indx++ ) {
1133
+ // direction = 2 means reset!
1134
+ if ( list[ indx ][ 1 ] !== 2 ) {
1135
+ // multicolumn sorting updating - see #1005
1136
+ // .not(function() {}) needs jQuery 1.4
1137
+ // filter(function(i, el) {}) <- el is undefined in jQuery v1.2.6
1138
+ $sorted = c.$headers.filter( function( i ) {
1139
+ // only include headers that are in the sortList (this includes colspans)
1140
+ var include = true,
1141
+ $el = c.$headers.eq( i ),
1142
+ col = parseInt( $el.attr( 'data-column' ), 10 ),
1143
+ end = col + ts.getClosest( $el, 'th, td' )[0].colSpan;
1144
+ for ( ; col < end; col++ ) {
1145
+ include = include ? include || ts.isValueInArray( col, c.sortList ) > -1 : false;
1146
+ }
1147
+ return include;
1148
+ });
1149
+
1150
+ // choose the :last in case there are nested columns
1151
+ $sorted = $sorted
1152
+ .not( '.sorter-false' )
1153
+ .filter( '[data-column="' + list[ indx ][ 0 ] + '"]' + ( len === 1 ? ':last' : '' ) );
1154
+ if ( $sorted.length ) {
1155
+ for ( column = 0; column < $sorted.length; column++ ) {
1156
+ if ( !$sorted[ column ].sortDisabled ) {
1157
+ updateColumnSort( $sorted.eq( column ), list[ indx ][ 1 ] );
1158
+ }
1159
+ }
1160
+ }
1161
+ // add sorted class to footer & extra headers, if they exist
1162
+ if ( $extras.length ) {
1163
+ updateColumnSort( $extras.filter( '[data-column="' + list[ indx ][ 0 ] + '"]' ), list[ indx ][ 1 ] );
1164
+ }
1165
+ }
1166
+ }
1167
+ // add verbose aria labels
1168
+ len = c.$headers.length;
1169
+ for ( indx = 0; indx < len; indx++ ) {
1170
+ ts.setColumnAriaLabel( c, c.$headers.eq( indx ) );
1171
+ }
1172
+ },
1173
+
1174
+ getClosest : function( $el, selector ) {
1175
+ // jQuery v1.2.6 doesn't have closest()
1176
+ if ( $.fn.closest ) {
1177
+ return $el.closest( selector );
1178
+ }
1179
+ return $el.is( selector ) ?
1180
+ $el :
1181
+ $el.parents( selector ).filter( ':first' );
1182
+ },
1183
+
1184
+ // nextSort (optional), lets you disable next sort text
1185
+ setColumnAriaLabel : function( c, $header, nextSort ) {
1186
+ if ( $header.length ) {
1187
+ var column = parseInt( $header.attr( 'data-column' ), 10 ),
1188
+ vars = c.sortVars[ column ],
1189
+ tmp = $header.hasClass( ts.css.sortAsc ) ?
1190
+ 'sortAsc' :
1191
+ $header.hasClass( ts.css.sortDesc ) ? 'sortDesc' : 'sortNone',
1192
+ txt = $.trim( $header.text() ) + ': ' + ts.language[ tmp ];
1193
+ if ( $header.hasClass( 'sorter-false' ) || nextSort === false ) {
1194
+ txt += ts.language.sortDisabled;
1195
+ } else {
1196
+ tmp = ( vars.count + 1 ) % vars.order.length;
1197
+ nextSort = vars.order[ tmp ];
1198
+ // if nextSort
1199
+ txt += ts.language[ nextSort === 0 ? 'nextAsc' : nextSort === 1 ? 'nextDesc' : 'nextNone' ];
1200
+ }
1201
+ $header.attr( 'aria-label', txt );
1202
+ if (vars.sortedBy) {
1203
+ $header.attr( 'data-sortedBy', vars.sortedBy );
1204
+ } else {
1205
+ $header.removeAttr('data-sortedBy');
1206
+ }
1207
+ }
1208
+ },
1209
+
1210
+ updateHeader : function( c ) {
1211
+ var index, isDisabled, $header, col,
1212
+ table = c.table,
1213
+ len = c.$headers.length;
1214
+ for ( index = 0; index < len; index++ ) {
1215
+ $header = c.$headers.eq( index );
1216
+ col = ts.getColumnData( table, c.headers, index, true );
1217
+ // add 'sorter-false' class if 'parser-false' is set
1218
+ isDisabled = ts.getData( $header, col, 'sorter' ) === 'false' || ts.getData( $header, col, 'parser' ) === 'false';
1219
+ ts.setColumnSort( c, $header, isDisabled );
1220
+ }
1221
+ },
1222
+
1223
+ setColumnSort : function( c, $header, isDisabled ) {
1224
+ var id = c.table.id;
1225
+ $header[ 0 ].sortDisabled = isDisabled;
1226
+ $header[ isDisabled ? 'addClass' : 'removeClass' ]( 'sorter-false' )
1227
+ .attr( 'aria-disabled', '' + isDisabled );
1228
+ // disable tab index on disabled cells
1229
+ if ( c.tabIndex ) {
1230
+ if ( isDisabled ) {
1231
+ $header.removeAttr( 'tabindex' );
1232
+ } else {
1233
+ $header.attr( 'tabindex', '0' );
1234
+ }
1235
+ }
1236
+ // aria-controls - requires table ID
1237
+ if ( id ) {
1238
+ if ( isDisabled ) {
1239
+ $header.removeAttr( 'aria-controls' );
1240
+ } else {
1241
+ $header.attr( 'aria-controls', id );
1242
+ }
1243
+ }
1244
+ },
1245
+
1246
+ updateHeaderSortCount : function( c, list ) {
1247
+ var col, dir, group, indx, primary, temp, val, order,
1248
+ sortList = list || c.sortList,
1249
+ len = sortList.length;
1250
+ c.sortList = [];
1251
+ for ( indx = 0; indx < len; indx++ ) {
1252
+ val = sortList[ indx ];
1253
+ // ensure all sortList values are numeric - fixes #127
1254
+ col = parseInt( val[ 0 ], 10 );
1255
+ // prevents error if sorton array is wrong
1256
+ if ( col < c.columns ) {
1257
+
1258
+ // set order if not already defined - due to colspan header without associated header cell
1259
+ // adding this check prevents a javascript error
1260
+ if ( !c.sortVars[ col ].order ) {
1261
+ if ( ts.getOrder( c.sortInitialOrder ) ) {
1262
+ order = c.sortReset ? [ 1, 0, 2 ] : [ 1, 0 ];
1263
+ } else {
1264
+ order = c.sortReset ? [ 0, 1, 2 ] : [ 0, 1 ];
1265
+ }
1266
+ c.sortVars[ col ].order = order;
1267
+ c.sortVars[ col ].count = 0;
1268
+ }
1269
+
1270
+ order = c.sortVars[ col ].order;
1271
+ dir = ( '' + val[ 1 ] ).match( /^(1|d|s|o|n)/ );
1272
+ dir = dir ? dir[ 0 ] : '';
1273
+ // 0/(a)sc (default), 1/(d)esc, (s)ame, (o)pposite, (n)ext
1274
+ switch ( dir ) {
1275
+ case '1' : case 'd' : // descending
1276
+ dir = 1;
1277
+ break;
1278
+ case 's' : // same direction (as primary column)
1279
+ // if primary sort is set to 's', make it ascending
1280
+ dir = primary || 0;
1281
+ break;
1282
+ case 'o' :
1283
+ temp = order[ ( primary || 0 ) % order.length ];
1284
+ // opposite of primary column; but resets if primary resets
1285
+ dir = temp === 0 ? 1 : temp === 1 ? 0 : 2;
1286
+ break;
1287
+ case 'n' :
1288
+ dir = order[ ( ++c.sortVars[ col ].count ) % order.length ];
1289
+ break;
1290
+ default : // ascending
1291
+ dir = 0;
1292
+ break;
1293
+ }
1294
+ primary = indx === 0 ? dir : primary;
1295
+ group = [ col, parseInt( dir, 10 ) || 0 ];
1296
+ c.sortList[ c.sortList.length ] = group;
1297
+ dir = $.inArray( group[ 1 ], order ); // fixes issue #167
1298
+ c.sortVars[ col ].count = dir >= 0 ? dir : group[ 1 ] % order.length;
1299
+ }
1300
+ }
1301
+ },
1302
+
1303
+ updateAll : function( c, resort, callback ) {
1304
+ var table = c.table;
1305
+ table.isUpdating = true;
1306
+ ts.refreshWidgets( table, true, true );
1307
+ ts.buildHeaders( c );
1308
+ ts.bindEvents( table, c.$headers, true );
1309
+ ts.bindMethods( c );
1310
+ ts.commonUpdate( c, resort, callback );
1311
+ },
1312
+
1313
+ update : function( c, resort, callback ) {
1314
+ var table = c.table;
1315
+ table.isUpdating = true;
1316
+ // update sorting (if enabled/disabled)
1317
+ ts.updateHeader( c );
1318
+ ts.commonUpdate( c, resort, callback );
1319
+ },
1320
+
1321
+ // simple header update - see #989
1322
+ updateHeaders : function( c, callback ) {
1323
+ c.table.isUpdating = true;
1324
+ ts.buildHeaders( c );
1325
+ ts.bindEvents( c.table, c.$headers, true );
1326
+ ts.resortComplete( c, callback );
1327
+ },
1328
+
1329
+ updateCell : function( c, cell, resort, callback ) {
1330
+ // updateCell for child rows is a mess - we'll ignore them for now
1331
+ // eventually I'll break out the "update" row cache code to make everything consistent
1332
+ if ( $( cell ).closest( 'tr' ).hasClass( c.cssChildRow ) ) {
1333
+ console.warn('Tablesorter Warning! "updateCell" for child row content has been disabled, use "update" instead');
1334
+ return;
1335
+ }
1336
+ if ( ts.isEmptyObject( c.cache ) ) {
1337
+ // empty table, do an update instead - fixes #1099
1338
+ ts.updateHeader( c );
1339
+ ts.commonUpdate( c, resort, callback );
1340
+ return;
1341
+ }
1342
+ c.table.isUpdating = true;
1343
+ c.$table.find( c.selectorRemove ).remove();
1344
+ // get position from the dom
1345
+ var tmp, indx, row, icell, cache, len,
1346
+ $tbodies = c.$tbodies,
1347
+ $cell = $( cell ),
1348
+ // update cache - format: function( s, table, cell, cellIndex )
1349
+ // no closest in jQuery v1.2.6
1350
+ tbodyIndex = $tbodies.index( ts.getClosest( $cell, 'tbody' ) ),
1351
+ tbcache = c.cache[ tbodyIndex ],
1352
+ $row = ts.getClosest( $cell, 'tr' );
1353
+ cell = $cell[ 0 ]; // in case cell is a jQuery object
1354
+ // tbody may not exist if update is initialized while tbody is removed for processing
1355
+ if ( $tbodies.length && tbodyIndex >= 0 ) {
1356
+ row = $tbodies.eq( tbodyIndex ).find( 'tr' ).not( '.' + c.cssChildRow ).index( $row );
1357
+ cache = tbcache.normalized[ row ];
1358
+ len = $row[ 0 ].cells.length;
1359
+ if ( len !== c.columns ) {
1360
+ // colspan in here somewhere!
1361
+ icell = 0;
1362
+ tmp = false;
1363
+ for ( indx = 0; indx < len; indx++ ) {
1364
+ if ( !tmp && $row[ 0 ].cells[ indx ] !== cell ) {
1365
+ icell += $row[ 0 ].cells[ indx ].colSpan;
1366
+ } else {
1367
+ tmp = true;
1368
+ }
1369
+ }
1370
+ } else {
1371
+ icell = $cell.index();
1372
+ }
1373
+ tmp = ts.getElementText( c, cell, icell ); // raw
1374
+ cache[ c.columns ].raw[ icell ] = tmp;
1375
+ tmp = ts.getParsedText( c, cell, icell, tmp );
1376
+ cache[ icell ] = tmp; // parsed
1377
+ if ( ( c.parsers[ icell ].type || '' ).toLowerCase() === 'numeric' ) {
1378
+ // update column max value (ignore sign)
1379
+ tbcache.colMax[ icell ] = Math.max( Math.abs( tmp ) || 0, tbcache.colMax[ icell ] || 0 );
1380
+ }
1381
+ tmp = resort !== 'undefined' ? resort : c.resort;
1382
+ if ( tmp !== false ) {
1383
+ // widgets will be reapplied
1384
+ ts.checkResort( c, tmp, callback );
1385
+ } else {
1386
+ // don't reapply widgets is resort is false, just in case it causes
1387
+ // problems with element focus
1388
+ ts.resortComplete( c, callback );
1389
+ }
1390
+ } else {
1391
+ if ( ts.debug(c, 'core') ) {
1392
+ console.error( 'updateCell aborted, tbody missing or not within the indicated table' );
1393
+ }
1394
+ c.table.isUpdating = false;
1395
+ }
1396
+ },
1397
+
1398
+ addRows : function( c, $row, resort, callback ) {
1399
+ var txt, val, tbodyIndex, rowIndex, rows, cellIndex, len, order,
1400
+ cacheIndex, rowData, cells, cell, span,
1401
+ // allow passing a row string if only one non-info tbody exists in the table
1402
+ valid = typeof $row === 'string' && c.$tbodies.length === 1 && /<tr/.test( $row || '' ),
1403
+ table = c.table;
1404
+ if ( valid ) {
1405
+ $row = $( $row );
1406
+ c.$tbodies.append( $row );
1407
+ } else if (
1408
+ !$row ||
1409
+ // row is a jQuery object?
1410
+ !( $row instanceof $ ) ||
1411
+ // row contained in the table?
1412
+ ( ts.getClosest( $row, 'table' )[ 0 ] !== c.table )
1413
+ ) {
1414
+ if ( ts.debug(c, 'core') ) {
1415
+ console.error( 'addRows method requires (1) a jQuery selector reference to rows that have already ' +
1416
+ 'been added to the table, or (2) row HTML string to be added to a table with only one tbody' );
1417
+ }
1418
+ return false;
1419
+ }
1420
+ table.isUpdating = true;
1421
+ if ( ts.isEmptyObject( c.cache ) ) {
1422
+ // empty table, do an update instead - fixes #450
1423
+ ts.updateHeader( c );
1424
+ ts.commonUpdate( c, resort, callback );
1425
+ } else {
1426
+ rows = $row.filter( 'tr' ).attr( 'role', 'row' ).length;
1427
+ tbodyIndex = c.$tbodies.index( $row.parents( 'tbody' ).filter( ':first' ) );
1428
+ // fixes adding rows to an empty table - see issue #179
1429
+ if ( !( c.parsers && c.parsers.length ) ) {
1430
+ ts.setupParsers( c );
1431
+ }
1432
+ // add each row
1433
+ for ( rowIndex = 0; rowIndex < rows; rowIndex++ ) {
1434
+ cacheIndex = 0;
1435
+ len = $row[ rowIndex ].cells.length;
1436
+ order = c.cache[ tbodyIndex ].normalized.length;
1437
+ cells = [];
1438
+ rowData = {
1439
+ child : [],
1440
+ raw : [],
1441
+ $row : $row.eq( rowIndex ),
1442
+ order : order
1443
+ };
1444
+ // add each cell
1445
+ for ( cellIndex = 0; cellIndex < len; cellIndex++ ) {
1446
+ cell = $row[ rowIndex ].cells[ cellIndex ];
1447
+ txt = ts.getElementText( c, cell, cacheIndex );
1448
+ rowData.raw[ cacheIndex ] = txt;
1449
+ val = ts.getParsedText( c, cell, cacheIndex, txt );
1450
+ cells[ cacheIndex ] = val;
1451
+ if ( ( c.parsers[ cacheIndex ].type || '' ).toLowerCase() === 'numeric' ) {
1452
+ // update column max value (ignore sign)
1453
+ c.cache[ tbodyIndex ].colMax[ cacheIndex ] =
1454
+ Math.max( Math.abs( val ) || 0, c.cache[ tbodyIndex ].colMax[ cacheIndex ] || 0 );
1455
+ }
1456
+ span = cell.colSpan - 1;
1457
+ if ( span > 0 ) {
1458
+ cacheIndex += span;
1459
+ }
1460
+ cacheIndex++;
1461
+ }
1462
+ // add the row data to the end
1463
+ cells[ c.columns ] = rowData;
1464
+ // update cache
1465
+ c.cache[ tbodyIndex ].normalized[ order ] = cells;
1466
+ }
1467
+ // resort using current settings
1468
+ ts.checkResort( c, resort, callback );
1469
+ }
1470
+ },
1471
+
1472
+ updateCache : function( c, callback, $tbodies ) {
1473
+ // rebuild parsers
1474
+ if ( !( c.parsers && c.parsers.length ) ) {
1475
+ ts.setupParsers( c, $tbodies );
1476
+ }
1477
+ // rebuild the cache map
1478
+ ts.buildCache( c, callback, $tbodies );
1479
+ },
1480
+
1481
+ // init flag (true) used by pager plugin to prevent widget application
1482
+ // renamed from appendToTable
1483
+ appendCache : function( c, init ) {
1484
+ var parsed, totalRows, $tbody, $curTbody, rowIndex, tbodyIndex, appendTime,
1485
+ table = c.table,
1486
+ $tbodies = c.$tbodies,
1487
+ rows = [],
1488
+ cache = c.cache;
1489
+ // empty table - fixes #206/#346
1490
+ if ( ts.isEmptyObject( cache ) ) {
1491
+ // run pager appender in case the table was just emptied
1492
+ return c.appender ? c.appender( table, rows ) :
1493
+ table.isUpdating ? c.$table.triggerHandler( 'updateComplete', table ) : ''; // Fixes #532
1494
+ }
1495
+ if ( ts.debug(c, 'core') ) {
1496
+ appendTime = new Date();
1497
+ }
1498
+ for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
1499
+ $tbody = $tbodies.eq( tbodyIndex );
1500
+ if ( $tbody.length ) {
1501
+ // detach tbody for manipulation
1502
+ $curTbody = ts.processTbody( table, $tbody, true );
1503
+ parsed = cache[ tbodyIndex ].normalized;
1504
+ totalRows = parsed.length;
1505
+ for ( rowIndex = 0; rowIndex < totalRows; rowIndex++ ) {
1506
+ rows[rows.length] = parsed[ rowIndex ][ c.columns ].$row;
1507
+ // removeRows used by the pager plugin; don't render if using ajax - fixes #411
1508
+ if ( !c.appender || ( c.pager && !c.pager.removeRows && !c.pager.ajax ) ) {
1509
+ $curTbody.append( parsed[ rowIndex ][ c.columns ].$row );
1510
+ }
1511
+ }
1512
+ // restore tbody
1513
+ ts.processTbody( table, $curTbody, false );
1514
+ }
1515
+ }
1516
+ if ( c.appender ) {
1517
+ c.appender( table, rows );
1518
+ }
1519
+ if ( ts.debug(c, 'core') ) {
1520
+ console.log( 'Rebuilt table' + ts.benchmark( appendTime ) );
1521
+ }
1522
+ // apply table widgets; but not before ajax completes
1523
+ if ( !init && !c.appender ) {
1524
+ ts.applyWidget( table );
1525
+ }
1526
+ if ( table.isUpdating ) {
1527
+ c.$table.triggerHandler( 'updateComplete', table );
1528
+ }
1529
+ },
1530
+
1531
+ commonUpdate : function( c, resort, callback ) {
1532
+ // remove rows/elements before update
1533
+ c.$table.find( c.selectorRemove ).remove();
1534
+ // rebuild parsers
1535
+ ts.setupParsers( c );
1536
+ // rebuild the cache map
1537
+ ts.buildCache( c );
1538
+ ts.checkResort( c, resort, callback );
1539
+ },
1540
+
1541
+ /*
1542
+ ▄█████ ▄████▄ █████▄ ██████ ██ █████▄ ▄████▄
1543
+ ▀█▄ ██ ██ ██▄▄██ ██ ██ ██ ██ ██ ▄▄▄
1544
+ ▀█▄ ██ ██ ██▀██ ██ ██ ██ ██ ██ ▀██
1545
+ █████▀ ▀████▀ ██ ██ ██ ██ ██ ██ ▀████▀
1546
+ */
1547
+ initSort : function( c, cell, event ) {
1548
+ if ( c.table.isUpdating ) {
1549
+ // let any updates complete before initializing a sort
1550
+ return setTimeout( function() {
1551
+ ts.initSort( c, cell, event );
1552
+ }, 50 );
1553
+ }
1554
+
1555
+ var arry, indx, headerIndx, dir, temp, tmp, $header,
1556
+ notMultiSort = !event[ c.sortMultiSortKey ],
1557
+ table = c.table,
1558
+ len = c.$headers.length,
1559
+ th = ts.getClosest( $( cell ), 'th, td' ),
1560
+ col = parseInt( th.attr( 'data-column' ), 10 ),
1561
+ sortedBy = event.type === 'mouseup' ? 'user' : event.type,
1562
+ order = c.sortVars[ col ].order;
1563
+ th = th[0];
1564
+ // Only call sortStart if sorting is enabled
1565
+ c.$table.triggerHandler( 'sortStart', table );
1566
+ // get current column sort order
1567
+ tmp = ( c.sortVars[ col ].count + 1 ) % order.length;
1568
+ c.sortVars[ col ].count = event[ c.sortResetKey ] ? 2 : tmp;
1569
+ // reset all sorts on non-current column - issue #30
1570
+ if ( c.sortRestart ) {
1571
+ for ( headerIndx = 0; headerIndx < len; headerIndx++ ) {
1572
+ $header = c.$headers.eq( headerIndx );
1573
+ tmp = parseInt( $header.attr( 'data-column' ), 10 );
1574
+ // only reset counts on columns that weren't just clicked on and if not included in a multisort
1575
+ if ( col !== tmp && ( notMultiSort || $header.hasClass( ts.css.sortNone ) ) ) {
1576
+ c.sortVars[ tmp ].count = -1;
1577
+ }
1578
+ }
1579
+ }
1580
+ // user only wants to sort on one column
1581
+ if ( notMultiSort ) {
1582
+ $.each( c.sortVars, function( i ) {
1583
+ c.sortVars[ i ].sortedBy = '';
1584
+ });
1585
+ // flush the sort list
1586
+ c.sortList = [];
1587
+ c.last.sortList = [];
1588
+ if ( c.sortForce !== null ) {
1589
+ arry = c.sortForce;
1590
+ for ( indx = 0; indx < arry.length; indx++ ) {
1591
+ if ( arry[ indx ][ 0 ] !== col ) {
1592
+ c.sortList[ c.sortList.length ] = arry[ indx ];
1593
+ c.sortVars[ arry[ indx ][ 0 ] ].sortedBy = 'sortForce';
1594
+ }
1595
+ }
1596
+ }
1597
+ // add column to sort list
1598
+ dir = order[ c.sortVars[ col ].count ];
1599
+ if ( dir < 2 ) {
1600
+ c.sortList[ c.sortList.length ] = [ col, dir ];
1601
+ c.sortVars[ col ].sortedBy = sortedBy;
1602
+ // add other columns if header spans across multiple
1603
+ if ( th.colSpan > 1 ) {
1604
+ for ( indx = 1; indx < th.colSpan; indx++ ) {
1605
+ c.sortList[ c.sortList.length ] = [ col + indx, dir ];
1606
+ // update count on columns in colSpan
1607
+ c.sortVars[ col + indx ].count = $.inArray( dir, order );
1608
+ c.sortVars[ col + indx ].sortedBy = sortedBy;
1609
+ }
1610
+ }
1611
+ }
1612
+ // multi column sorting
1613
+ } else {
1614
+ // get rid of the sortAppend before adding more - fixes issue #115 & #523
1615
+ c.sortList = $.extend( [], c.last.sortList );
1616
+
1617
+ // the user has clicked on an already sorted column
1618
+ if ( ts.isValueInArray( col, c.sortList ) >= 0 ) {
1619
+ // reverse the sorting direction
1620
+ c.sortVars[ col ].sortedBy = sortedBy;
1621
+ for ( indx = 0; indx < c.sortList.length; indx++ ) {
1622
+ tmp = c.sortList[ indx ];
1623
+ if ( tmp[ 0 ] === col ) {
1624
+ // order.count seems to be incorrect when compared to cell.count
1625
+ tmp[ 1 ] = order[ c.sortVars[ col ].count ];
1626
+ if ( tmp[1] === 2 ) {
1627
+ c.sortList.splice( indx, 1 );
1628
+ c.sortVars[ col ].count = -1;
1629
+ }
1630
+ }
1631
+ }
1632
+ } else {
1633
+ // add column to sort list array
1634
+ dir = order[ c.sortVars[ col ].count ];
1635
+ c.sortVars[ col ].sortedBy = sortedBy;
1636
+ if ( dir < 2 ) {
1637
+ c.sortList[ c.sortList.length ] = [ col, dir ];
1638
+ // add other columns if header spans across multiple
1639
+ if ( th.colSpan > 1 ) {
1640
+ for ( indx = 1; indx < th.colSpan; indx++ ) {
1641
+ c.sortList[ c.sortList.length ] = [ col + indx, dir ];
1642
+ // update count on columns in colSpan
1643
+ c.sortVars[ col + indx ].count = $.inArray( dir, order );
1644
+ c.sortVars[ col + indx ].sortedBy = sortedBy;
1645
+ }
1646
+ }
1647
+ }
1648
+ }
1649
+ }
1650
+ // save sort before applying sortAppend
1651
+ c.last.sortList = $.extend( [], c.sortList );
1652
+ if ( c.sortList.length && c.sortAppend ) {
1653
+ arry = $.isArray( c.sortAppend ) ? c.sortAppend : c.sortAppend[ c.sortList[ 0 ][ 0 ] ];
1654
+ if ( !ts.isEmptyObject( arry ) ) {
1655
+ for ( indx = 0; indx < arry.length; indx++ ) {
1656
+ if ( arry[ indx ][ 0 ] !== col && ts.isValueInArray( arry[ indx ][ 0 ], c.sortList ) < 0 ) {
1657
+ dir = arry[ indx ][ 1 ];
1658
+ temp = ( '' + dir ).match( /^(a|d|s|o|n)/ );
1659
+ if ( temp ) {
1660
+ tmp = c.sortList[ 0 ][ 1 ];
1661
+ switch ( temp[ 0 ] ) {
1662
+ case 'd' :
1663
+ dir = 1;
1664
+ break;
1665
+ case 's' :
1666
+ dir = tmp;
1667
+ break;
1668
+ case 'o' :
1669
+ dir = tmp === 0 ? 1 : 0;
1670
+ break;
1671
+ case 'n' :
1672
+ dir = ( tmp + 1 ) % order.length;
1673
+ break;
1674
+ default:
1675
+ dir = 0;
1676
+ break;
1677
+ }
1678
+ }
1679
+ c.sortList[ c.sortList.length ] = [ arry[ indx ][ 0 ], dir ];
1680
+ c.sortVars[ arry[ indx ][ 0 ] ].sortedBy = 'sortAppend';
1681
+ }
1682
+ }
1683
+ }
1684
+ }
1685
+ // sortBegin event triggered immediately before the sort
1686
+ c.$table.triggerHandler( 'sortBegin', table );
1687
+ // setTimeout needed so the processing icon shows up
1688
+ setTimeout( function() {
1689
+ // set css for headers
1690
+ ts.setHeadersCss( c );
1691
+ ts.multisort( c );
1692
+ ts.appendCache( c );
1693
+ c.$table.triggerHandler( 'sortBeforeEnd', table );
1694
+ c.$table.triggerHandler( 'sortEnd', table );
1695
+ }, 1 );
1696
+ },
1697
+
1698
+ // sort multiple columns
1699
+ multisort : function( c ) { /*jshint loopfunc:true */
1700
+ var tbodyIndex, sortTime, colMax, rows, tmp,
1701
+ table = c.table,
1702
+ sorter = [],
1703
+ dir = 0,
1704
+ textSorter = c.textSorter || '',
1705
+ sortList = c.sortList,
1706
+ sortLen = sortList.length,
1707
+ len = c.$tbodies.length;
1708
+ if ( c.serverSideSorting || ts.isEmptyObject( c.cache ) ) {
1709
+ // empty table - fixes #206/#346
1710
+ return;
1711
+ }
1712
+ if ( ts.debug(c, 'core') ) { sortTime = new Date(); }
1713
+ // cache textSorter to optimize speed
1714
+ if ( typeof textSorter === 'object' ) {
1715
+ colMax = c.columns;
1716
+ while ( colMax-- ) {
1717
+ tmp = ts.getColumnData( table, textSorter, colMax );
1718
+ if ( typeof tmp === 'function' ) {
1719
+ sorter[ colMax ] = tmp;
1720
+ }
1721
+ }
1722
+ }
1723
+ for ( tbodyIndex = 0; tbodyIndex < len; tbodyIndex++ ) {
1724
+ colMax = c.cache[ tbodyIndex ].colMax;
1725
+ rows = c.cache[ tbodyIndex ].normalized;
1726
+
1727
+ rows.sort( function( a, b ) {
1728
+ var sortIndex, num, col, order, sort, x, y;
1729
+ // rows is undefined here in IE, so don't use it!
1730
+ for ( sortIndex = 0; sortIndex < sortLen; sortIndex++ ) {
1731
+ col = sortList[ sortIndex ][ 0 ];
1732
+ order = sortList[ sortIndex ][ 1 ];
1733
+ // sort direction, true = asc, false = desc
1734
+ dir = order === 0;
1735
+
1736
+ if ( c.sortStable && a[ col ] === b[ col ] && sortLen === 1 ) {
1737
+ return a[ c.columns ].order - b[ c.columns ].order;
1738
+ }
1739
+
1740
+ // fallback to natural sort since it is more robust
1741
+ num = /n/i.test( ts.getSortType( c.parsers, col ) );
1742
+ if ( num && c.strings[ col ] ) {
1743
+ // sort strings in numerical columns
1744
+ if ( typeof ( ts.string[ c.strings[ col ] ] ) === 'boolean' ) {
1745
+ num = ( dir ? 1 : -1 ) * ( ts.string[ c.strings[ col ] ] ? -1 : 1 );
1746
+ } else {
1747
+ num = ( c.strings[ col ] ) ? ts.string[ c.strings[ col ] ] || 0 : 0;
1748
+ }
1749
+ // fall back to built-in numeric sort
1750
+ // var sort = $.tablesorter['sort' + s]( a[col], b[col], dir, colMax[col], table );
1751
+ sort = c.numberSorter ? c.numberSorter( a[ col ], b[ col ], dir, colMax[ col ], table ) :
1752
+ ts[ 'sortNumeric' + ( dir ? 'Asc' : 'Desc' ) ]( a[ col ], b[ col ], num, colMax[ col ], col, c );
1753
+ } else {
1754
+ // set a & b depending on sort direction
1755
+ x = dir ? a : b;
1756
+ y = dir ? b : a;
1757
+ // text sort function
1758
+ if ( typeof textSorter === 'function' ) {
1759
+ // custom OVERALL text sorter
1760
+ sort = textSorter( x[ col ], y[ col ], dir, col, table );
1761
+ } else if ( typeof sorter[ col ] === 'function' ) {
1762
+ // custom text sorter for a SPECIFIC COLUMN
1763
+ sort = sorter[ col ]( x[ col ], y[ col ], dir, col, table );
1764
+ } else {
1765
+ // fall back to natural sort
1766
+ sort = ts[ 'sortNatural' + ( dir ? 'Asc' : 'Desc' ) ]( a[ col ] || '', b[ col ] || '', col, c );
1767
+ }
1768
+ }
1769
+ if ( sort ) { return sort; }
1770
+ }
1771
+ return a[ c.columns ].order - b[ c.columns ].order;
1772
+ });
1773
+ }
1774
+ if ( ts.debug(c, 'core') ) {
1775
+ console.log( 'Applying sort ' + sortList.toString() + ts.benchmark( sortTime ) );
1776
+ }
1777
+ },
1778
+
1779
+ resortComplete : function( c, callback ) {
1780
+ if ( c.table.isUpdating ) {
1781
+ c.$table.triggerHandler( 'updateComplete', c.table );
1782
+ }
1783
+ if ( $.isFunction( callback ) ) {
1784
+ callback( c.table );
1785
+ }
1786
+ },
1787
+
1788
+ checkResort : function( c, resort, callback ) {
1789
+ var sortList = $.isArray( resort ) ? resort : c.sortList,
1790
+ // if no resort parameter is passed, fallback to config.resort (true by default)
1791
+ resrt = typeof resort === 'undefined' ? c.resort : resort;
1792
+ // don't try to resort if the table is still processing
1793
+ // this will catch spamming of the updateCell method
1794
+ if ( resrt !== false && !c.serverSideSorting && !c.table.isProcessing ) {
1795
+ if ( sortList.length ) {
1796
+ ts.sortOn( c, sortList, function() {
1797
+ ts.resortComplete( c, callback );
1798
+ }, true );
1799
+ } else {
1800
+ ts.sortReset( c, function() {
1801
+ ts.resortComplete( c, callback );
1802
+ ts.applyWidget( c.table, false );
1803
+ } );
1804
+ }
1805
+ } else {
1806
+ ts.resortComplete( c, callback );
1807
+ ts.applyWidget( c.table, false );
1808
+ }
1809
+ },
1810
+
1811
+ sortOn : function( c, list, callback, init ) {
1812
+ var indx,
1813
+ table = c.table;
1814
+ c.$table.triggerHandler( 'sortStart', table );
1815
+ for (indx = 0; indx < c.columns; indx++) {
1816
+ c.sortVars[ indx ].sortedBy = ts.isValueInArray( indx, list ) > -1 ? 'sorton' : '';
1817
+ }
1818
+ // update header count index
1819
+ ts.updateHeaderSortCount( c, list );
1820
+ // set css for headers
1821
+ ts.setHeadersCss( c );
1822
+ // fixes #346
1823
+ if ( c.delayInit && ts.isEmptyObject( c.cache ) ) {
1824
+ ts.buildCache( c );
1825
+ }
1826
+ c.$table.triggerHandler( 'sortBegin', table );
1827
+ // sort the table and append it to the dom
1828
+ ts.multisort( c );
1829
+ ts.appendCache( c, init );
1830
+ c.$table.triggerHandler( 'sortBeforeEnd', table );
1831
+ c.$table.triggerHandler( 'sortEnd', table );
1832
+ ts.applyWidget( table );
1833
+ if ( $.isFunction( callback ) ) {
1834
+ callback( table );
1835
+ }
1836
+ },
1837
+
1838
+ sortReset : function( c, callback ) {
1839
+ c.sortList = [];
1840
+ var indx;
1841
+ for (indx = 0; indx < c.columns; indx++) {
1842
+ c.sortVars[ indx ].count = -1;
1843
+ c.sortVars[ indx ].sortedBy = '';
1844
+ }
1845
+ ts.setHeadersCss( c );
1846
+ ts.multisort( c );
1847
+ ts.appendCache( c );
1848
+ if ( $.isFunction( callback ) ) {
1849
+ callback( c.table );
1850
+ }
1851
+ },
1852
+
1853
+ getSortType : function( parsers, column ) {
1854
+ return ( parsers && parsers[ column ] ) ? parsers[ column ].type || '' : '';
1855
+ },
1856
+
1857
+ getOrder : function( val ) {
1858
+ // look for 'd' in 'desc' order; return true
1859
+ return ( /^d/i.test( val ) || val === 1 );
1860
+ },
1861
+
1862
+ // Natural sort - https://github.com/overset/javascript-natural-sort (date sorting removed)
1863
+ sortNatural : function( a, b ) {
1864
+ if ( a === b ) { return 0; }
1865
+ a = ( a || '' ).toString();
1866
+ b = ( b || '' ).toString();
1867
+ var aNum, bNum, aFloat, bFloat, indx, max,
1868
+ regex = ts.regex;
1869
+ // first try and sort Hex codes
1870
+ if ( regex.hex.test( b ) ) {
1871
+ aNum = parseInt( a.match( regex.hex ), 16 );
1872
+ bNum = parseInt( b.match( regex.hex ), 16 );
1873
+ if ( aNum < bNum ) { return -1; }
1874
+ if ( aNum > bNum ) { return 1; }
1875
+ }
1876
+ // chunk/tokenize
1877
+ aNum = a.replace( regex.chunk, '\\0$1\\0' ).replace( regex.chunks, '' ).split( '\\0' );
1878
+ bNum = b.replace( regex.chunk, '\\0$1\\0' ).replace( regex.chunks, '' ).split( '\\0' );
1879
+ max = Math.max( aNum.length, bNum.length );
1880
+ // natural sorting through split numeric strings and default strings
1881
+ for ( indx = 0; indx < max; indx++ ) {
1882
+ // find floats not starting with '0', string or 0 if not defined
1883
+ aFloat = isNaN( aNum[ indx ] ) ? aNum[ indx ] || 0 : parseFloat( aNum[ indx ] ) || 0;
1884
+ bFloat = isNaN( bNum[ indx ] ) ? bNum[ indx ] || 0 : parseFloat( bNum[ indx ] ) || 0;
1885
+ // handle numeric vs string comparison - number < string - (Kyle Adams)
1886
+ if ( isNaN( aFloat ) !== isNaN( bFloat ) ) { return isNaN( aFloat ) ? 1 : -1; }
1887
+ // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
1888
+ if ( typeof aFloat !== typeof bFloat ) {
1889
+ aFloat += '';
1890
+ bFloat += '';
1891
+ }
1892
+ if ( aFloat < bFloat ) { return -1; }
1893
+ if ( aFloat > bFloat ) { return 1; }
1894
+ }
1895
+ return 0;
1896
+ },
1897
+
1898
+ sortNaturalAsc : function( a, b, col, c ) {
1899
+ if ( a === b ) { return 0; }
1900
+ var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
1901
+ if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : -empty || -1; }
1902
+ if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : empty || 1; }
1903
+ return ts.sortNatural( a, b );
1904
+ },
1905
+
1906
+ sortNaturalDesc : function( a, b, col, c ) {
1907
+ if ( a === b ) { return 0; }
1908
+ var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
1909
+ if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : empty || 1; }
1910
+ if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : -empty || -1; }
1911
+ return ts.sortNatural( b, a );
1912
+ },
1913
+
1914
+ // basic alphabetical sort
1915
+ sortText : function( a, b ) {
1916
+ return a > b ? 1 : ( a < b ? -1 : 0 );
1917
+ },
1918
+
1919
+ // return text string value by adding up ascii value
1920
+ // so the text is somewhat sorted when using a digital sort
1921
+ // this is NOT an alphanumeric sort
1922
+ getTextValue : function( val, num, max ) {
1923
+ if ( max ) {
1924
+ // make sure the text value is greater than the max numerical value (max)
1925
+ var indx,
1926
+ len = val ? val.length : 0,
1927
+ n = max + num;
1928
+ for ( indx = 0; indx < len; indx++ ) {
1929
+ n += val.charCodeAt( indx );
1930
+ }
1931
+ return num * n;
1932
+ }
1933
+ return 0;
1934
+ },
1935
+
1936
+ sortNumericAsc : function( a, b, num, max, col, c ) {
1937
+ if ( a === b ) { return 0; }
1938
+ var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
1939
+ if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : -empty || -1; }
1940
+ if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : empty || 1; }
1941
+ if ( isNaN( a ) ) { a = ts.getTextValue( a, num, max ); }
1942
+ if ( isNaN( b ) ) { b = ts.getTextValue( b, num, max ); }
1943
+ return a - b;
1944
+ },
1945
+
1946
+ sortNumericDesc : function( a, b, num, max, col, c ) {
1947
+ if ( a === b ) { return 0; }
1948
+ var empty = ts.string[ ( c.empties[ col ] || c.emptyTo ) ];
1949
+ if ( a === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? -1 : 1 ) : empty || 1; }
1950
+ if ( b === '' && empty !== 0 ) { return typeof empty === 'boolean' ? ( empty ? 1 : -1 ) : -empty || -1; }
1951
+ if ( isNaN( a ) ) { a = ts.getTextValue( a, num, max ); }
1952
+ if ( isNaN( b ) ) { b = ts.getTextValue( b, num, max ); }
1953
+ return b - a;
1954
+ },
1955
+
1956
+ sortNumeric : function( a, b ) {
1957
+ return a - b;
1958
+ },
1959
+
1960
+ /*
1961
+ ██ ██ ██ ██ █████▄ ▄████▄ ██████ ██████ ▄█████
1962
+ ██ ██ ██ ██ ██ ██ ██ ▄▄▄ ██▄▄ ██ ▀█▄
1963
+ ██ ██ ██ ██ ██ ██ ██ ▀██ ██▀▀ ██ ▀█▄
1964
+ ███████▀ ██ █████▀ ▀████▀ ██████ ██ █████▀
1965
+ */
1966
+ addWidget : function( widget ) {
1967
+ if ( widget.id && !ts.isEmptyObject( ts.getWidgetById( widget.id ) ) ) {
1968
+ console.warn( '"' + widget.id + '" widget was loaded more than once!' );
1969
+ }
1970
+ ts.widgets[ ts.widgets.length ] = widget;
1971
+ },
1972
+
1973
+ hasWidget : function( $table, name ) {
1974
+ $table = $( $table );
1975
+ return $table.length && $table[ 0 ].config && $table[ 0 ].config.widgetInit[ name ] || false;
1976
+ },
1977
+
1978
+ getWidgetById : function( name ) {
1979
+ var indx, widget,
1980
+ len = ts.widgets.length;
1981
+ for ( indx = 0; indx < len; indx++ ) {
1982
+ widget = ts.widgets[ indx ];
1983
+ if ( widget && widget.id && widget.id.toLowerCase() === name.toLowerCase() ) {
1984
+ return widget;
1985
+ }
1986
+ }
1987
+ },
1988
+
1989
+ applyWidgetOptions : function( table ) {
1990
+ var indx, widget, wo,
1991
+ c = table.config,
1992
+ len = c.widgets.length;
1993
+ if ( len ) {
1994
+ for ( indx = 0; indx < len; indx++ ) {
1995
+ widget = ts.getWidgetById( c.widgets[ indx ] );
1996
+ if ( widget && widget.options ) {
1997
+ wo = $.extend( true, {}, widget.options );
1998
+ c.widgetOptions = $.extend( true, wo, c.widgetOptions );
1999
+ // add widgetOptions to defaults for option validator
2000
+ $.extend( true, ts.defaults.widgetOptions, widget.options );
2001
+ }
2002
+ }
2003
+ }
2004
+ },
2005
+
2006
+ addWidgetFromClass : function( table ) {
2007
+ var len, indx,
2008
+ c = table.config,
2009
+ // look for widgets to apply from table class
2010
+ // don't match from 'ui-widget-content'; use \S instead of \w to include widgets
2011
+ // with dashes in the name, e.g. "widget-test-2" extracts out "test-2"
2012
+ regex = '^' + c.widgetClass.replace( ts.regex.templateName, '(\\S+)+' ) + '$',
2013
+ widgetClass = new RegExp( regex, 'g' ),
2014
+ // split up table class (widget id's can include dashes) - stop using match
2015
+ // otherwise only one widget gets extracted, see #1109
2016
+ widgets = ( table.className || '' ).split( ts.regex.spaces );
2017
+ if ( widgets.length ) {
2018
+ len = widgets.length;
2019
+ for ( indx = 0; indx < len; indx++ ) {
2020
+ if ( widgets[ indx ].match( widgetClass ) ) {
2021
+ c.widgets[ c.widgets.length ] = widgets[ indx ].replace( widgetClass, '$1' );
2022
+ }
2023
+ }
2024
+ }
2025
+ },
2026
+
2027
+ applyWidgetId : function( table, id, init ) {
2028
+ table = $(table)[0];
2029
+ var applied, time, name,
2030
+ c = table.config,
2031
+ wo = c.widgetOptions,
2032
+ debug = ts.debug(c, 'core'),
2033
+ widget = ts.getWidgetById( id );
2034
+ if ( widget ) {
2035
+ name = widget.id;
2036
+ applied = false;
2037
+ // add widget name to option list so it gets reapplied after sorting, filtering, etc
2038
+ if ( $.inArray( name, c.widgets ) < 0 ) {
2039
+ c.widgets[ c.widgets.length ] = name;
2040
+ }
2041
+ if ( debug ) { time = new Date(); }
2042
+
2043
+ if ( init || !( c.widgetInit[ name ] ) ) {
2044
+ // set init flag first to prevent calling init more than once (e.g. pager)
2045
+ c.widgetInit[ name ] = true;
2046
+ if ( table.hasInitialized ) {
2047
+ // don't reapply widget options on tablesorter init
2048
+ ts.applyWidgetOptions( table );
2049
+ }
2050
+ if ( typeof widget.init === 'function' ) {
2051
+ applied = true;
2052
+ if ( debug ) {
2053
+ console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
2054
+ }
2055
+ widget.init( table, widget, c, wo );
2056
+ }
2057
+ }
2058
+ if ( !init && typeof widget.format === 'function' ) {
2059
+ applied = true;
2060
+ if ( debug ) {
2061
+ console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
2062
+ }
2063
+ widget.format( table, c, wo, false );
2064
+ }
2065
+ if ( debug ) {
2066
+ if ( applied ) {
2067
+ console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time ) );
2068
+ if ( console.groupEnd ) { console.groupEnd(); }
2069
+ }
2070
+ }
2071
+ }
2072
+ },
2073
+
2074
+ applyWidget : function( table, init, callback ) {
2075
+ table = $( table )[ 0 ]; // in case this is called externally
2076
+ var indx, len, names, widget, time,
2077
+ c = table.config,
2078
+ debug = ts.debug(c, 'core'),
2079
+ widgets = [];
2080
+ // prevent numerous consecutive widget applications
2081
+ if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) {
2082
+ return;
2083
+ }
2084
+ if ( debug ) { time = new Date(); }
2085
+ ts.addWidgetFromClass( table );
2086
+ // prevent "tablesorter-ready" from firing multiple times in a row
2087
+ clearTimeout( c.timerReady );
2088
+ if ( c.widgets.length ) {
2089
+ table.isApplyingWidgets = true;
2090
+ // ensure unique widget ids
2091
+ c.widgets = $.grep( c.widgets, function( val, index ) {
2092
+ return $.inArray( val, c.widgets ) === index;
2093
+ });
2094
+ names = c.widgets || [];
2095
+ len = names.length;
2096
+ // build widget array & add priority as needed
2097
+ for ( indx = 0; indx < len; indx++ ) {
2098
+ widget = ts.getWidgetById( names[ indx ] );
2099
+ if ( widget && widget.id ) {
2100
+ // set priority to 10 if not defined
2101
+ if ( !widget.priority ) { widget.priority = 10; }
2102
+ widgets[ indx ] = widget;
2103
+ } else if ( debug ) {
2104
+ console.warn( '"' + names[ indx ] + '" was enabled, but the widget code has not been loaded!' );
2105
+ }
2106
+ }
2107
+ // sort widgets by priority
2108
+ widgets.sort( function( a, b ) {
2109
+ return a.priority < b.priority ? -1 : a.priority === b.priority ? 0 : 1;
2110
+ });
2111
+ // add/update selected widgets
2112
+ len = widgets.length;
2113
+ if ( debug ) {
2114
+ console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
2115
+ }
2116
+ for ( indx = 0; indx < len; indx++ ) {
2117
+ widget = widgets[ indx ];
2118
+ if ( widget && widget.id ) {
2119
+ ts.applyWidgetId( table, widget.id, init );
2120
+ }
2121
+ }
2122
+ if ( debug && console.groupEnd ) { console.groupEnd(); }
2123
+ }
2124
+ c.timerReady = setTimeout( function() {
2125
+ table.isApplyingWidgets = false;
2126
+ $.data( table, 'lastWidgetApplication', new Date() );
2127
+ c.$table.triggerHandler( 'tablesorter-ready' );
2128
+ // callback executed on init only
2129
+ if ( !init && typeof callback === 'function' ) {
2130
+ callback( table );
2131
+ }
2132
+ if ( debug ) {
2133
+ widget = c.widgets.length;
2134
+ console.log( 'Completed ' +
2135
+ ( init === true ? 'initializing ' : 'applying ' ) + widget +
2136
+ ' widget' + ( widget !== 1 ? 's' : '' ) + ts.benchmark( time ) );
2137
+ }
2138
+ }, 10 );
2139
+ },
2140
+
2141
+ removeWidget : function( table, name, refreshing ) {
2142
+ table = $( table )[ 0 ];
2143
+ var index, widget, indx, len,
2144
+ c = table.config;
2145
+ // if name === true, add all widgets from $.tablesorter.widgets
2146
+ if ( name === true ) {
2147
+ name = [];
2148
+ len = ts.widgets.length;
2149
+ for ( indx = 0; indx < len; indx++ ) {
2150
+ widget = ts.widgets[ indx ];
2151
+ if ( widget && widget.id ) {
2152
+ name[ name.length ] = widget.id;
2153
+ }
2154
+ }
2155
+ } else {
2156
+ // name can be either an array of widgets names,
2157
+ // or a space/comma separated list of widget names
2158
+ name = ( $.isArray( name ) ? name.join( ',' ) : name || '' ).toLowerCase().split( /[\s,]+/ );
2159
+ }
2160
+ len = name.length;
2161
+ for ( index = 0; index < len; index++ ) {
2162
+ widget = ts.getWidgetById( name[ index ] );
2163
+ indx = $.inArray( name[ index ], c.widgets );
2164
+ // don't remove the widget from config.widget if refreshing
2165
+ if ( indx >= 0 && refreshing !== true ) {
2166
+ c.widgets.splice( indx, 1 );
2167
+ }
2168
+ if ( widget && widget.remove ) {
2169
+ if ( ts.debug(c, 'core') ) {
2170
+ console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' );
2171
+ }
2172
+ widget.remove( table, c, c.widgetOptions, refreshing );
2173
+ c.widgetInit[ name[ index ] ] = false;
2174
+ }
2175
+ }
2176
+ c.$table.triggerHandler( 'widgetRemoveEnd', table );
2177
+ },
2178
+
2179
+ refreshWidgets : function( table, doAll, dontapply ) {
2180
+ table = $( table )[ 0 ]; // see issue #243
2181
+ var indx, widget,
2182
+ c = table.config,
2183
+ curWidgets = c.widgets,
2184
+ widgets = ts.widgets,
2185
+ len = widgets.length,
2186
+ list = [],
2187
+ callback = function( table ) {
2188
+ $( table ).triggerHandler( 'refreshComplete' );
2189
+ };
2190
+ // remove widgets not defined in config.widgets, unless doAll is true
2191
+ for ( indx = 0; indx < len; indx++ ) {
2192
+ widget = widgets[ indx ];
2193
+ if ( widget && widget.id && ( doAll || $.inArray( widget.id, curWidgets ) < 0 ) ) {
2194
+ list[ list.length ] = widget.id;
2195
+ }
2196
+ }
2197
+ ts.removeWidget( table, list.join( ',' ), true );
2198
+ if ( dontapply !== true ) {
2199
+ // call widget init if
2200
+ ts.applyWidget( table, doAll || false, callback );
2201
+ if ( doAll ) {
2202
+ // apply widget format
2203
+ ts.applyWidget( table, false, callback );
2204
+ }
2205
+ } else {
2206
+ callback( table );
2207
+ }
2208
+ },
2209
+
2210
+ /*
2211
+ ██ ██ ██████ ██ ██ ██ ██████ ██ ██████ ▄█████
2212
+ ██ ██ ██ ██ ██ ██ ██ ██ ██▄▄ ▀█▄
2213
+ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀█▄
2214
+ ▀████▀ ██ ██ ██████ ██ ██ ██ ██████ █████▀
2215
+ */
2216
+ benchmark : function( diff ) {
2217
+ return ( ' (' + ( new Date().getTime() - diff.getTime() ) + ' ms)' );
2218
+ },
2219
+ // deprecated ts.log
2220
+ log : function() {
2221
+ console.log( arguments );
2222
+ },
2223
+ debug : function(c, name) {
2224
+ return c && (
2225
+ c.debug === true ||
2226
+ typeof c.debug === 'string' && c.debug.indexOf(name) > -1
2227
+ );
2228
+ },
2229
+
2230
+ // $.isEmptyObject from jQuery v1.4
2231
+ isEmptyObject : function( obj ) {
2232
+ /*jshint forin: false */
2233
+ for ( var name in obj ) {
2234
+ return false;
2235
+ }
2236
+ return true;
2237
+ },
2238
+
2239
+ isValueInArray : function( column, arry ) {
2240
+ var indx,
2241
+ len = arry && arry.length || 0;
2242
+ for ( indx = 0; indx < len; indx++ ) {
2243
+ if ( arry[ indx ][ 0 ] === column ) {
2244
+ return indx;
2245
+ }
2246
+ }
2247
+ return -1;
2248
+ },
2249
+
2250
+ formatFloat : function( str, table ) {
2251
+ if ( typeof str !== 'string' || str === '' ) { return str; }
2252
+ // allow using formatFloat without a table; defaults to US number format
2253
+ var num,
2254
+ usFormat = table && table.config ? table.config.usNumberFormat !== false :
2255
+ typeof table !== 'undefined' ? table : true;
2256
+ if ( usFormat ) {
2257
+ // US Format - 1,234,567.89 -> 1234567.89
2258
+ str = str.replace( ts.regex.comma, '' );
2259
+ } else {
2260
+ // German Format = 1.234.567,89 -> 1234567.89
2261
+ // French Format = 1 234 567,89 -> 1234567.89
2262
+ str = str.replace( ts.regex.digitNonUS, '' ).replace( ts.regex.comma, '.' );
2263
+ }
2264
+ if ( ts.regex.digitNegativeTest.test( str ) ) {
2265
+ // make (#) into a negative number -> (10) = -10
2266
+ str = str.replace( ts.regex.digitNegativeReplace, '-$1' );
2267
+ }
2268
+ num = parseFloat( str );
2269
+ // return the text instead of zero
2270
+ return isNaN( num ) ? $.trim( str ) : num;
2271
+ },
2272
+
2273
+ isDigit : function( str ) {
2274
+ // replace all unwanted chars and match
2275
+ return isNaN( str ) ?
2276
+ ts.regex.digitTest.test( str.toString().replace( ts.regex.digitReplace, '' ) ) :
2277
+ str !== '';
2278
+ },
2279
+
2280
+ // computeTableHeaderCellIndexes from:
2281
+ // http://www.javascripttoolbox.com/lib/table/examples.php
2282
+ // http://www.javascripttoolbox.com/temp/table_cellindex.html
2283
+ computeColumnIndex : function( $rows, c ) {
2284
+ var i, j, k, l, cell, cells, rowIndex, rowSpan, colSpan, firstAvailCol,
2285
+ // total columns has been calculated, use it to set the matrixrow
2286
+ columns = c && c.columns || 0,
2287
+ matrix = [],
2288
+ matrixrow = new Array( columns );
2289
+ for ( i = 0; i < $rows.length; i++ ) {
2290
+ cells = $rows[ i ].cells;
2291
+ for ( j = 0; j < cells.length; j++ ) {
2292
+ cell = cells[ j ];
2293
+ rowIndex = i;
2294
+ rowSpan = cell.rowSpan || 1;
2295
+ colSpan = cell.colSpan || 1;
2296
+ if ( typeof matrix[ rowIndex ] === 'undefined' ) {
2297
+ matrix[ rowIndex ] = [];
2298
+ }
2299
+ // Find first available column in the first row
2300
+ for ( k = 0; k < matrix[ rowIndex ].length + 1; k++ ) {
2301
+ if ( typeof matrix[ rowIndex ][ k ] === 'undefined' ) {
2302
+ firstAvailCol = k;
2303
+ break;
2304
+ }
2305
+ }
2306
+ // jscs:disable disallowEmptyBlocks
2307
+ if ( columns && cell.cellIndex === firstAvailCol ) {
2308
+ // don't to anything
2309
+ } else if ( cell.setAttribute ) {
2310
+ // jscs:enable disallowEmptyBlocks
2311
+ // add data-column (setAttribute = IE8+)
2312
+ cell.setAttribute( 'data-column', firstAvailCol );
2313
+ } else {
2314
+ // remove once we drop support for IE7 - 1/12/2016
2315
+ $( cell ).attr( 'data-column', firstAvailCol );
2316
+ }
2317
+ for ( k = rowIndex; k < rowIndex + rowSpan; k++ ) {
2318
+ if ( typeof matrix[ k ] === 'undefined' ) {
2319
+ matrix[ k ] = [];
2320
+ }
2321
+ matrixrow = matrix[ k ];
2322
+ for ( l = firstAvailCol; l < firstAvailCol + colSpan; l++ ) {
2323
+ matrixrow[ l ] = 'x';
2324
+ }
2325
+ }
2326
+ }
2327
+ }
2328
+ ts.checkColumnCount($rows, matrix, matrixrow.length);
2329
+ return matrixrow.length;
2330
+ },
2331
+
2332
+ checkColumnCount : function($rows, matrix, columns) {
2333
+ // this DOES NOT report any tbody column issues, except for the math and
2334
+ // and column selector widgets
2335
+ var i, len,
2336
+ valid = true,
2337
+ cells = [];
2338
+ for ( i = 0; i < matrix.length; i++ ) {
2339
+ // some matrix entries are undefined when testing the footer because
2340
+ // it is using the rowIndex property
2341
+ if ( matrix[i] ) {
2342
+ len = matrix[i].length;
2343
+ if ( matrix[i].length !== columns ) {
2344
+ valid = false;
2345
+ break;
2346
+ }
2347
+ }
2348
+ }
2349
+ if ( !valid ) {
2350
+ $rows.each( function( indx, el ) {
2351
+ var cell = el.parentElement.nodeName;
2352
+ if ( cells.indexOf( cell ) < 0 ) {
2353
+ cells.push( cell );
2354
+ }
2355
+ });
2356
+ console.error(
2357
+ 'Invalid or incorrect number of columns in the ' +
2358
+ cells.join( ' or ' ) + '; expected ' + columns +
2359
+ ', but found ' + len + ' columns'
2360
+ );
2361
+ }
2362
+ },
2363
+
2364
+ // automatically add a colgroup with col elements set to a percentage width
2365
+ fixColumnWidth : function( table ) {
2366
+ table = $( table )[ 0 ];
2367
+ var overallWidth, percent, $tbodies, len, index,
2368
+ c = table.config,
2369
+ $colgroup = c.$table.children( 'colgroup' );
2370
+ // remove plugin-added colgroup, in case we need to refresh the widths
2371
+ if ( $colgroup.length && $colgroup.hasClass( ts.css.colgroup ) ) {
2372
+ $colgroup.remove();
2373
+ }
2374
+ if ( c.widthFixed && c.$table.children( 'colgroup' ).length === 0 ) {
2375
+ $colgroup = $( '<colgroup class="' + ts.css.colgroup + '">' );
2376
+ overallWidth = c.$table.width();
2377
+ // only add col for visible columns - fixes #371
2378
+ $tbodies = c.$tbodies.find( 'tr:first' ).children( ':visible' );
2379
+ len = $tbodies.length;
2380
+ for ( index = 0; index < len; index++ ) {
2381
+ percent = parseInt( ( $tbodies.eq( index ).width() / overallWidth ) * 1000, 10 ) / 10 + '%';
2382
+ $colgroup.append( $( '<col>' ).css( 'width', percent ) );
2383
+ }
2384
+ c.$table.prepend( $colgroup );
2385
+ }
2386
+ },
2387
+
2388
+ // get sorter, string, empty, etc options for each column from
2389
+ // jQuery data, metadata, header option or header class name ('sorter-false')
2390
+ // priority = jQuery data > meta > headers option > header class name
2391
+ getData : function( header, configHeader, key ) {
2392
+ var meta, cl4ss,
2393
+ val = '',
2394
+ $header = $( header );
2395
+ if ( !$header.length ) { return ''; }
2396
+ meta = $.metadata ? $header.metadata() : false;
2397
+ cl4ss = ' ' + ( $header.attr( 'class' ) || '' );
2398
+ if ( typeof $header.data( key ) !== 'undefined' ||
2399
+ typeof $header.data( key.toLowerCase() ) !== 'undefined' ) {
2400
+ // 'data-lockedOrder' is assigned to 'lockedorder'; but 'data-locked-order' is assigned to 'lockedOrder'
2401
+ // 'data-sort-initial-order' is assigned to 'sortInitialOrder'
2402
+ val += $header.data( key ) || $header.data( key.toLowerCase() );
2403
+ } else if ( meta && typeof meta[ key ] !== 'undefined' ) {
2404
+ val += meta[ key ];
2405
+ } else if ( configHeader && typeof configHeader[ key ] !== 'undefined' ) {
2406
+ val += configHeader[ key ];
2407
+ } else if ( cl4ss !== ' ' && cl4ss.match( ' ' + key + '-' ) ) {
2408
+ // include sorter class name 'sorter-text', etc; now works with 'sorter-my-custom-parser'
2409
+ val = cl4ss.match( new RegExp( '\\s' + key + '-([\\w-]+)' ) )[ 1 ] || '';
2410
+ }
2411
+ return $.trim( val );
2412
+ },
2413
+
2414
+ getColumnData : function( table, obj, indx, getCell, $headers ) {
2415
+ if ( typeof obj !== 'object' || obj === null ) {
2416
+ return obj;
2417
+ }
2418
+ table = $( table )[ 0 ];
2419
+ var $header, key,
2420
+ c = table.config,
2421
+ $cells = ( $headers || c.$headers ),
2422
+ // c.$headerIndexed is not defined initially
2423
+ $cell = c.$headerIndexed && c.$headerIndexed[ indx ] ||
2424
+ $cells.find( '[data-column="' + indx + '"]:last' );
2425
+ if ( typeof obj[ indx ] !== 'undefined' ) {
2426
+ return getCell ? obj[ indx ] : obj[ $cells.index( $cell ) ];
2427
+ }
2428
+ for ( key in obj ) {
2429
+ if ( typeof key === 'string' ) {
2430
+ $header = $cell
2431
+ // header cell with class/id
2432
+ .filter( key )
2433
+ // find elements within the header cell with cell/id
2434
+ .add( $cell.find( key ) );
2435
+ if ( $header.length ) {
2436
+ return obj[ key ];
2437
+ }
2438
+ }
2439
+ }
2440
+ return;
2441
+ },
2442
+
2443
+ // *** Process table ***
2444
+ // add processing indicator
2445
+ isProcessing : function( $table, toggle, $headers ) {
2446
+ $table = $( $table );
2447
+ var c = $table[ 0 ].config,
2448
+ // default to all headers
2449
+ $header = $headers || $table.find( '.' + ts.css.header );
2450
+ if ( toggle ) {
2451
+ // don't use sortList if custom $headers used
2452
+ if ( typeof $headers !== 'undefined' && c.sortList.length > 0 ) {
2453
+ // get headers from the sortList
2454
+ $header = $header.filter( function() {
2455
+ // get data-column from attr to keep compatibility with jQuery 1.2.6
2456
+ return this.sortDisabled ?
2457
+ false :
2458
+ ts.isValueInArray( parseFloat( $( this ).attr( 'data-column' ) ), c.sortList ) >= 0;
2459
+ });
2460
+ }
2461
+ $table.add( $header ).addClass( ts.css.processing + ' ' + c.cssProcessing );
2462
+ } else {
2463
+ $table.add( $header ).removeClass( ts.css.processing + ' ' + c.cssProcessing );
2464
+ }
2465
+ },
2466
+
2467
+ // detach tbody but save the position
2468
+ // don't use tbody because there are portions that look for a tbody index (updateCell)
2469
+ processTbody : function( table, $tb, getIt ) {
2470
+ table = $( table )[ 0 ];
2471
+ if ( getIt ) {
2472
+ table.isProcessing = true;
2473
+ $tb.before( '<colgroup class="tablesorter-savemyplace"/>' );
2474
+ return $.fn.detach ? $tb.detach() : $tb.remove();
2475
+ }
2476
+ var holdr = $( table ).find( 'colgroup.tablesorter-savemyplace' );
2477
+ $tb.insertAfter( holdr );
2478
+ holdr.remove();
2479
+ table.isProcessing = false;
2480
+ },
2481
+
2482
+ clearTableBody : function( table ) {
2483
+ $( table )[ 0 ].config.$tbodies.children().detach();
2484
+ },
2485
+
2486
+ // used when replacing accented characters during sorting
2487
+ characterEquivalents : {
2488
+ 'a' : '\u00e1\u00e0\u00e2\u00e3\u00e4\u0105\u00e5', // áàâãäąå
2489
+ 'A' : '\u00c1\u00c0\u00c2\u00c3\u00c4\u0104\u00c5', // ÁÀÂÃÄĄÅ
2490
+ 'c' : '\u00e7\u0107\u010d', // çćč
2491
+ 'C' : '\u00c7\u0106\u010c', // ÇĆČ
2492
+ 'e' : '\u00e9\u00e8\u00ea\u00eb\u011b\u0119', // éèêëěę
2493
+ 'E' : '\u00c9\u00c8\u00ca\u00cb\u011a\u0118', // ÉÈÊËĚĘ
2494
+ 'i' : '\u00ed\u00ec\u0130\u00ee\u00ef\u0131', // íìİîïı
2495
+ 'I' : '\u00cd\u00cc\u0130\u00ce\u00cf', // ÍÌİÎÏ
2496
+ 'o' : '\u00f3\u00f2\u00f4\u00f5\u00f6\u014d', // óòôõöō
2497
+ 'O' : '\u00d3\u00d2\u00d4\u00d5\u00d6\u014c', // ÓÒÔÕÖŌ
2498
+ 'ss': '\u00df', // ß (s sharp)
2499
+ 'SS': '\u1e9e', // ẞ (Capital sharp s)
2500
+ 'u' : '\u00fa\u00f9\u00fb\u00fc\u016f', // úùûüů
2501
+ 'U' : '\u00da\u00d9\u00db\u00dc\u016e' // ÚÙÛÜŮ
2502
+ },
2503
+
2504
+ replaceAccents : function( str ) {
2505
+ var chr,
2506
+ acc = '[',
2507
+ eq = ts.characterEquivalents;
2508
+ if ( !ts.characterRegex ) {
2509
+ ts.characterRegexArray = {};
2510
+ for ( chr in eq ) {
2511
+ if ( typeof chr === 'string' ) {
2512
+ acc += eq[ chr ];
2513
+ ts.characterRegexArray[ chr ] = new RegExp( '[' + eq[ chr ] + ']', 'g' );
2514
+ }
2515
+ }
2516
+ ts.characterRegex = new RegExp( acc + ']' );
2517
+ }
2518
+ if ( ts.characterRegex.test( str ) ) {
2519
+ for ( chr in eq ) {
2520
+ if ( typeof chr === 'string' ) {
2521
+ str = str.replace( ts.characterRegexArray[ chr ], chr );
2522
+ }
2523
+ }
2524
+ }
2525
+ return str;
2526
+ },
2527
+
2528
+ validateOptions : function( c ) {
2529
+ var setting, setting2, typ, timer,
2530
+ // ignore options containing an array
2531
+ ignore = 'headers sortForce sortList sortAppend widgets'.split( ' ' ),
2532
+ orig = c.originalSettings;
2533
+ if ( orig ) {
2534
+ if ( ts.debug(c, 'core') ) {
2535
+ timer = new Date();
2536
+ }
2537
+ for ( setting in orig ) {
2538
+ typ = typeof ts.defaults[setting];
2539
+ if ( typ === 'undefined' ) {
2540
+ console.warn( 'Tablesorter Warning! "table.config.' + setting + '" option not recognized' );
2541
+ } else if ( typ === 'object' ) {
2542
+ for ( setting2 in orig[setting] ) {
2543
+ typ = ts.defaults[setting] && typeof ts.defaults[setting][setting2];
2544
+ if ( $.inArray( setting, ignore ) < 0 && typ === 'undefined' ) {
2545
+ console.warn( 'Tablesorter Warning! "table.config.' + setting + '.' + setting2 + '" option not recognized' );
2546
+ }
2547
+ }
2548
+ }
2549
+ }
2550
+ if ( ts.debug(c, 'core') ) {
2551
+ console.log( 'validate options time:' + ts.benchmark( timer ) );
2552
+ }
2553
+ }
2554
+ },
2555
+
2556
+ // restore headers
2557
+ restoreHeaders : function( table ) {
2558
+ var index, $cell,
2559
+ c = $( table )[ 0 ].config,
2560
+ $headers = c.$table.find( c.selectorHeaders ),
2561
+ len = $headers.length;
2562
+ // don't use c.$headers here in case header cells were swapped
2563
+ for ( index = 0; index < len; index++ ) {
2564
+ $cell = $headers.eq( index );
2565
+ // only restore header cells if it is wrapped
2566
+ // because this is also used by the updateAll method
2567
+ if ( $cell.find( '.' + ts.css.headerIn ).length ) {
2568
+ $cell.html( c.headerContent[ index ] );
2569
+ }
2570
+ }
2571
+ },
2572
+
2573
+ destroy : function( table, removeClasses, callback ) {
2574
+ table = $( table )[ 0 ];
2575
+ if ( !table.hasInitialized ) { return; }
2576
+ // remove all widgets
2577
+ ts.removeWidget( table, true, false );
2578
+ var events,
2579
+ $t = $( table ),
2580
+ c = table.config,
2581
+ $h = $t.find( 'thead:first' ),
2582
+ $r = $h.find( 'tr.' + ts.css.headerRow ).removeClass( ts.css.headerRow + ' ' + c.cssHeaderRow ),
2583
+ $f = $t.find( 'tfoot:first > tr' ).children( 'th, td' );
2584
+ if ( removeClasses === false && $.inArray( 'uitheme', c.widgets ) >= 0 ) {
2585
+ // reapply uitheme classes, in case we want to maintain appearance
2586
+ $t.triggerHandler( 'applyWidgetId', [ 'uitheme' ] );
2587
+ $t.triggerHandler( 'applyWidgetId', [ 'zebra' ] );
2588
+ }
2589
+ // remove widget added rows, just in case
2590
+ $h.find( 'tr' ).not( $r ).remove();
2591
+ // disable tablesorter - not using .unbind( namespace ) because namespacing was
2592
+ // added in jQuery v1.4.3 - see http://api.jquery.com/event.namespace/
2593
+ events = 'sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton ' +
2594
+ 'appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave ' +
2595
+ 'keypress sortBegin sortEnd resetToLoadState '.split( ' ' )
2596
+ .join( c.namespace + ' ' );
2597
+ $t
2598
+ .removeData( 'tablesorter' )
2599
+ .unbind( events.replace( ts.regex.spaces, ' ' ) );
2600
+ c.$headers
2601
+ .add( $f )
2602
+ .removeClass( [ ts.css.header, c.cssHeader, c.cssAsc, c.cssDesc, ts.css.sortAsc, ts.css.sortDesc, ts.css.sortNone ].join( ' ' ) )
2603
+ .removeAttr( 'data-column' )
2604
+ .removeAttr( 'aria-label' )
2605
+ .attr( 'aria-disabled', 'true' );
2606
+ $r
2607
+ .find( c.selectorSort )
2608
+ .unbind( ( 'mousedown mouseup keypress '.split( ' ' ).join( c.namespace + ' ' ) ).replace( ts.regex.spaces, ' ' ) );
2609
+ ts.restoreHeaders( table );
2610
+ $t.toggleClass( ts.css.table + ' ' + c.tableClass + ' tablesorter-' + c.theme, removeClasses === false );
2611
+ $t.removeClass(c.namespace.slice(1));
2612
+ // clear flag in case the plugin is initialized again
2613
+ table.hasInitialized = false;
2614
+ delete table.config.cache;
2615
+ if ( typeof callback === 'function' ) {
2616
+ callback( table );
2617
+ }
2618
+ if ( ts.debug(c, 'core') ) {
2619
+ console.log( 'tablesorter has been removed' );
2620
+ }
2621
+ }
2622
+
2623
+ };
2624
+
2625
+ $.fn.tablesorter = function( settings ) {
2626
+ return this.each( function() {
2627
+ var table = this,
2628
+ // merge & extend config options
2629
+ c = $.extend( true, {}, ts.defaults, settings, ts.instanceMethods );
2630
+ // save initial settings
2631
+ c.originalSettings = settings;
2632
+ // create a table from data (build table widget)
2633
+ if ( !table.hasInitialized && ts.buildTable && this.nodeName !== 'TABLE' ) {
2634
+ // return the table (in case the original target is the table's container)
2635
+ ts.buildTable( table, c );
2636
+ } else {
2637
+ ts.setup( table, c );
2638
+ }
2639
+ });
2640
+ };
2641
+
2642
+ // set up debug logs
2643
+ if ( !( window.console && window.console.log ) ) {
2644
+ // access $.tablesorter.logs for browsers that don't have a console...
2645
+ ts.logs = [];
2646
+ /*jshint -W020 */
2647
+ console = {};
2648
+ console.log = console.warn = console.error = console.table = function() {
2649
+ var arg = arguments.length > 1 ? arguments : arguments[0];
2650
+ ts.logs[ ts.logs.length ] = { date: Date.now(), log: arg };
2651
+ };
2652
+ }
2653
+
2654
+ // add default parsers
2655
+ ts.addParser({
2656
+ id : 'no-parser',
2657
+ is : function() {
2658
+ return false;
2659
+ },
2660
+ format : function() {
2661
+ return '';
2662
+ },
2663
+ type : 'text'
2664
+ });
2665
+
2666
+ ts.addParser({
2667
+ id : 'text',
2668
+ is : function() {
2669
+ return true;
2670
+ },
2671
+ format : function( str, table ) {
2672
+ var c = table.config;
2673
+ if ( str ) {
2674
+ str = $.trim( c.ignoreCase ? str.toLocaleLowerCase() : str );
2675
+ str = c.sortLocaleCompare ? ts.replaceAccents( str ) : str;
2676
+ }
2677
+ return str;
2678
+ },
2679
+ type : 'text'
2680
+ });
2681
+
2682
+ ts.regex.nondigit = /[^\w,. \-()]/g;
2683
+ ts.addParser({
2684
+ id : 'digit',
2685
+ is : function( str ) {
2686
+ return ts.isDigit( str );
2687
+ },
2688
+ format : function( str, table ) {
2689
+ var num = ts.formatFloat( ( str || '' ).replace( ts.regex.nondigit, '' ), table );
2690
+ return str && typeof num === 'number' ? num :
2691
+ str ? $.trim( str && table.config.ignoreCase ? str.toLocaleLowerCase() : str ) : str;
2692
+ },
2693
+ type : 'numeric'
2694
+ });
2695
+
2696
+ ts.regex.currencyReplace = /[+\-,. ]/g;
2697
+ ts.regex.currencyTest = /^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/;
2698
+ ts.addParser({
2699
+ id : 'currency',
2700
+ is : function( str ) {
2701
+ str = ( str || '' ).replace( ts.regex.currencyReplace, '' );
2702
+ // test for £$€¤¥¢
2703
+ return ts.regex.currencyTest.test( str );
2704
+ },
2705
+ format : function( str, table ) {
2706
+ var num = ts.formatFloat( ( str || '' ).replace( ts.regex.nondigit, '' ), table );
2707
+ return str && typeof num === 'number' ? num :
2708
+ str ? $.trim( str && table.config.ignoreCase ? str.toLocaleLowerCase() : str ) : str;
2709
+ },
2710
+ type : 'numeric'
2711
+ });
2712
+
2713
+ // too many protocols to add them all https://en.wikipedia.org/wiki/URI_scheme
2714
+ // now, this regex can be updated before initialization
2715
+ ts.regex.urlProtocolTest = /^(https?|ftp|file):\/\//;
2716
+ ts.regex.urlProtocolReplace = /(https?|ftp|file):\/\/(www\.)?/;
2717
+ ts.addParser({
2718
+ id : 'url',
2719
+ is : function( str ) {
2720
+ return ts.regex.urlProtocolTest.test( str );
2721
+ },
2722
+ format : function( str ) {
2723
+ return str ? $.trim( str.replace( ts.regex.urlProtocolReplace, '' ) ) : str;
2724
+ },
2725
+ type : 'text'
2726
+ });
2727
+
2728
+ ts.regex.dash = /-/g;
2729
+ ts.regex.isoDate = /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/;
2730
+ ts.addParser({
2731
+ id : 'isoDate',
2732
+ is : function( str ) {
2733
+ return ts.regex.isoDate.test( str );
2734
+ },
2735
+ format : function( str ) {
2736
+ var date = str ? new Date( str.replace( ts.regex.dash, '/' ) ) : str;
2737
+ return date instanceof Date && isFinite( date ) ? date.getTime() : str;
2738
+ },
2739
+ type : 'numeric'
2740
+ });
2741
+
2742
+ ts.regex.percent = /%/g;
2743
+ ts.regex.percentTest = /(\d\s*?%|%\s*?\d)/;
2744
+ ts.addParser({
2745
+ id : 'percent',
2746
+ is : function( str ) {
2747
+ return ts.regex.percentTest.test( str ) && str.length < 15;
2748
+ },
2749
+ format : function( str, table ) {
2750
+ return str ? ts.formatFloat( str.replace( ts.regex.percent, '' ), table ) : str;
2751
+ },
2752
+ type : 'numeric'
2753
+ });
2754
+
2755
+ // added image parser to core v2.17.9
2756
+ ts.addParser({
2757
+ id : 'image',
2758
+ is : function( str, table, node, $node ) {
2759
+ return $node.find( 'img' ).length > 0;
2760
+ },
2761
+ format : function( str, table, cell ) {
2762
+ return $( cell ).find( 'img' ).attr( table.config.imgAttr || 'alt' ) || str;
2763
+ },
2764
+ parsed : true, // filter widget flag
2765
+ type : 'text'
2766
+ });
2767
+
2768
+ ts.regex.dateReplace = /(\S)([AP]M)$/i; // used by usLongDate & time parser
2769
+ ts.regex.usLongDateTest1 = /^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i;
2770
+ ts.regex.usLongDateTest2 = /^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i;
2771
+ ts.addParser({
2772
+ id : 'usLongDate',
2773
+ is : function( str ) {
2774
+ // two digit years are not allowed cross-browser
2775
+ // Jan 01, 2013 12:34:56 PM or 01 Jan 2013
2776
+ return ts.regex.usLongDateTest1.test( str ) || ts.regex.usLongDateTest2.test( str );
2777
+ },
2778
+ format : function( str ) {
2779
+ var date = str ? new Date( str.replace( ts.regex.dateReplace, '$1 $2' ) ) : str;
2780
+ return date instanceof Date && isFinite( date ) ? date.getTime() : str;
2781
+ },
2782
+ type : 'numeric'
2783
+ });
2784
+
2785
+ // testing for ##-##-#### or ####-##-##, so it's not perfect; time can be included
2786
+ ts.regex.shortDateTest = /(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/;
2787
+ // escaped "-" because JSHint in Firefox was showing it as an error
2788
+ ts.regex.shortDateReplace = /[\-.,]/g;
2789
+ // XXY covers MDY & DMY formats
2790
+ ts.regex.shortDateXXY = /(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/;
2791
+ ts.regex.shortDateYMD = /(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/;
2792
+ ts.convertFormat = function( dateString, format ) {
2793
+ dateString = ( dateString || '' )
2794
+ .replace( ts.regex.spaces, ' ' )
2795
+ .replace( ts.regex.shortDateReplace, '/' );
2796
+ if ( format === 'mmddyyyy' ) {
2797
+ dateString = dateString.replace( ts.regex.shortDateXXY, '$3/$1/$2' );
2798
+ } else if ( format === 'ddmmyyyy' ) {
2799
+ dateString = dateString.replace( ts.regex.shortDateXXY, '$3/$2/$1' );
2800
+ } else if ( format === 'yyyymmdd' ) {
2801
+ dateString = dateString.replace( ts.regex.shortDateYMD, '$1/$2/$3' );
2802
+ }
2803
+ var date = new Date( dateString );
2804
+ return date instanceof Date && isFinite( date ) ? date.getTime() : '';
2805
+ };
2806
+
2807
+ ts.addParser({
2808
+ id : 'shortDate', // 'mmddyyyy', 'ddmmyyyy' or 'yyyymmdd'
2809
+ is : function( str ) {
2810
+ str = ( str || '' ).replace( ts.regex.spaces, ' ' ).replace( ts.regex.shortDateReplace, '/' );
2811
+ return ts.regex.shortDateTest.test( str );
2812
+ },
2813
+ format : function( str, table, cell, cellIndex ) {
2814
+ if ( str ) {
2815
+ var c = table.config,
2816
+ $header = c.$headerIndexed[ cellIndex ],
2817
+ format = $header.length && $header.data( 'dateFormat' ) ||
2818
+ ts.getData( $header, ts.getColumnData( table, c.headers, cellIndex ), 'dateFormat' ) ||
2819
+ c.dateFormat;
2820
+ // save format because getData can be slow...
2821
+ if ( $header.length ) {
2822
+ $header.data( 'dateFormat', format );
2823
+ }
2824
+ return ts.convertFormat( str, format ) || str;
2825
+ }
2826
+ return str;
2827
+ },
2828
+ type : 'numeric'
2829
+ });
2830
+
2831
+ // match 24 hour time & 12 hours time + am/pm - see http://regexr.com/3c3tk
2832
+ ts.regex.timeTest = /^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i;
2833
+ ts.regex.timeMatch = /(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i;
2834
+ ts.addParser({
2835
+ id : 'time',
2836
+ is : function( str ) {
2837
+ return ts.regex.timeTest.test( str );
2838
+ },
2839
+ format : function( str ) {
2840
+ // isolate time... ignore month, day and year
2841
+ var temp,
2842
+ timePart = ( str || '' ).match( ts.regex.timeMatch ),
2843
+ orig = new Date( str ),
2844
+ // no time component? default to 00:00 by leaving it out, but only if str is defined
2845
+ time = str && ( timePart !== null ? timePart[ 0 ] : '00:00 AM' ),
2846
+ date = time ? new Date( '2000/01/01 ' + time.replace( ts.regex.dateReplace, '$1 $2' ) ) : time;
2847
+ if ( date instanceof Date && isFinite( date ) ) {
2848
+ temp = orig instanceof Date && isFinite( orig ) ? orig.getTime() : 0;
2849
+ // if original string was a valid date, add it to the decimal so the column sorts in some kind of order
2850
+ // luckily new Date() ignores the decimals
2851
+ return temp ? parseFloat( date.getTime() + '.' + orig.getTime() ) : date.getTime();
2852
+ }
2853
+ return str;
2854
+ },
2855
+ type : 'numeric'
2856
+ });
2857
+
2858
+ ts.addParser({
2859
+ id : 'metadata',
2860
+ is : function() {
2861
+ return false;
2862
+ },
2863
+ format : function( str, table, cell ) {
2864
+ var c = table.config,
2865
+ p = ( !c.parserMetadataName ) ? 'sortValue' : c.parserMetadataName;
2866
+ return $( cell ).metadata()[ p ];
2867
+ },
2868
+ type : 'numeric'
2869
+ });
2870
+
2871
+ /*
2872
+ ██████ ██████ █████▄ █████▄ ▄████▄
2873
+ ▄█▀ ██▄▄ ██▄▄██ ██▄▄██ ██▄▄██
2874
+ ▄█▀ ██▀▀ ██▀▀██ ██▀▀█ ██▀▀██
2875
+ ██████ ██████ █████▀ ██ ██ ██ ██
2876
+ */
2877
+ // add default widgets
2878
+ ts.addWidget({
2879
+ id : 'zebra',
2880
+ priority : 90,
2881
+ format : function( table, c, wo ) {
2882
+ var $visibleRows, $row, count, isEven, tbodyIndex, rowIndex, len,
2883
+ child = new RegExp( c.cssChildRow, 'i' ),
2884
+ $tbodies = c.$tbodies.add( $( c.namespace + '_extra_table' ).children( 'tbody:not(.' + c.cssInfoBlock + ')' ) );
2885
+ for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
2886
+ // loop through the visible rows
2887
+ count = 0;
2888
+ $visibleRows = $tbodies.eq( tbodyIndex ).children( 'tr:visible' ).not( c.selectorRemove );
2889
+ len = $visibleRows.length;
2890
+ for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
2891
+ $row = $visibleRows.eq( rowIndex );
2892
+ // style child rows the same way the parent row was styled
2893
+ if ( !child.test( $row[ 0 ].className ) ) { count++; }
2894
+ isEven = ( count % 2 === 0 );
2895
+ $row
2896
+ .removeClass( wo.zebra[ isEven ? 1 : 0 ] )
2897
+ .addClass( wo.zebra[ isEven ? 0 : 1 ] );
2898
+ }
2899
+ }
2900
+ },
2901
+ remove : function( table, c, wo, refreshing ) {
2902
+ if ( refreshing ) { return; }
2903
+ var tbodyIndex, $tbody,
2904
+ $tbodies = c.$tbodies,
2905
+ toRemove = ( wo.zebra || [ 'even', 'odd' ] ).join( ' ' );
2906
+ for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
2907
+ $tbody = ts.processTbody( table, $tbodies.eq( tbodyIndex ), true ); // remove tbody
2908
+ $tbody.children().removeClass( toRemove );
2909
+ ts.processTbody( table, $tbody, false ); // restore tbody
2910
+ }
2911
+ }
2912
+ });
2913
+
2914
+ })( jQuery );
js/jquery.tablesorter.min.js DELETED
@@ -1,2 +0,0 @@
1
- !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&"object"==typeof module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return function(b){"use strict";var c=b.tablesorter={version:"2.27.8",parsers:[],widgets:[],defaults:{theme:"default",widthFixed:!1,showProcessing:!1,headerTemplate:"{content}",onRenderTemplate:null,onRenderHeader:null,cancelSelection:!0,tabIndex:!0,dateFormat:"mmddyyyy",sortMultiSortKey:"shiftKey",sortResetKey:"ctrlKey",usNumberFormat:!0,delayInit:!1,serverSideSorting:!1,resort:!0,headers:{},ignoreCase:!0,sortForce:null,sortList:[],sortAppend:null,sortStable:!1,sortInitialOrder:"asc",sortLocaleCompare:!1,sortReset:!1,sortRestart:!1,emptyTo:"bottom",stringTo:"max",duplicateSpan:!0,textExtraction:"basic",textAttribute:"data-text",textSorter:null,numberSorter:null,initWidgets:!0,widgetClass:"widget-{name}",widgets:[],widgetOptions:{zebra:["even","odd"]},initialized:null,tableClass:"",cssAsc:"",cssDesc:"",cssNone:"",cssHeader:"",cssHeaderRow:"",cssProcessing:"",cssChildRow:"tablesorter-childRow",cssInfoBlock:"tablesorter-infoOnly",cssNoSort:"tablesorter-noSort",cssIgnoreRow:"tablesorter-ignoreRow",cssIcon:"tablesorter-icon",cssIconNone:"",cssIconAsc:"",cssIconDesc:"",pointerClick:"click",pointerDown:"mousedown",pointerUp:"mouseup",selectorHeaders:"> thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[]},css:{table:"tablesorter",cssHasChild:"tablesorter-hasChildRow",childRow:"tablesorter-childRow",colgroup:"tablesorter-colgroup",header:"tablesorter-header",headerRow:"tablesorter-headerRow",headerIn:"tablesorter-header-inner",icon:"tablesorter-icon",processing:"tablesorter-processing",sortAsc:"tablesorter-headerAsc",sortDesc:"tablesorter-headerDesc",sortNone:"tablesorter-headerUnSorted"},language:{sortAsc:"Ascending sort applied, ",sortDesc:"Descending sort applied, ",sortNone:"No sort applied, ",sortDisabled:"sorting is disabled",nextAsc:"activate to apply an ascending sort",nextDesc:"activate to apply a descending sort",nextNone:"activate to remove the sort"},regex:{templateContent:/\{content\}/g,templateIcon:/\{icon\}/g,templateName:/\{name\}/i,spaces:/\s+/g,nonWord:/\W/g,formElements:/(input|select|button|textarea)/i,chunk:/(^([+\-]?(?:\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,chunks:/(^\\0|\\0$)/,hex:/^0x[0-9a-f]+$/i,comma:/,/g,digitNonUS:/[\s|\.]/g,digitNegativeTest:/^\s*\([.\d]+\)/,digitNegativeReplace:/^\s*\(([.\d]+)\)/,digitTest:/^[\-+(]?\d+[)]?$/,digitReplace:/[,.'"\s]/g},string:{max:1,min:-1,emptymin:1,emptymax:-1,zero:0,none:0,null:0,top:!0,bottom:!1},keyCodes:{enter:13},dates:{},instanceMethods:{},setup:function(a,d){if(!a||!a.tHead||0===a.tBodies.length||a.hasInitialized===!0)return void(d.debug&&(a.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",a)));var e="",f=b(a),g=b.metadata;a.hasInitialized=!1,a.isProcessing=!0,a.config=d,b.data(a,"tablesorter",d),d.debug&&(console[console.group?"group":"log"]("Initializing tablesorter v"+c.version),b.data(a,"startoveralltimer",new Date)),d.supportsDataObject=function(a){return a[0]=parseInt(a[0],10),a[0]>1||1===a[0]&&parseInt(a[1],10)>=4}(b.fn.jquery.split(".")),d.emptyTo=d.emptyTo.toLowerCase(),d.stringTo=d.stringTo.toLowerCase(),d.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(f.attr("class"))||(e=""!==d.theme?" tablesorter-"+d.theme:""),d.table=a,d.$table=f.addClass(c.css.table+" "+d.tableClass+e).attr("role","grid"),d.$headers=f.find(d.selectorHeaders),d.namespace?d.namespace="."+d.namespace.replace(c.regex.nonWord,""):d.namespace=".tablesorter"+Math.random().toString(16).slice(2),d.$table.children().children("tr").attr("role","row"),d.$tbodies=f.children("tbody:not(."+d.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),d.$table.children("caption").length&&(e=d.$table.children("caption")[0],e.id||(e.id=d.namespace.slice(1)+"caption"),d.$table.attr("aria-labelledby",e.id)),d.widgetInit={},d.textExtraction=d.$table.attr("data-text-extraction")||d.textExtraction||"basic",c.buildHeaders(d),c.fixColumnWidth(a),c.addWidgetFromClass(a),c.applyWidgetOptions(a),c.setupParsers(d),d.totalRows=0,d.delayInit||c.buildCache(d),c.bindEvents(a,d.$headers,!0),c.bindMethods(d),d.supportsDataObject&&"undefined"!=typeof f.data().sortlist?d.sortList=f.data().sortlist:g&&f.metadata()&&f.metadata().sortlist&&(d.sortList=f.metadata().sortlist),c.applyWidget(a,!0),d.sortList.length>0?c.sortOn(d,d.sortList,{},!d.initWidgets):(c.setHeadersCss(d),d.initWidgets&&c.applyWidget(a,!1)),d.showProcessing&&f.unbind("sortBegin"+d.namespace+" sortEnd"+d.namespace).bind("sortBegin"+d.namespace+" sortEnd"+d.namespace,function(b){clearTimeout(d.timerProcessing),c.isProcessing(a),"sortBegin"===b.type&&(d.timerProcessing=setTimeout(function(){c.isProcessing(a,!0)},500))}),a.hasInitialized=!0,a.isProcessing=!1,d.debug&&(console.log("Overall initialization time:"+c.benchmark(b.data(a,"startoveralltimer"))),d.debug&&console.groupEnd&&console.groupEnd()),f.triggerHandler("tablesorter-initialized",a),"function"==typeof d.initialized&&d.initialized(a)},bindMethods:function(a){var d=a.$table,e=a.namespace,f="sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(e+" ");d.unbind(f.replace(c.regex.spaces," ")).bind("sortReset"+e,function(a,b){a.stopPropagation(),c.sortReset(this.config,b)}).bind("updateAll"+e,function(a,b,d){a.stopPropagation(),c.updateAll(this.config,b,d)}).bind("update"+e+" updateRows"+e,function(a,b,d){a.stopPropagation(),c.update(this.config,b,d)}).bind("updateHeaders"+e,function(a,b){a.stopPropagation(),c.updateHeaders(this.config,b)}).bind("updateCell"+e,function(a,b,d,e){a.stopPropagation(),c.updateCell(this.config,b,d,e)}).bind("addRows"+e,function(a,b,d,e){a.stopPropagation(),c.addRows(this.config,b,d,e)}).bind("updateComplete"+e,function(){this.isUpdating=!1}).bind("sorton"+e,function(a,b,d,e){a.stopPropagation(),c.sortOn(this.config,b,d,e)}).bind("appendCache"+e,function(a,d,e){a.stopPropagation(),c.appendCache(this.config,e),b.isFunction(d)&&d(this)}).bind("updateCache"+e,function(a,b,d){a.stopPropagation(),c.updateCache(this.config,b,d)}).bind("applyWidgetId"+e,function(a,b){a.stopPropagation(),c.applyWidgetId(this,b)}).bind("applyWidgets"+e,function(a,b){a.stopPropagation(),c.applyWidget(this,b)}).bind("refreshWidgets"+e,function(a,b,d){a.stopPropagation(),c.refreshWidgets(this,b,d)}).bind("removeWidget"+e,function(a,b,d){a.stopPropagation(),c.removeWidget(this,b,d)}).bind("destroy"+e,function(a,b,d){a.stopPropagation(),c.destroy(this,b,d)}).bind("resetToLoadState"+e,function(d){d.stopPropagation(),c.removeWidget(this,!0,!1),a=b.extend(!0,c.defaults,a.originalSettings),this.hasInitialized=!1,c.setup(this,a)})},bindEvents:function(a,d,e){a=b(a)[0];var f,g=a.config,h=g.namespace,i=null;e!==!0&&(d.addClass(h.slice(1)+"_extra_headers"),f=b.fn.closest?d.closest("table")[0]:d.parents("table")[0],f&&"TABLE"===f.nodeName&&f!==a&&b(f).addClass(h.slice(1)+"_extra_table")),f=(g.pointerDown+" "+g.pointerUp+" "+g.pointerClick+" sort keyup ").replace(c.regex.spaces," ").split(" ").join(h+" "),d.find(g.selectorSort).add(d.filter(g.selectorSort)).unbind(f).bind(f,function(a,e){var f,h,j,k=b(a.target),l=" "+a.type+" ";if(!(1!==(a.which||a.button)&&!l.match(" "+g.pointerClick+" | sort | keyup ")||" keyup "===l&&a.which!==c.keyCodes.enter||l.match(" "+g.pointerClick+" ")&&"undefined"!=typeof a.which||l.match(" "+g.pointerUp+" ")&&i!==a.target&&e!==!0)){if(l.match(" "+g.pointerDown+" "))return i=a.target,j=k.jquery.split("."),void("1"===j[0]&&j[1]<4&&a.preventDefault());if(i=null,c.regex.formElements.test(a.target.nodeName)||k.hasClass(g.cssNoSort)||k.parents("."+g.cssNoSort).length>0||k.parents("button").length>0)return!g.cancelSelection;g.delayInit&&c.isEmptyObject(g.cache)&&c.buildCache(g),f=b.fn.closest?b(this).closest("th, td"):/TH|TD/.test(this.nodeName)?b(this):b(this).parents("th, td"),j=d.index(f),g.last.clickedIndex=j<0?f.attr("data-column"):j,h=g.$headers[g.last.clickedIndex],h&&!h.sortDisabled&&c.initSort(g,h,a)}}),g.cancelSelection&&d.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(a){var d,e,f,g;for(a.headerList=[],a.headerContent=[],a.sortVars=[],a.debug&&(f=new Date),a.columns=c.computeColumnIndex(a.$table.children("thead, tfoot").children("tr")),e=a.cssIcon?'<i class="'+(a.cssIcon===c.css.icon?c.css.icon:a.cssIcon+" "+c.css.icon)+'"></i>':"",a.$headers=b(b.map(a.$table.find(a.selectorHeaders),function(d,f){var g,h,i,j,k,l=b(d);if(!l.parent().hasClass(a.cssIgnoreRow))return g=c.getColumnData(a.table,a.headers,f,!0),a.headerContent[f]=l.html(),""===a.headerTemplate||l.find("."+c.css.headerIn).length||(j=a.headerTemplate.replace(c.regex.templateContent,l.html()).replace(c.regex.templateIcon,l.find("."+c.css.icon).length?"":e),a.onRenderTemplate&&(h=a.onRenderTemplate.apply(l,[f,j]),h&&"string"==typeof h&&(j=h)),l.html('<div class="'+c.css.headerIn+'">'+j+"</div>")),a.onRenderHeader&&a.onRenderHeader.apply(l,[f,a,a.$table]),i=parseInt(l.attr("data-column"),10),d.column=i,k=c.getOrder(c.getData(l,g,"sortInitialOrder")||a.sortInitialOrder),a.sortVars[i]={count:-1,order:k?a.sortReset?[1,0,2]:[1,0]:a.sortReset?[0,1,2]:[0,1],lockedOrder:!1},k=c.getData(l,g,"lockedOrder")||!1,"undefined"!=typeof k&&k!==!1&&(a.sortVars[i].lockedOrder=!0,a.sortVars[i].order=c.getOrder(k)?[1,1]:[0,0]),a.headerList[f]=d,l.addClass(c.css.header+" "+a.cssHeader).parent().addClass(c.css.headerRow+" "+a.cssHeaderRow).attr("role","row"),a.tabIndex&&l.attr("tabindex",0),d})),a.$headerIndexed=[],g=0;g<a.columns;g++)c.isEmptyObject(a.sortVars[g])&&(a.sortVars[g]={}),d=a.$headers.filter('[data-column="'+g+'"]'),a.$headerIndexed[g]=d.length?d.not(".sorter-false").length?d.not(".sorter-false").filter(":last"):d.filter(":last"):b();a.$table.find(a.selectorHeaders).attr({scope:"col",role:"columnheader"}),c.updateHeader(a),a.debug&&(console.log("Built headers:"+c.benchmark(f)),console.log(a.$headers))},addInstanceMethods:function(a){b.extend(c.instanceMethods,a)},setupParsers:function(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=a.table,s=0,t={};if(a.$tbodies=a.$table.children("tbody:not(."+a.cssInfoBlock+")"),p="undefined"==typeof b?a.$tbodies:b,q=p.length,0===q)return a.debug?console.warn("Warning: *Empty table!* Not building a parser cache"):"";for(a.debug&&(o=new Date,console[console.group?"group":"log"]("Detecting parsers for each column")),e={extractors:[],parsers:[]};s<q;){if(d=p[s].rows,d.length)for(h=0,g=a.columns,i=0;i<g;i++){if(j=a.$headerIndexed[h],j&&j.length&&(k=c.getColumnData(r,a.headers,h),n=c.getParserById(c.getData(j,k,"extractor")),m=c.getParserById(c.getData(j,k,"sorter")),l="false"===c.getData(j,k,"parser"),a.empties[h]=(c.getData(j,k,"empty")||a.emptyTo||(a.emptyToBottom?"bottom":"top")).toLowerCase(),a.strings[h]=(c.getData(j,k,"string")||a.stringTo||"max").toLowerCase(),l&&(m=c.getParserById("no-parser")),n||(n=!1),m||(m=c.detectParserForColumn(a,d,-1,h)),a.debug&&(t["("+h+") "+j.text()]={parser:m.id,extractor:n?n.id:"none",string:a.strings[h],empty:a.empties[h]}),e.parsers[h]=m,e.extractors[h]=n,f=j[0].colSpan-1,f>0))for(h+=f,g+=f;f+1>0;)e.parsers[h-f]=m,e.extractors[h-f]=n,f--;h++}s+=e.parsers.length?q:1}a.debug&&(c.isEmptyObject(t)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](t),console.log("Completed detecting parsers"+c.benchmark(o)),console.groupEnd&&console.groupEnd()),a.parsers=e.parsers,a.extractors=e.extractors},addParser:function(a){var b,d=c.parsers.length,e=!0;for(b=0;b<d;b++)c.parsers[b].id.toLowerCase()===a.id.toLowerCase()&&(e=!1);e&&(c.parsers[c.parsers.length]=a)},getParserById:function(a){if("false"==a)return!1;var b,d=c.parsers.length;for(b=0;b<d;b++)if(c.parsers[b].id.toLowerCase()===a.toString().toLowerCase())return c.parsers[b];return!1},detectParserForColumn:function(a,d,e,f){for(var g,h,i,j=c.parsers.length,k=!1,l="",m=!0;""===l&&m;)e++,i=d[e],i&&e<50?i.className.indexOf(c.cssIgnoreRow)<0&&(k=d[e].cells[f],l=c.getElementText(a,k,f),h=b(k),a.debug&&console.log("Checking if value was empty on row "+e+", column: "+f+': "'+l+'"')):m=!1;for(;--j>=0;)if(g=c.parsers[j],g&&"text"!==g.id&&g.is&&g.is(l,a.table,k,h))return g;return c.getParserById("text")},getElementText:function(a,d,e){if(!d)return"";var f,g=a.textExtraction||"",h=d.jquery?d:b(d);return"string"==typeof g?"basic"===g&&"undefined"!=typeof(f=h.attr(a.textAttribute))?b.trim(f):b.trim(d.textContent||h.text()):"function"==typeof g?b.trim(g(h[0],a.table,e)):"function"==typeof(f=c.getColumnData(a.table,g,e))?b.trim(f(h[0],a.table,e)):b.trim(h[0].textContent||h.text())},getParsedText:function(a,b,d,e){"undefined"==typeof e&&(e=c.getElementText(a,b,d));var f=""+e,g=a.parsers[d],h=a.extractors[d];return g&&(h&&"function"==typeof h.format&&(e=h.format(e,a.table,b,d)),f="no-parser"===g.id?"":g.format(""+e,a.table,b,d),a.ignoreCase&&"string"==typeof f&&(f=f.toLowerCase())),f},buildCache:function(a,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a.table,C=a.parsers;if(a.$tbodies=a.$table.children("tbody:not(."+a.cssInfoBlock+")"),l="undefined"==typeof e?a.$tbodies:e,a.cache={},a.totalRows=0,!C)return a.debug?console.warn("Warning: *Empty table!* Not building a cache"):"";for(a.debug&&(q=new Date),a.showProcessing&&c.isProcessing(B,!0),k=0;k<l.length;k++){for(u=[],f=a.cache[k]={normalized:[]},r=l[k]&&l[k].rows.length||0,i=0;i<r;++i)if(s={child:[],raw:[]},m=b(l[k].rows[i]),n=[],!m.hasClass(a.selectorRemove.slice(1)))if(m.hasClass(a.cssChildRow)&&0!==i)for(z=f.normalized.length-1,t=f.normalized[z][a.columns],t.$row=t.$row.add(m),m.prev().hasClass(a.cssChildRow)||m.prev().addClass(c.css.cssHasChild),o=m.children("th, td"),z=t.child.length,t.child[z]=[],w=0,y=a.columns,j=0;j<y;j++)p=o[j],p&&(t.child[z][j]=c.getParsedText(a,p,j),v=o[j].colSpan-1,v>0&&(w+=v,y+=v)),w++;else{for(s.$row=m,s.order=i,w=0,y=a.columns,j=0;j<y;++j){if(p=m[0].cells[j],p&&w<a.columns&&(x="undefined"!=typeof C[w],!x&&a.debug&&console.warn("No parser found for row: "+i+", column: "+j+'; cell containing: "'+b(p).text()+'"; does it have a header?'),g=c.getElementText(a,p,w),s.raw[w]=g,h=c.getParsedText(a,p,w,g),n[w]=h,x&&"numeric"===(C[w].type||"").toLowerCase()&&(u[w]=Math.max(Math.abs(h)||0,u[w]||0)),v=p.colSpan-1,v>0)){for(A=0;A<=v;)h=a.duplicateSpan||0===A?g:"string"!=typeof a.textExtraction?c.getElementText(a,p,w+A)||"":"",s.raw[w+A]=h,n[w+A]=h,A++;w+=v,y+=v}w++}n[a.columns]=s,f.normalized[f.normalized.length]=n}f.colMax=u,a.totalRows+=f.normalized.length}if(a.showProcessing&&c.isProcessing(B),a.debug){for(z=Math.min(5,a.cache[0].normalized.length),console[console.group?"group":"log"]("Building cache for "+a.totalRows+" rows (showing "+z+" rows in log) and "+a.columns+" columns"+c.benchmark(q)),g={},j=0;j<a.columns;j++)for(w=0;w<z;w++)g["row: "+w]||(g["row: "+w]={}),g["row: "+w][a.$headerIndexed[j].text()]=a.cache[0].normalized[w][j];console[console.table?"table":"log"](g),console.groupEnd&&console.groupEnd()}b.isFunction(d)&&d(B)},getColumnText:function(a,d,e,f){a=b(a)[0];var g,h,i,j,k,l,m,n,o,p,q="function"==typeof e,r="all"===d,s={raw:[],parsed:[],$cell:[]},t=a.config;if(!c.isEmptyObject(t)){for(k=t.$tbodies.length,g=0;g<k;g++)for(i=t.cache[g].normalized,l=i.length,h=0;h<l;h++)j=i[h],f&&!j[t.columns].$row.is(f)||(p=!0,n=r?j.slice(0,t.columns):j[d],j=j[t.columns],m=r?j.raw:j.raw[d],o=r?j.$row.children():j.$row.children().eq(d),q&&(p=e({tbodyIndex:g,rowIndex:h,parsed:n,raw:m,$row:j.$row,$cell:o})),p!==!1&&(s.parsed[s.parsed.length]=n,s.raw[s.raw.length]=m,s.$cell[s.$cell.length]=o));return s}t.debug&&console.warn("No cache found - aborting getColumnText function!")},setHeadersCss:function(a){var d,e,f,g=a.sortList,h=g.length,i=c.css.sortNone+" "+a.cssNone,j=[c.css.sortAsc+" "+a.cssAsc,c.css.sortDesc+" "+a.cssDesc],k=[a.cssIconAsc,a.cssIconDesc,a.cssIconNone],l=["ascending","descending"],m=a.$table.find("tfoot tr").children("td, th").add(b(a.namespace+"_extra_headers")).removeClass(j.join(" "));for(a.$headers.removeClass(j.join(" ")).addClass(i).attr("aria-sort","none").find("."+c.css.icon).removeClass(k.join(" ")).addClass(k[2]),e=0;e<h;e++)if(2!==g[e][1]&&(d=a.$headers.filter(function(b){for(var d=!0,e=a.$headers.eq(b),f=parseInt(e.attr("data-column"),10),g=f+a.$headers[b].colSpan;f<g;f++)d=!!d&&(d||c.isValueInArray(f,a.sortList)>-1);return d}),d=d.not(".sorter-false").filter('[data-column="'+g[e][0]+'"]'+(1===h?":last":"")),d.length)){for(f=0;f<d.length;f++)d[f].sortDisabled||d.eq(f).removeClass(i).addClass(j[g[e][1]]).attr("aria-sort",l[g[e][1]]).find("."+c.css.icon).removeClass(k[2]).addClass(k[g[e][1]]);m.length&&m.filter('[data-column="'+g[e][0]+'"]').removeClass(i).addClass(j[g[e][1]])}for(h=a.$headers.length,e=0;e<h;e++)c.setColumnAriaLabel(a,a.$headers.eq(e))},setColumnAriaLabel:function(a,d,e){if(d.length){var f=parseInt(d.attr("data-column"),10),g=a.sortVars[f],h=d.hasClass(c.css.sortAsc)?"sortAsc":d.hasClass(c.css.sortDesc)?"sortDesc":"sortNone",i=b.trim(d.text())+": "+c.language[h];d.hasClass("sorter-false")||e===!1?i+=c.language.sortDisabled:(h=(g.count+1)%g.order.length,e=g.order[h],i+=c.language[0===e?"nextAsc":1===e?"nextDesc":"nextNone"]),d.attr("aria-label",i)}},updateHeader:function(a){var b,d,e,f,g=a.table,h=a.$headers.length;for(b=0;b<h;b++)e=a.$headers.eq(b),f=c.getColumnData(g,a.headers,b,!0),d="false"===c.getData(e,f,"sorter")||"false"===c.getData(e,f,"parser"),c.setColumnSort(a,e,d)},setColumnSort:function(a,b,c){var d=a.table.id;b[0].sortDisabled=c,b[c?"addClass":"removeClass"]("sorter-false").attr("aria-disabled",""+c),a.tabIndex&&(c?b.removeAttr("tabindex"):b.attr("tabindex","0")),d&&(c?b.removeAttr("aria-controls"):b.attr("aria-controls",d))},updateHeaderSortCount:function(a,d){var e,f,g,h,i,j,k,l,m=d||a.sortList,n=m.length;for(a.sortList=[],h=0;h<n;h++)if(k=m[h],e=parseInt(k[0],10),e<a.columns){switch(a.sortVars[e].order||(l=c.getOrder(a.sortInitialOrder)?a.sortReset?[1,0,2]:[1,0]:a.sortReset?[0,1,2]:[0,1],a.sortVars[e].order=l,a.sortVars[e].count=0),l=a.sortVars[e].order,f=(""+k[1]).match(/^(1|d|s|o|n)/),f=f?f[0]:""){case"1":case"d":f=1;break;case"s":f=i||0;break;case"o":j=l[(i||0)%l.length],f=0===j?1:1===j?0:2;break;case"n":f=l[++a.sortVars[e].count%l.length];break;default:f=0}i=0===h?f:i,g=[e,parseInt(f,10)||0],a.sortList[a.sortList.length]=g,f=b.inArray(g[1],l),a.sortVars[e].count=f>=0?f:g[1]%l.length}},updateAll:function(a,b,d){var e=a.table;e.isUpdating=!0,c.refreshWidgets(e,!0,!0),c.buildHeaders(a),c.bindEvents(e,a.$headers,!0),c.bindMethods(a),c.commonUpdate(a,b,d)},update:function(a,b,d){var e=a.table;e.isUpdating=!0,c.updateHeader(a),c.commonUpdate(a,b,d)},updateHeaders:function(a,b){a.table.isUpdating=!0,c.buildHeaders(a),c.bindEvents(a.table,a.$headers,!0),c.resortComplete(a,b)},updateCell:function(a,d,e,f){if(c.isEmptyObject(a.cache))return c.updateHeader(a),void c.commonUpdate(a,e,f);a.table.isUpdating=!0,a.$table.find(a.selectorRemove).remove();var g,h,i,j,k,l,m=a.$tbodies,n=b(d),o=m.index(b.fn.closest?n.closest("tbody"):n.parents("tbody").filter(":first")),p=a.cache[o],q=b.fn.closest?n.closest("tr"):n.parents("tr").filter(":first");if(d=n[0],m.length&&o>=0){if(i=m.eq(o).find("tr").index(q),k=p.normalized[i],l=q[0].cells.length,l!==a.columns)for(j=0,g=!1,h=0;h<l;h++)g||q[0].cells[h]===d?g=!0:j+=q[0].cells[h].colSpan;else j=n.index();g=c.getElementText(a,d,j),k[a.columns].raw[j]=g,g=c.getParsedText(a,d,j,g),k[j]=g,k[a.columns].$row=q,"numeric"===(a.parsers[j].type||"").toLowerCase()&&(p.colMax[j]=Math.max(Math.abs(g)||0,p.colMax[j]||0)),g="undefined"!==e?e:a.resort,g!==!1?c.checkResort(a,g,f):c.resortComplete(a,f)}else a.debug&&console.error("updateCell aborted, tbody missing or not within the indicated table"),a.table.isUpdating=!1},addRows:function(d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u="string"==typeof e&&1===d.$tbodies.length&&/<tr/.test(e||""),v=d.table;if(u)e=b(e),d.$tbodies.append(e);else if(!(e&&e instanceof a&&(b.fn.closest?e.closest("table")[0]:e.parents("table")[0])===d.table))return d.debug&&console.error("addRows method requires (1) a jQuery selector reference to rows that have already been added to the table, or (2) row HTML string to be added to a table with only one tbody"),!1;if(v.isUpdating=!0,c.isEmptyObject(d.cache))c.updateHeader(d),c.commonUpdate(d,f,g);else{for(l=e.filter("tr").attr("role","row").length,j=d.$tbodies.index(e.parents("tbody").filter(":first")),d.parsers&&d.parsers.length||c.setupParsers(d),k=0;k<l;k++){for(p=0,n=e[k].cells.length,o=d.cache[j].normalized.length,r=[],q={child:[],raw:[],$row:e.eq(k),order:o},m=0;m<n;m++)s=e[k].cells[m],h=c.getElementText(d,s,p),q.raw[p]=h,i=c.getParsedText(d,s,p,h),r[p]=i,"numeric"===(d.parsers[p].type||"").toLowerCase()&&(d.cache[j].colMax[p]=Math.max(Math.abs(i)||0,d.cache[j].colMax[p]||0)),t=s.colSpan-1,t>0&&(p+=t),p++;r[d.columns]=q,d.cache[j].normalized[o]=r}c.checkResort(d,f,g)}},updateCache:function(a,b,d){a.parsers&&a.parsers.length||c.setupParsers(a,d),c.buildCache(a,b,d)},appendCache:function(a,b){var d,e,f,g,h,i,j,k=a.table,l=a.widgetOptions,m=a.$tbodies,n=[],o=a.cache;if(c.isEmptyObject(o))return a.appender?a.appender(k,n):k.isUpdating?a.$table.triggerHandler("updateComplete",k):"";for(a.debug&&(j=new Date),i=0;i<m.length;i++)if(f=m.eq(i),f.length){for(g=c.processTbody(k,f,!0),d=o[i].normalized,e=d.length,h=0;h<e;h++)n[n.length]=d[h][a.columns].$row,a.appender&&(!a.pager||a.pager.removeRows&&l.pager_removeRows||a.pager.ajax)||g.append(d[h][a.columns].$row);c.processTbody(k,g,!1)}a.appender&&a.appender(k,n),a.debug&&console.log("Rebuilt table"+c.benchmark(j)),b||a.appender||c.applyWidget(k),k.isUpdating&&a.$table.triggerHandler("updateComplete",k)},commonUpdate:function(a,b,d){a.$table.find(a.selectorRemove).remove(),c.setupParsers(a),c.buildCache(a),c.checkResort(a,b,d)},initSort:function(a,d,e){if(a.table.isUpdating)return setTimeout(function(){c.initSort(a,d,e)},50);var f,g,h,i,j,k,l,m=!e[a.sortMultiSortKey],n=a.table,o=a.$headers.length,p=parseInt(b(d).attr("data-column"),10),q=a.sortVars[p].order;if(a.$table.triggerHandler("sortStart",n),k=(a.sortVars[p].count+1)%q.length,a.sortVars[p].count=e[a.sortResetKey]?2:k,a.sortRestart)for(h=0;h<o;h++)l=a.$headers.eq(h),k=parseInt(l.attr("data-column"),10),p!==k&&(m||l.hasClass(c.css.sortNone))&&(a.sortVars[k].count=-1);if(m){if(a.sortList=[],a.last.sortList=[],null!==a.sortForce)for(f=a.sortForce,g=0;g<f.length;g++)f[g][0]!==p&&(a.sortList[a.sortList.length]=f[g]);if(i=q[a.sortVars[p].count],i<2&&(a.sortList[a.sortList.length]=[p,i],d.colSpan>1))for(g=1;g<d.colSpan;g++)a.sortList[a.sortList.length]=[p+g,i],a.sortVars[p+g].count=b.inArray(i,q)}else if(a.sortList=b.extend([],a.last.sortList),c.isValueInArray(p,a.sortList)>=0)for(g=0;g<a.sortList.length;g++)k=a.sortList[g],k[0]===p&&(k[1]=q[a.sortVars[p].count],2===k[1]&&(a.sortList.splice(g,1),a.sortVars[p].count=-1));else if(i=q[a.sortVars[p].count],i<2&&(a.sortList[a.sortList.length]=[p,i],d.colSpan>1))for(g=1;g<d.colSpan;g++)a.sortList[a.sortList.length]=[p+g,i],a.sortVars[p+g].count=b.inArray(i,q);if(a.last.sortList=b.extend([],a.sortList),a.sortList.length&&a.sortAppend&&(f=b.isArray(a.sortAppend)?a.sortAppend:a.sortAppend[a.sortList[0][0]],!c.isEmptyObject(f)))for(g=0;g<f.length;g++)if(f[g][0]!==p&&c.isValueInArray(f[g][0],a.sortList)<0){if(i=f[g][1],j=(""+i).match(/^(a|d|s|o|n)/))switch(k=a.sortList[0][1],j[0]){case"d":i=1;break;case"s":i=k;break;case"o":i=0===k?1:0;break;case"n":i=(k+1)%q.length;break;default:i=0}a.sortList[a.sortList.length]=[f[g][0],i]}a.$table.triggerHandler("sortBegin",n),setTimeout(function(){c.setHeadersCss(a),c.multisort(a),c.appendCache(a),a.$table.triggerHandler("sortBeforeEnd",n),a.$table.triggerHandler("sortEnd",n)},1)},multisort:function(a){var b,d,e,f,g,h=a.table,i=[],j=0,k=a.textSorter||"",l=a.sortList,m=l.length,n=a.$tbodies.length;if(!a.serverSideSorting&&!c.isEmptyObject(a.cache)){if(a.debug&&(d=new Date),"object"==typeof k)for(e=a.columns;e--;)g=c.getColumnData(h,k,e),"function"==typeof g&&(i[e]=g);for(b=0;b<n;b++)e=a.cache[b].colMax,f=a.cache[b].normalized,f.sort(function(b,d){var f,g,n,o,p,q,r;for(f=0;f<m;f++){if(n=l[f][0],o=l[f][1],j=0===o,a.sortStable&&b[n]===d[n]&&1===m)return b[a.columns].order-d[a.columns].order;if(g=/n/i.test(c.getSortType(a.parsers,n)),g&&a.strings[n]?(g="boolean"==typeof c.string[a.strings[n]]?(j?1:-1)*(c.string[a.strings[n]]?-1:1):a.strings[n]?c.string[a.strings[n]]||0:0,p=a.numberSorter?a.numberSorter(b[n],d[n],j,e[n],h):c["sortNumeric"+(j?"Asc":"Desc")](b[n],d[n],g,e[n],n,a)):(q=j?b:d,r=j?d:b,p="function"==typeof k?k(q[n],r[n],j,n,h):"function"==typeof i[n]?i[n](q[n],r[n],j,n,h):c["sortNatural"+(j?"Asc":"Desc")](b[n],d[n],n,a)),p)return p}return b[a.columns].order-d[a.columns].order});a.debug&&console.log("Applying sort "+l.toString()+c.benchmark(d))}},resortComplete:function(a,c){a.table.isUpdating&&a.$table.triggerHandler("updateComplete",a.table),b.isFunction(c)&&c(a.table)},checkResort:function(a,d,e){var f=b.isArray(d)?d:a.sortList,g="undefined"==typeof d?a.resort:d;g===!1||a.serverSideSorting||a.table.isProcessing?(c.resortComplete(a,e),c.applyWidget(a.table,!1)):f.length?c.sortOn(a,f,function(){c.resortComplete(a,e)},!0):c.sortReset(a,function(){c.resortComplete(a,e),c.applyWidget(a.table,!1)})},sortOn:function(a,d,e,f){var g=a.table;a.$table.triggerHandler("sortStart",g),c.updateHeaderSortCount(a,d),c.setHeadersCss(a),a.delayInit&&c.isEmptyObject(a.cache)&&c.buildCache(a),a.$table.triggerHandler("sortBegin",g),c.multisort(a),c.appendCache(a,f),a.$table.triggerHandler("sortBeforeEnd",g),a.$table.triggerHandler("sortEnd",g),c.applyWidget(g),b.isFunction(e)&&e(g)},sortReset:function(a,d){a.sortList=[],c.setHeadersCss(a),c.multisort(a),c.appendCache(a),b.isFunction(d)&&d(a.table)},getSortType:function(a,b){return a&&a[b]?a[b].type||"":""},getOrder:function(a){return/^d/i.test(a)||1===a},sortNatural:function(a,b){if(a===b)return 0;var d,e,f,g,h,i,j=c.regex;if(j.hex.test(b)){if(d=parseInt((a||"").match(j.hex),16),e=parseInt((b||"").match(j.hex),16),d<e)return-1;if(d>e)return 1}for(d=(a||"").replace(j.chunk,"\\0$1\\0").replace(j.chunks,"").split("\\0"),e=(b||"").replace(j.chunk,"\\0$1\\0").replace(j.chunks,"").split("\\0"),i=Math.max(d.length,e.length),h=0;h<i;h++){if(f=isNaN(d[h])?d[h]||0:parseFloat(d[h])||0,g=isNaN(e[h])?e[h]||0:parseFloat(e[h])||0,isNaN(f)!==isNaN(g))return isNaN(f)?1:-1;if(typeof f!=typeof g&&(f+="",g+=""),f<g)return-1;if(f>g)return 1}return 0},sortNaturalAsc:function(a,b,d,e){if(a===b)return 0;var f=c.string[e.empties[d]||e.emptyTo];return""===a&&0!==f?"boolean"==typeof f?f?-1:1:-f||-1:""===b&&0!==f?"boolean"==typeof f?f?1:-1:f||1:c.sortNatural(a,b)},sortNaturalDesc:function(a,b,d,e){if(a===b)return 0;var f=c.string[e.empties[d]||e.emptyTo];return""===a&&0!==f?"boolean"==typeof f?f?-1:1:f||1:""===b&&0!==f?"boolean"==typeof f?f?1:-1:-f||-1:c.sortNatural(b,a)},sortText:function(a,b){return a>b?1:a<b?-1:0},getTextValue:function(a,b,c){if(c){var d,e=a?a.length:0,f=c+b;for(d=0;d<e;d++)f+=a.charCodeAt(d);return b*f}return 0},sortNumericAsc:function(a,b,d,e,f,g){if(a===b)return 0;var h=c.string[g.empties[f]||g.emptyTo];return""===a&&0!==h?"boolean"==typeof h?h?-1:1:-h||-1:""===b&&0!==h?"boolean"==typeof h?h?1:-1:h||1:(isNaN(a)&&(a=c.getTextValue(a,d,e)),isNaN(b)&&(b=c.getTextValue(b,d,e)),a-b)},sortNumericDesc:function(a,b,d,e,f,g){if(a===b)return 0;var h=c.string[g.empties[f]||g.emptyTo];return""===a&&0!==h?"boolean"==typeof h?h?-1:1:h||1:""===b&&0!==h?"boolean"==typeof h?h?1:-1:-h||-1:(isNaN(a)&&(a=c.getTextValue(a,d,e)),isNaN(b)&&(b=c.getTextValue(b,d,e)),b-a)},sortNumeric:function(a,b){return a-b},addWidget:function(a){a.id&&!c.isEmptyObject(c.getWidgetById(a.id))&&console.warn('"'+a.id+'" widget was loaded more than once!'),c.widgets[c.widgets.length]=a},hasWidget:function(a,c){return a=b(a),a.length&&a[0].config&&a[0].config.widgetInit[c]||!1},getWidgetById:function(a){var b,d,e=c.widgets.length;for(b=0;b<e;b++)if(d=c.widgets[b],d&&d.id&&d.id.toLowerCase()===a.toLowerCase())return d},applyWidgetOptions:function(a){var d,e,f=a.config,g=f.widgets.length;if(g)for(d=0;d<g;d++)e=c.getWidgetById(f.widgets[d]),e&&e.options&&(f.widgetOptions=b.extend(!0,{},e.options,f.widgetOptions))},addWidgetFromClass:function(a){var b,d,e=a.config,f="^"+e.widgetClass.replace(c.regex.templateName,"(\\S+)+")+"$",g=new RegExp(f,"g"),h=(a.className||"").split(c.regex.spaces);if(h.length)for(b=h.length,d=0;d<b;d++)h[d].match(g)&&(e.widgets[e.widgets.length]=h[d].replace(g,"$1"))},applyWidgetId:function(a,d,e){a=b(a)[0];var f,g,h,i=a.config,j=i.widgetOptions,k=c.getWidgetById(d);k&&(h=k.id,f=!1,b.inArray(h,i.widgets)<0&&(i.widgets[i.widgets.length]=h),i.debug&&(g=new Date),!e&&i.widgetInit[h]||(i.widgetInit[h]=!0,a.hasInitialized&&c.applyWidgetOptions(a),"function"==typeof k.init&&(f=!0,i.debug&&console[console.group?"group":"log"]("Initializing "+h+" widget"),k.init(a,k,i,j))),e||"function"!=typeof k.format||(f=!0,i.debug&&console[console.group?"group":"log"]("Updating "+h+" widget"),k.format(a,i,j,!1)),i.debug&&f&&(console.log("Completed "+(e?"initializing ":"applying ")+h+" widget"+c.benchmark(g)),console.groupEnd&&console.groupEnd()))},applyWidget:function(a,d,e){a=b(a)[0];var f,g,h,i,j,k=a.config,l=[];if(d===!1||!a.hasInitialized||!a.isApplyingWidgets&&!a.isUpdating){if(k.debug&&(j=new Date),c.addWidgetFromClass(a),clearTimeout(k.timerReady),k.widgets.length){for(a.isApplyingWidgets=!0,k.widgets=b.grep(k.widgets,function(a,c){return b.inArray(a,k.widgets)===c}),h=k.widgets||[],g=h.length,f=0;f<g;f++)i=c.getWidgetById(h[f]),i&&i.id?(i.priority||(i.priority=10),l[f]=i):k.debug&&console.warn('"'+h[f]+'" widget code does not exist!');for(l.sort(function(a,b){return a.priority<b.priority?-1:a.priority===b.priority?0:1}),g=l.length,k.debug&&console[console.group?"group":"log"]("Start "+(d?"initializing":"applying")+" widgets"),f=0;f<g;f++)i=l[f],i&&i.id&&c.applyWidgetId(a,i.id,d);k.debug&&console.groupEnd&&console.groupEnd(),d||"function"!=typeof e||e(a)}k.timerReady=setTimeout(function(){a.isApplyingWidgets=!1,b.data(a,"lastWidgetApplication",new Date),k.$table.triggerHandler("tablesorter-ready")},10),k.debug&&(i=k.widgets.length,console.log("Completed "+(d===!0?"initializing ":"applying ")+i+" widget"+(1!==i?"s":"")+c.benchmark(j)))}},removeWidget:function(a,d,e){a=b(a)[0];var f,g,h,i,j=a.config;if(d===!0)for(d=[],i=c.widgets.length,h=0;h<i;h++)g=c.widgets[h],g&&g.id&&(d[d.length]=g.id);else d=(b.isArray(d)?d.join(","):d||"").toLowerCase().split(/[\s,]+/);for(i=d.length,f=0;f<i;f++)g=c.getWidgetById(d[f]),h=b.inArray(d[f],j.widgets),h>=0&&e!==!0&&j.widgets.splice(h,1),g&&g.remove&&(j.debug&&console.log((e?"Refreshing":"Removing")+' "'+d[f]+'" widget'),g.remove(a,j,j.widgetOptions,e),j.widgetInit[d[f]]=!1)},refreshWidgets:function(a,d,e){a=b(a)[0];var f,g,h=a.config,i=h.widgets,j=c.widgets,k=j.length,l=[],m=function(a){b(a).triggerHandler("refreshComplete")};for(f=0;f<k;f++)g=j[f],g&&g.id&&(d||b.inArray(g.id,i)<0)&&(l[l.length]=g.id);c.removeWidget(a,l.join(","),!0),e!==!0?(c.applyWidget(a,d||!1,m),d&&c.applyWidget(a,!1,m)):m(a)},benchmark:function(a){return" ("+((new Date).getTime()-a.getTime())+" ms)"},log:function(){console.log(arguments)},isEmptyObject:function(a){for(var b in a)return!1;return!0},isValueInArray:function(a,b){var c,d=b&&b.length||0;for(c=0;c<d;c++)if(b[c][0]===a)return c;return-1},formatFloat:function(a,d){if("string"!=typeof a||""===a)return a;var e,f=d&&d.config?d.config.usNumberFormat!==!1:"undefined"==typeof d||d;return a=f?a.replace(c.regex.comma,""):a.replace(c.regex.digitNonUS,"").replace(c.regex.comma,"."),c.regex.digitNegativeTest.test(a)&&(a=a.replace(c.regex.digitNegativeReplace,"-$1")),
2
- e=parseFloat(a),isNaN(e)?b.trim(a):e},isDigit:function(a){return isNaN(a)?c.regex.digitTest.test(a.toString().replace(c.regex.digitReplace,"")):""!==a},computeColumnIndex:function(a,c){var d,e,f,g,h,i,j,k,l,m,n=c&&c.columns||0,o=[],p=new Array(n);for(d=0;d<a.length;d++)for(i=a[d].cells,e=0;e<i.length;e++){for(h=i[e],j=h.parentNode.rowIndex,k=h.rowSpan||1,l=h.colSpan||1,"undefined"==typeof o[j]&&(o[j]=[]),f=0;f<o[j].length+1;f++)if("undefined"==typeof o[j][f]){m=f;break}for(n&&h.cellIndex===m||(h.setAttribute?h.setAttribute("data-column",m):b(h).attr("data-column",m)),f=j;f<j+k;f++)for("undefined"==typeof o[f]&&(o[f]=[]),p=o[f],g=m;g<m+l;g++)p[g]="x"}return p.length},fixColumnWidth:function(a){a=b(a)[0];var d,e,f,g,h,i=a.config,j=i.$table.children("colgroup");if(j.length&&j.hasClass(c.css.colgroup)&&j.remove(),i.widthFixed&&0===i.$table.children("colgroup").length){for(j=b('<colgroup class="'+c.css.colgroup+'">'),d=i.$table.width(),f=i.$tbodies.find("tr:first").children(":visible"),g=f.length,h=0;h<g;h++)e=parseInt(f.eq(h).width()/d*1e3,10)/10+"%",j.append(b("<col>").css("width",e));i.$table.prepend(j)}},getData:function(a,c,d){var e,f,g="",h=b(a);return h.length?(e=!!b.metadata&&h.metadata(),f=" "+(h.attr("class")||""),"undefined"!=typeof h.data(d)||"undefined"!=typeof h.data(d.toLowerCase())?g+=h.data(d)||h.data(d.toLowerCase()):e&&"undefined"!=typeof e[d]?g+=e[d]:c&&"undefined"!=typeof c[d]?g+=c[d]:" "!==f&&f.match(" "+d+"-")&&(g=f.match(new RegExp("\\s"+d+"-([\\w-]+)"))[1]||""),b.trim(g)):""},getColumnData:function(a,c,d,e,f){if("undefined"!=typeof c&&null!==c){a=b(a)[0];var g,h,i=a.config,j=f||i.$headers,k=i.$headerIndexed&&i.$headerIndexed[d]||j.filter('[data-column="'+d+'"]:last');if("undefined"!=typeof c[d])return e?c[d]:c[j.index(k)];for(h in c)if("string"==typeof h&&(g=k.filter(h).add(k.find(h)),g.length))return c[h]}},isProcessing:function(a,d,e){a=b(a);var f=a[0].config,g=e||a.find("."+c.css.header);d?("undefined"!=typeof e&&f.sortList.length>0&&(g=g.filter(function(){return!this.sortDisabled&&c.isValueInArray(parseFloat(b(this).attr("data-column")),f.sortList)>=0})),a.add(g).addClass(c.css.processing+" "+f.cssProcessing)):a.add(g).removeClass(c.css.processing+" "+f.cssProcessing)},processTbody:function(a,c,d){if(a=b(a)[0],d)return a.isProcessing=!0,c.before('<colgroup class="tablesorter-savemyplace"/>'),b.fn.detach?c.detach():c.remove();var e=b(a).find("colgroup.tablesorter-savemyplace");c.insertAfter(e),e.remove(),a.isProcessing=!1},clearTableBody:function(a){b(a)[0].config.$tbodies.children().detach()},characterEquivalents:{a:"áàâãäąå",A:"ÁÀÂÃÄĄÅ",c:"çćč",C:"ÇĆČ",e:"éèêëěę",E:"ÉÈÊËĚĘ",i:"íìİîïı",I:"ÍÌİÎÏ",o:"óòôõöō",O:"ÓÒÔÕÖŌ",ss:"ß",SS:"ẞ",u:"úùûüů",U:"ÚÙÛÜŮ"},replaceAccents:function(a){var b,d="[",e=c.characterEquivalents;if(!c.characterRegex){c.characterRegexArray={};for(b in e)"string"==typeof b&&(d+=e[b],c.characterRegexArray[b]=new RegExp("["+e[b]+"]","g"));c.characterRegex=new RegExp(d+"]")}if(c.characterRegex.test(a))for(b in e)"string"==typeof b&&(a=a.replace(c.characterRegexArray[b],b));return a},restoreHeaders:function(a){var d,e,f=b(a)[0].config,g=f.$table.find(f.selectorHeaders),h=g.length;for(d=0;d<h;d++)e=g.eq(d),e.find("."+c.css.headerIn).length&&e.html(f.headerContent[d])},destroy:function(a,d,e){if(a=b(a)[0],a.hasInitialized){c.removeWidget(a,!0,!1);var f,g=b(a),h=a.config,i=h.debug,j=g.find("thead:first"),k=j.find("tr."+c.css.headerRow).removeClass(c.css.headerRow+" "+h.cssHeaderRow),l=g.find("tfoot:first > tr").children("th, td");d===!1&&b.inArray("uitheme",h.widgets)>=0&&(g.triggerHandler("applyWidgetId",["uitheme"]),g.triggerHandler("applyWidgetId",["zebra"])),j.find("tr").not(k).remove(),f="sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave "+"keypress sortBegin sortEnd resetToLoadState ".split(" ").join(h.namespace+" "),g.removeData("tablesorter").unbind(f.replace(c.regex.spaces," ")),h.$headers.add(l).removeClass([c.css.header,h.cssHeader,h.cssAsc,h.cssDesc,c.css.sortAsc,c.css.sortDesc,c.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true"),k.find(h.selectorSort).unbind("mousedown mouseup keypress ".split(" ").join(h.namespace+" ").replace(c.regex.spaces," ")),c.restoreHeaders(a),g.toggleClass(c.css.table+" "+h.tableClass+" tablesorter-"+h.theme,d===!1),a.hasInitialized=!1,delete a.config.cache,"function"==typeof e&&e(a),i&&console.log("tablesorter has been removed")}}};b.fn.tablesorter=function(a){return this.each(function(){var d=this,e=b.extend(!0,{},c.defaults,a,c.instanceMethods);e.originalSettings=a,!d.hasInitialized&&c.buildTable&&"TABLE"!==this.nodeName?c.buildTable(d,e):c.setup(d,e)})},window.console&&window.console.log||(c.logs=[],console={},console.log=console.warn=console.error=console.table=function(){var a=arguments.length>1?arguments:arguments[0];c.logs[c.logs.length]={date:Date.now(),log:a}}),c.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),c.addParser({id:"text",is:function(){return!0},format:function(a,d){var e=d.config;return a&&(a=b.trim(e.ignoreCase?a.toLocaleLowerCase():a),a=e.sortLocaleCompare?c.replaceAccents(a):a),a},type:"text"}),c.regex.nondigit=/[^\w,. \-()]/g,c.addParser({id:"digit",is:function(a){return c.isDigit(a)},format:function(a,d){var e=c.formatFloat((a||"").replace(c.regex.nondigit,""),d);return a&&"number"==typeof e?e:a?b.trim(a&&d.config.ignoreCase?a.toLocaleLowerCase():a):a},type:"numeric"}),c.regex.currencyReplace=/[+\-,. ]/g,c.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,c.addParser({id:"currency",is:function(a){return a=(a||"").replace(c.regex.currencyReplace,""),c.regex.currencyTest.test(a)},format:function(a,d){var e=c.formatFloat((a||"").replace(c.regex.nondigit,""),d);return a&&"number"==typeof e?e:a?b.trim(a&&d.config.ignoreCase?a.toLocaleLowerCase():a):a},type:"numeric"}),c.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,c.regex.urlProtocolReplace=/(https?|ftp|file):\/\/(www\.)?/,c.addParser({id:"url",is:function(a){return c.regex.urlProtocolTest.test(a)},format:function(a){return a?b.trim(a.replace(c.regex.urlProtocolReplace,"")):a},type:"text"}),c.regex.dash=/-/g,c.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,c.addParser({id:"isoDate",is:function(a){return c.regex.isoDate.test(a)},format:function(a,b){var d=a?new Date(a.replace(c.regex.dash,"/")):a;return d instanceof Date&&isFinite(d)?d.getTime():a},type:"numeric"}),c.regex.percent=/%/g,c.regex.percentTest=/(\d\s*?%|%\s*?\d)/,c.addParser({id:"percent",is:function(a){return c.regex.percentTest.test(a)&&a.length<15},format:function(a,b){return a?c.formatFloat(a.replace(c.regex.percent,""),b):a},type:"numeric"}),c.addParser({id:"image",is:function(a,b,c,d){return d.find("img").length>0},format:function(a,c,d){return b(d).find("img").attr(c.config.imgAttr||"alt")||a},parsed:!0,type:"text"}),c.regex.dateReplace=/(\S)([AP]M)$/i,c.regex.usLongDateTest1=/^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i,c.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,c.addParser({id:"usLongDate",is:function(a){return c.regex.usLongDateTest1.test(a)||c.regex.usLongDateTest2.test(a)},format:function(a,b){var d=a?new Date(a.replace(c.regex.dateReplace,"$1 $2")):a;return d instanceof Date&&isFinite(d)?d.getTime():a},type:"numeric"}),c.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,c.regex.shortDateReplace=/[\-.,]/g,c.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,c.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,c.convertFormat=function(a,b){a=(a||"").replace(c.regex.spaces," ").replace(c.regex.shortDateReplace,"/"),"mmddyyyy"===b?a=a.replace(c.regex.shortDateXXY,"$3/$1/$2"):"ddmmyyyy"===b?a=a.replace(c.regex.shortDateXXY,"$3/$2/$1"):"yyyymmdd"===b&&(a=a.replace(c.regex.shortDateYMD,"$1/$2/$3"));var d=new Date(a);return d instanceof Date&&isFinite(d)?d.getTime():""},c.addParser({id:"shortDate",is:function(a){return a=(a||"").replace(c.regex.spaces," ").replace(c.regex.shortDateReplace,"/"),c.regex.shortDateTest.test(a)},format:function(a,b,d,e){if(a){var f=b.config,g=f.$headerIndexed[e],h=g.length&&g.data("dateFormat")||c.getData(g,c.getColumnData(b,f.headers,e),"dateFormat")||f.dateFormat;return g.length&&g.data("dateFormat",h),c.convertFormat(a,h)||a}return a},type:"numeric"}),c.regex.timeTest=/^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i,c.regex.timeMatch=/(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i,c.addParser({id:"time",is:function(a){return c.regex.timeTest.test(a)},format:function(a,b){var d,e=(a||"").match(c.regex.timeMatch),f=new Date(a),g=a&&(null!==e?e[0]:"00:00 AM"),h=g?new Date("2000/01/01 "+g.replace(c.regex.dateReplace,"$1 $2")):g;return h instanceof Date&&isFinite(h)?(d=f instanceof Date&&isFinite(f)?f.getTime():0,d?parseFloat(h.getTime()+"."+f.getTime()):h.getTime()):a},type:"numeric"}),c.addParser({id:"metadata",is:function(){return!1},format:function(a,c,d){var e=c.config,f=e.parserMetadataName?e.parserMetadataName:"sortValue";return b(d).metadata()[f]},type:"numeric"}),c.addWidget({id:"zebra",priority:90,format:function(a,c,d){var e,f,g,h,i,j,k,l=new RegExp(c.cssChildRow,"i"),m=c.$tbodies.add(b(c.namespace+"_extra_table").children("tbody:not(."+c.cssInfoBlock+")"));for(i=0;i<m.length;i++)for(g=0,e=m.eq(i).children("tr:visible").not(c.selectorRemove),k=e.length,j=0;j<k;j++)f=e.eq(j),l.test(f[0].className)||g++,h=g%2===0,f.removeClass(d.zebra[h?1:0]).addClass(d.zebra[h?0:1])},remove:function(a,b,d,e){if(!e){var f,g,h=b.$tbodies,i=(d.zebra||["even","odd"]).join(" ");for(f=0;f<h.length;f++)g=c.processTbody(a,h.eq(f),!0),g.children().removeClass(i),c.processTbody(a,g,!1)}}})}(a),a.tablesorter});
 
 
js/jquery.tablesorter.pager.js CHANGED
@@ -1,6 +1,6 @@
1
  /*!
2
  * tablesorter (FORK) pager plugin
3
- * updated 9/23/2016 (v2.27.7)
4
  */
5
  /*jshint browser:true, jquery:true, unused:false */
6
  ;(function($) {
@@ -27,7 +27,7 @@
27
  customAjaxUrl: function(table, url) { return url; },
28
 
29
  // ajax error callback from $.tablesorter.showError function
30
- // ajaxError: function( config, xhr, settings, exception ){ return exception; };
31
  // returning false will abort the error message
32
  ajaxError: null,
33
 
@@ -52,7 +52,7 @@
52
  // ],
53
  // [ "header1", "header2", ... "headerN" ] // optional
54
  // ]
55
- ajaxProcessing: function(ajax){ return [ 0, [], null ]; },
56
 
57
  // output default: '{page}/{totalPages}'
58
  // possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow},
@@ -128,16 +128,25 @@
128
 
129
  // hide arrows at extremes
130
  pagerArrows = function( table, p, disable ) {
131
- var a = 'addClass',
132
- r = 'removeClass',
133
- d = p.cssDisabled,
134
- dis = !!disable,
135
- first = ( dis || p.page === 0 ),
136
- tp = getTotalPages( table, p ),
137
- last = ( dis || (p.page === tp - 1) || tp === 0 );
 
138
  if ( p.updateArrows ) {
139
- p.$container.find(p.cssFirst + ',' + p.cssPrev)[ first ? a : r ](d).attr('aria-disabled', first);
140
- p.$container.find(p.cssNext + ',' + p.cssLast)[ last ? a : r ](d).attr('aria-disabled', last);
 
 
 
 
 
 
 
 
141
  }
142
  },
143
 
@@ -164,7 +173,7 @@
164
 
165
  updatePageDisplay = function(table, p, completed) {
166
  if ( p.initializing ) { return; }
167
- var s, t, $out, indx, len, options,
168
  c = table.config,
169
  namespace = c.namespace + 'pager',
170
  sz = parsePageSize( p, p.size, 'get' ); // don't allow dividing by zero
@@ -187,14 +196,18 @@
187
  if (typeof p.output === 'function') {
188
  s = p.output(table, p);
189
  } else {
 
 
 
 
190
  // form the output string (can now get a new output string from the server)
191
- s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || p.output : p.output )
192
  // {page} = one-based index; {page+#} = zero based index +/- value
193
- .replace(/\{page([\-+]\d+)?\}/gi, function(m, n){
194
  return p.totalPages ? p.page + (n ? parseInt(n, 10) : 1) : 0;
195
  })
196
  // {totalPages}, {extra}, {extra:0} (array) or {extra : key} (object)
197
- .replace(/\{\w+(\s*:\s*\w+)?\}/gi, function(m){
198
  var len, indx,
199
  str = m.replace(/[{}\s]/g, ''),
200
  extra = str.split(':'),
@@ -209,7 +222,8 @@
209
  return extra.length > 1 && data && data[extra[0]] ? data[extra[0]][extra[1]] : p[str] || (data ? data[str] : deflt) || deflt;
210
  });
211
  }
212
- if ( p.$goto.length ) {
 
213
  t = '';
214
  options = buildPageSelect( table, p );
215
  len = options.length;
@@ -217,12 +231,12 @@
217
  t += '<option value="' + options[indx] + '">' + options[indx] + '</option>';
218
  }
219
  // innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228
220
- p.$goto.html(t).val( p.page + 1 );
221
  }
222
  if ($out.length) {
223
  $out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
224
  // rebind startRow/page inputs
225
- $out.find('.ts-startRow, .ts-page').unbind('change' + namespace).bind('change' + namespace, function(){
226
  var v = $(this).val(),
227
  pg = $(this).hasClass('ts-startRow') ? Math.floor( v / sz ) + 1 : v;
228
  c.$table.triggerHandler('pageSet' + namespace, [ pg ]);
@@ -232,8 +246,8 @@
232
  pagerArrows( table, p );
233
  fixHeight(table, p);
234
  if (p.initialized && completed !== false) {
235
- if (c.debug) {
236
- console.log('Pager: Triggering pagerComplete');
237
  }
238
  c.$table.triggerHandler('pagerComplete', p);
239
  // save pager info to storage
@@ -307,16 +321,22 @@
307
  },
308
 
309
  fixHeight = function(table, p) {
310
- var d, h,
311
  c = table.config,
312
  $b = c.$tbodies.eq(0);
313
  $b.find('tr.pagerSavedHeightSpacer').remove();
314
  if (p.fixedHeight && !p.isDisabled) {
315
  h = $.data(table, 'pagerSavedHeight');
316
  if (h) {
317
- d = h - $b.height();
318
- if ( d > 5 && $.data(table, 'pagerLastSize') === p.size &&
319
- $b.children('tr:visible').length < (p.size === 'all' ? p.totalRows : p.size) ) {
 
 
 
 
 
 
320
  $b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '" style="height:' + d + 'px;"></tr>');
321
  }
322
  }
@@ -337,7 +357,7 @@
337
  $.data(table, 'pagerLastSize', p.size);
338
  },
339
 
340
- hideRows = function(table, p){
341
  if (!p.ajaxUrl) {
342
  var i,
343
  lastIndex = 0,
@@ -347,10 +367,10 @@
347
  sz = p.size === 'all' ? p.totalRows : p.size,
348
  s = ( p.page * sz ),
349
  e = s + sz,
350
- last = 0, // for cache indexing
351
  j = 0; // size counter
352
  p.cacheIndex = [];
353
- for ( i = 0; i < l; i++ ){
354
  if ( !p.regexFiltered.test(rows[i].className) ) {
355
  if (j === s && rows[i].className.match(c.cssChildRow)) {
356
  // hide child rows @ start of pager (if already visible)
@@ -378,20 +398,19 @@
378
  }
379
  },
380
 
381
- hideRowsSetup = function(table, p){
382
- p.size = parsePageSize( p, p.$size.val(), 'get' );
383
- p.$size.val( p.size );
384
- $.data(table, 'pagerLastSize', p.size);
385
  pagerArrows( table, p );
386
  if ( !p.removeRows ) {
387
  hideRows(table, p);
388
- $(table).bind('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function(){
389
  hideRows(table, p);
390
  });
391
  }
392
  },
393
 
394
- renderAjax = function(data, table, p, xhr, settings, exception){
395
  // process data
396
  if ( typeof p.ajaxProcessing === 'function' ) {
397
 
@@ -405,15 +424,13 @@
405
  c = table.config,
406
  $table = c.$table,
407
  tds = '',
408
- result = p.ajaxProcessing(data, table, xhr) || [ 0, [] ],
409
- hl = $table.find('thead th').length;
410
-
411
  // Clean up any previous error.
412
  ts.showError( table );
413
 
414
  if ( exception ) {
415
- if (c.debug) {
416
- console.error('Pager: >> Ajax Error', xhr, settings, exception);
417
  }
418
  ts.showError( table, xhr, settings, exception );
419
  c.$tbodies.eq(0).children('tr').detach();
@@ -439,7 +456,7 @@
439
  th = result[2]; // headers
440
  }
441
  l = d && d.length;
442
- if (d instanceof jQuery) {
443
  if (p.processAjaxOnInit) {
444
  // append jQuery object
445
  c.$tbodies.eq(0).empty();
@@ -461,10 +478,12 @@
461
  }
462
  }
463
  p.processAjaxOnInit = true;
464
- // only add new header text if the length matches
465
- if ( th && th.length === hl ) {
466
  hsh = $table.hasClass('hasStickyHeaders');
467
- $sh = hsh ? c.widgetOptions.$sticky.children('thead:first').children('tr').children() : '';
 
 
468
  $f = $table.find('tfoot tr:first').children();
469
  // don't change td headers (may contain pager)
470
  $headers = c.$headers.filter( 'th ' );
@@ -474,15 +493,17 @@
474
  // add new test within the first span it finds, or just in the header
475
  if ( $h.find('.' + ts.css.icon).length ) {
476
  icon = $h.find('.' + ts.css.icon).clone(true);
477
- $h.find('.tablesorter-header-inner').html( th[j] ).append(icon);
478
  if ( hsh && $sh.length ) {
479
  icon = $sh.eq(j).find('.' + ts.css.icon).clone(true);
480
- $sh.eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icon);
481
  }
482
  } else {
483
- $h.find('.tablesorter-header-inner').html( th[j] );
484
  if (hsh && $sh.length) {
485
- $sh.eq(j).find('.tablesorter-header-inner').html( th[j] );
 
 
486
  }
487
  }
488
  $f.eq(j).html( th[j] );
@@ -501,13 +522,13 @@
501
  p.last.sortList = (c.sortList || []).join(',');
502
  updatePageDisplay(table, p, false);
503
  // tablesorter core updateCache (not pager)
504
- ts.updateCache( c, function(){
505
  if (p.initialized) {
506
  // apply widgets after table has rendered & after a delay to prevent
507
  // multiple applyWidget blocking code from blocking this trigger
508
- setTimeout(function(){
509
- if (c.debug) {
510
- console.log('Pager: Triggering pagerChange');
511
  }
512
  $table.triggerHandler( 'pagerChange', p );
513
  ts.applyWidget( table );
@@ -543,7 +564,7 @@
543
  p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
544
  p.ajaxObject.success = function(data, status, jqxhr) {
545
  // Refuse to process old ajax commands that were overwritten by new ones - see #443
546
- if (counter < p.ajaxCounter){
547
  return;
548
  }
549
  renderAjax(data, table, p, jqxhr);
@@ -552,8 +573,8 @@
552
  p.oldAjaxSuccess(data);
553
  }
554
  };
555
- if (c.debug) {
556
- console.log('Pager: Ajax initialized', p.ajaxObject);
557
  }
558
  $.ajax(p.ajaxObject);
559
  }
@@ -564,7 +585,7 @@
564
  c = table.config,
565
  url = (p.ajaxUrl) ? p.ajaxUrl
566
  // allow using "{page+1}" in the url string to switch to a non-zero based index
567
- .replace(/\{page([\-+]\d+)?\}/, function(s, n){ return p.page + (n ? parseInt(n, 10) : 0); })
568
  // this will pass "all" to server when size is set to "all"
569
  .replace(/\{size\}/g, p.size) : '',
570
  sortList = c.sortList,
@@ -597,8 +618,8 @@
597
  if ( typeof p.customAjaxUrl === 'function' ) {
598
  url = p.customAjaxUrl(table, url);
599
  }
600
- if (c.debug) {
601
- console.log('Pager: Ajax url = ' + url);
602
  }
603
  return url;
604
  },
@@ -607,13 +628,14 @@
607
  var $tb, index, count, added,
608
  $t = $(table),
609
  c = table.config,
 
610
  f = c.$table.hasClass('hasFilters'),
611
  l = rows && rows.length || 0, // rows may be undefined
612
  e = p.size === 'all' ? p.totalRows : p.size,
613
  s = ( p.page * e );
614
  if ( l < 1 ) {
615
- if (c.debug) {
616
- console.warn('Pager: >> No rows for pager to render');
617
  }
618
  // empty table, abort!
619
  return;
@@ -625,8 +647,8 @@
625
  p.cacheIndex = [];
626
  p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
627
  if (p.initialized) {
628
- if (c.debug) {
629
- console.log('Pager: Triggering pagerChange');
630
  }
631
  $t.triggerHandler( 'pagerChange', p );
632
  }
@@ -641,7 +663,7 @@
641
  count = f ? 0 : s;
642
  added = 0;
643
  while (added < e && index < rows.length) {
644
- if (!f || !p.regexFiltered.test(rows[index][0].className)){
645
  count++;
646
  if (count > s && added <= e) {
647
  added++;
@@ -655,8 +677,8 @@
655
  }
656
  updatePageDisplay(table, p);
657
  if (table.isUpdating) {
658
- if (c.debug) {
659
- console.log('Pager: Triggering updateComplete');
660
  }
661
  $t.triggerHandler('updateComplete', [ table, true ]);
662
  }
@@ -670,28 +692,25 @@
670
  $.data(table, 'pagerLastPage', p.page);
671
  $.data(table, 'pagerLastSize', p.size);
672
  p.page = 0;
673
- p.size = 'all';
674
  p.totalPages = 1;
675
  $(table)
676
- .addClass('pagerDisabled')
677
- .removeAttr('aria-describedby')
678
- .find('tr.pagerSavedHeightSpacer').remove();
679
  renderTable(table, table.config.rowsCopy, p);
680
  p.isDisabled = true;
681
  ts.applyWidget( table );
682
- if (table.config.debug) {
683
- console.log('Pager: Disabled');
684
  }
685
  }
686
  // disable size selector
687
- $controls = p.$size
688
- .add( p.$goto )
689
- .add( p.$container.find( '.ts-startRow, .ts-page' ) );
690
  len = $controls.length;
691
  for ( index = 0; index < len; index++ ) {
692
- $controls.eq( index )
693
- .attr( 'aria-disabled', 'true' )
694
- .addClass( p.cssDisabled )[0].disabled = true;
695
  }
696
  },
697
 
@@ -700,7 +719,7 @@
700
  var c = table.config,
701
  p = c.pager;
702
  // tablesorter core updateCache (not pager)
703
- ts.updateCache( c, function(){
704
  var i,
705
  rows = [],
706
  n = table.config.cache[0].normalized;
@@ -716,9 +735,10 @@
716
  moveToPage = function(table, p, pageMoved) {
717
  if ( p.isDisabled ) { return; }
718
  var tmp,
719
- c = table.config,
720
- $t = $(table),
721
- l = p.last;
 
722
  if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) {
723
  return updateCache(table);
724
  }
@@ -738,8 +758,8 @@
738
  // & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
739
  (l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
740
  l.sortList === (c.sortList || []).join(',') ) { return; }
741
- if (c.debug) {
742
- console.log('Pager: Changing to page ' + p.page);
743
  }
744
  p.last = {
745
  page : p.page,
@@ -756,9 +776,9 @@
756
  p.processAjaxOnInit = true;
757
  tmp = p.initialRows;
758
  p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
759
- ( c.debug ? console.error('Pager: no initial total page set!') || 0 : 0 );
760
  p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered :
761
- ( c.debug ? console.error('Pager: no initial filtered page set!') || 0 : 0 );
762
  pagerInitialized( table, p );
763
  } else {
764
  getAjax(table, p);
@@ -768,14 +788,14 @@
768
  }
769
  $.data(table, 'pagerLastPage', p.page);
770
  if (p.initialized && pageMoved !== false) {
771
- if (c.debug) {
772
- console.log('Pager: Triggering pageMoved');
773
  }
774
  $t.triggerHandler('pageMoved', p);
775
  ts.applyWidget( table );
776
  if (table.isUpdating) {
777
- if (c.debug) {
778
- console.log('Pager: Triggering updateComplete');
779
  }
780
  $t.triggerHandler('updateComplete', [ table, true ]);
781
  }
@@ -783,15 +803,9 @@
783
  },
784
 
785
  getTotalPages = function( table, p ) {
786
- return ts.hasWidget( table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages;
787
- },
788
-
789
- // set to either set or get value
790
- parsePageSize = function( p, size, mode ) {
791
- var s = parseInt( size, 10 ) || p.size || p.settings.size || 10;
792
- return p.initialized && (/all/i.test( size ) || s === p.totalRows) ?
793
- // "get" to get `p.size` or "set" to set `p.$size.val()`
794
- 'all' : ( mode === 'get' ? s : p.size );
795
  },
796
 
797
  parsePageNumber = function( table, p ) {
@@ -802,14 +816,26 @@
802
  return p.page;
803
  },
804
 
 
 
 
 
 
 
 
 
 
 
 
 
805
  setPageSize = function(table, size, p) {
 
806
  p.size = parsePageSize( p, size, 'get' );
807
- p.$size.val( parsePageSize( p, p.size, 'set' ) );
808
  $.data(table, 'pagerLastPage', parsePageNumber( table, p ) );
809
  $.data(table, 'pagerLastSize', p.size);
810
  p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
811
  p.filteredPages = p.size === 'all' ? 1 : Math.ceil( p.filteredRows / p.size );
812
- moveToPage(table, p);
813
  },
814
 
815
  moveToFirstPage = function(table, p) {
@@ -842,14 +868,20 @@
842
  pagerInitialized = function(table, p) {
843
  p.initialized = true;
844
  p.initializing = false;
845
- if (table.config.debug) {
846
- console.log('Pager: Triggering pagerInitialized');
847
  }
848
  $(table).triggerHandler( 'pagerInitialized', p );
849
  ts.applyWidget( table );
850
  updatePageDisplay(table, p);
851
  },
852
 
 
 
 
 
 
 
853
  destroyPager = function(table, p) {
854
  var c = table.config,
855
  namespace = c.namespace + 'pager',
@@ -873,16 +905,19 @@
873
  enablePager = function(table, p, triggered) {
874
  var info, size, $el,
875
  c = table.config;
876
- p.$size.add(p.$goto).add(p.$container.find('.ts-startRow, .ts-page'))
877
  .removeClass(p.cssDisabled)
878
  .removeAttr('disabled')
879
- .attr('aria-disabled', 'false');
 
 
880
  p.isDisabled = false;
881
  p.page = $.data(table, 'pagerLastPage') || p.page || 0;
882
- size = p.$size.find('option[selected]').val();
 
883
  p.size = $.data(table, 'pagerLastSize') || parsePageSize( p, size, 'get' );
884
- p.$size.val( p.size ); // set page size
885
  p.totalPages = p.size === 'all' ? 1 : Math.ceil( getTotalPages( table, p ) / p.size );
 
886
  // if table id exists, include page display with aria info
887
  if ( table.id && !c.$table.attr( 'aria-describedby' ) ) {
888
  $el = p.$container.find( p.cssPageDisplay );
@@ -899,11 +934,231 @@
899
  // tablesorter core update table
900
  ts.update( c );
901
  setPageSize(table, p.size, p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
902
  hideRowsSetup(table, p);
903
- if (c.debug) {
904
- console.log('Pager: Enabled');
 
 
 
 
 
 
 
 
 
 
 
 
 
905
  }
906
  }
 
 
 
907
  };
908
 
909
  $this.appender = function(table, rows) {
@@ -924,204 +1179,7 @@
924
  return this.each(function() {
925
  // check if tablesorter has initialized
926
  if (!(this.config && this.hasInitialized)) { return; }
927
- var t, ctrls, fxn, size,
928
- table = this,
929
- c = table.config,
930
- wo = c.widgetOptions,
931
- p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ),
932
- $t = c.$table,
933
- namespace = c.namespace + 'pager',
934
- // added in case the pager is reinitialized after being destroyed.
935
- pager = p.$container = $(p.container).addClass('tablesorter-pager').show();
936
- // save a copy of the original settings
937
- p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
938
- if (c.debug) {
939
- console.log('Pager: Initializing');
940
- }
941
- p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
942
- c.appender = $this.appender;
943
- p.initializing = true;
944
- if (p.savePages && ts.storage) {
945
- t = ts.storage(table, p.storageKey) || {}; // fixes #387
946
- p.page = isNaN(t.page) ? p.page : t.page;
947
- p.size = t.size === 'all' ? t.size : ( isNaN( t.size ) ? p.size : t.size ) || p.setSize || 10;
948
- $.data(table, 'pagerLastSize', p.size);
949
- pager.find(p.cssPageSize).val(p.size);
950
- }
951
- // skipped rows
952
- p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
953
- p.regexFiltered = new RegExp(wo.filter_filteredRow || 'filtered');
954
-
955
- $t
956
- // .unbind( namespace ) adding in jQuery 1.4.3 ( I think )
957
- .unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
958
- .bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
959
- p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
960
- // don't change page if filters are the same (pager updating, etc)
961
- if (e.type === 'filterStart' && p.pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) {
962
- p.page = p.pageReset; // fixes #456 & #565
963
- }
964
- })
965
- // update pager after filter widget completes
966
- .bind('filterEnd sortEnd '.split(' ').join(namespace + ' '), function() {
967
- p.currentFilters = c.$table.data('lastSearch');
968
- if (p.initialized || p.initializing) {
969
- if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
970
- // make sure we have a copy of all table rows once the cache has been built
971
- updateCache(table);
972
- }
973
- updatePageDisplay(table, p, false);
974
- moveToPage(table, p, false);
975
- ts.applyWidget( table );
976
- }
977
- })
978
- .bind('disablePager' + namespace, function(e){
979
- e.stopPropagation();
980
- showAllRows(table, p);
981
- })
982
- .bind('enablePager' + namespace, function(e){
983
- e.stopPropagation();
984
- enablePager(table, p, true);
985
- })
986
- .bind('destroyPager' + namespace, function(e){
987
- e.stopPropagation();
988
- destroyPager(table, p);
989
- })
990
- .bind('updateComplete' + namespace, function(e, table, triggered){
991
- e.stopPropagation();
992
- // table can be unintentionally undefined in tablesorter v2.17.7 and earlier
993
- // don't recalculate total rows/pages if using ajax
994
- if ( !table || triggered || p.ajax ) { return; }
995
- var $rows = c.$tbodies.eq(0).children('tr').not(c.selectorRemove);
996
- p.totalRows = $rows.length - ( p.countChildRows ? 0 : $rows.filter('.' + c.cssChildRow).length );
997
- p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
998
- if ($rows.length && c.rowsCopy && c.rowsCopy.length === 0) {
999
- // make a copy of all table rows once the cache has been built
1000
- updateCache(table);
1001
- }
1002
- if ( p.page >= p.totalPages ) {
1003
- moveToLastPage(table, p);
1004
- }
1005
- hideRows(table, p);
1006
- changeHeight(table, p);
1007
- updatePageDisplay(table, p, true);
1008
- })
1009
- .bind('pageSize refreshComplete '.split(' ').join(namespace + ' '), function(e, size){
1010
- e.stopPropagation();
1011
- setPageSize(table, parsePageSize( p, size, 'get' ), p);
1012
- hideRows(table, p);
1013
- updatePageDisplay(table, p, false);
1014
- })
1015
- .bind('pageSet pagerUpdate '.split(' ').join(namespace + ' '), function(e, num){
1016
- e.stopPropagation();
1017
- // force pager refresh
1018
- if (e.type === 'pagerUpdate') {
1019
- num = typeof num === 'undefined' ? p.page + 1 : num;
1020
- p.last.page = true;
1021
- }
1022
- p.page = (parseInt(num, 10) || 1) - 1;
1023
- moveToPage(table, p, true);
1024
- updatePageDisplay(table, p, false);
1025
- })
1026
- .bind('pageAndSize' + namespace, function(e, page, size){
1027
- e.stopPropagation();
1028
- p.page = (parseInt(page, 10) || 1) - 1;
1029
- setPageSize(table, parsePageSize( p, size, 'get' ), p);
1030
- moveToPage(table, p, true);
1031
- hideRows(table, p);
1032
- updatePageDisplay(table, p, false);
1033
- });
1034
-
1035
- // clicked controls
1036
- ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
1037
- fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
1038
- if (c.debug && !pager.length) {
1039
- console.warn('Pager: >> Container not found');
1040
- }
1041
- pager.find(ctrls.join(','))
1042
- .attr('tabindex', 0)
1043
- .unbind('click' + namespace)
1044
- .bind('click' + namespace, function(e){
1045
- e.stopPropagation();
1046
- var i, $t = $(this), l = ctrls.length;
1047
- if ( !$t.hasClass(p.cssDisabled) ) {
1048
- for (i = 0; i < l; i++) {
1049
- if ($t.is(ctrls[i])) {
1050
- fxn[i](table, p);
1051
- break;
1052
- }
1053
- }
1054
- }
1055
- });
1056
-
1057
- // goto selector
1058
- p.$goto = pager.find(p.cssGoto);
1059
- if ( p.$goto.length ) {
1060
- p.$goto
1061
- .unbind('change' + namespace)
1062
- .bind('change' + namespace, function(){
1063
- p.page = $(this).val() - 1;
1064
- moveToPage(table, p, true);
1065
- updatePageDisplay(table, p, false);
1066
- });
1067
- } else if (c.debug) {
1068
- console.warn('Pager: >> Goto selector not found');
1069
- }
1070
- // page size selector
1071
- p.$size = pager.find(p.cssPageSize);
1072
- if ( p.$size.length ) {
1073
- // setting an option as selected appears to cause issues with initial page size
1074
- p.$size.find('option').removeAttr('selected');
1075
- p.$size.unbind('change' + namespace).bind('change' + namespace, function() {
1076
- if ( !$(this).hasClass(p.cssDisabled) ) {
1077
- var size = $(this).val();
1078
- p.$size.val( size ); // in case there are more than one pagers
1079
- setPageSize(table, size, p);
1080
- changeHeight(table, p);
1081
- }
1082
- return false;
1083
- });
1084
- } else if (c.debug) {
1085
- console.warn('Pager: >> Size selector not found');
1086
- }
1087
-
1088
- // clear initialized flag
1089
- p.initialized = false;
1090
- // before initialization event
1091
- $t.triggerHandler('pagerBeforeInitialized', p);
1092
-
1093
- enablePager(table, p, false);
1094
- if ( typeof p.ajaxUrl === 'string' ) {
1095
- // ajax pager; interact with database
1096
- p.ajax = true;
1097
- // When filtering with ajax, allow only custom filtering function, disable default
1098
- // filtering since it will be done server side.
1099
- c.widgetOptions.filter_serversideFiltering = true;
1100
- c.serverSideSorting = true;
1101
- moveToPage(table, p);
1102
- } else {
1103
- p.ajax = false;
1104
- // Regular pager; all rows stored in memory
1105
- ts.appendCache( c, true ); // true = don't apply widgets
1106
- hideRowsSetup(table, p);
1107
- }
1108
-
1109
- // pager initialized
1110
- if (!p.ajax && !p.initialized) {
1111
- p.initializing = false;
1112
- p.initialized = true;
1113
- moveToPage(table, p);
1114
- if (c.debug) {
1115
- console.log('Pager: Triggering pagerInitialized');
1116
- }
1117
- c.$table.triggerHandler( 'pagerInitialized', p );
1118
- if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
1119
- updatePageDisplay(table, p, false);
1120
- }
1121
- }
1122
-
1123
- // make the hasWidget function think that the pager widget is being used
1124
- c.widgetInit.pager = true;
1125
  });
1126
  };
1127
 
@@ -1130,8 +1188,7 @@
1130
 
1131
  // see #486
1132
  ts.showError = function( table, xhr, settings, exception ) {
1133
- var $row,
1134
- $table = $( table ),
1135
  c = $table[0].config,
1136
  wo = c && c.widgetOptions,
1137
  errorRow = c.pager && c.pager.cssErrorRow ||
@@ -1140,8 +1197,8 @@
1140
  typ = typeof xhr,
1141
  valid = true,
1142
  message = '',
1143
- removeRow = function(){
1144
- c.$table.find( 'thead' ).find( '.' + errorRow ).remove();
1145
  };
1146
 
1147
  if ( !$table.length ) {
@@ -1186,7 +1243,7 @@
1186
  }
1187
 
1188
  // allow message to include entire row HTML!
1189
- $row = ( /tr\>/.test(message) ? $(message) : $('<tr><td colspan="' + c.columns + '">' + message + '</td></tr>') )
1190
  .click( function() {
1191
  $( this ).remove();
1192
  })
1
  /*!
2
  * tablesorter (FORK) pager plugin
3
+ * updated 2020-03-03 (v2.31.3)
4
  */
5
  /*jshint browser:true, jquery:true, unused:false */
6
  ;(function($) {
27
  customAjaxUrl: function(table, url) { return url; },
28
 
29
  // ajax error callback from $.tablesorter.showError function
30
+ // ajaxError: function( config, xhr, settings, exception ) { return exception; };
31
  // returning false will abort the error message
32
  ajaxError: null,
33
 
52
  // ],
53
  // [ "header1", "header2", ... "headerN" ] // optional
54
  // ]
55
+ ajaxProcessing: function(data) { return data; },
56
 
57
  // output default: '{page}/{totalPages}'
58
  // possible variables: {size}, {page}, {totalPages}, {filteredPages}, {startRow},
128
 
129
  // hide arrows at extremes
130
  pagerArrows = function( table, p, disable ) {
131
+ var tmp,
132
+ a = 'addClass',
133
+ r = 'removeClass',
134
+ d = p.cssDisabled,
135
+ dis = !!disable,
136
+ first = ( dis || p.page === 0 ),
137
+ tp = getTotalPages( table, p ),
138
+ last = ( dis || (p.page === tp - 1) || tp === 0 );
139
  if ( p.updateArrows ) {
140
+ tmp = p.$container.find(p.cssFirst + ',' + p.cssPrev);
141
+ tmp[ first ? a : r ](d); // toggle disabled class
142
+ tmp.each(function() {
143
+ this.ariaDisabled = first;
144
+ });
145
+ tmp = p.$container.find(p.cssNext + ',' + p.cssLast);
146
+ tmp[ last ? a : r ](d);
147
+ tmp.each(function() {
148
+ this.ariaDisabled = last;
149
+ });
150
  }
151
  },
152
 
173
 
174
  updatePageDisplay = function(table, p, completed) {
175
  if ( p.initializing ) { return; }
176
+ var s, t, $out, $el, indx, len, options, output,
177
  c = table.config,
178
  namespace = c.namespace + 'pager',
179
  sz = parsePageSize( p, p.size, 'get' ); // don't allow dividing by zero
196
  if (typeof p.output === 'function') {
197
  s = p.output(table, p);
198
  } else {
199
+ output = $out
200
+ // get output template from data-pager-output or data-pager-output-filtered
201
+ .attr('data-pager-output' + (p.filteredRows < p.totalRows ? '-filtered' : '')) ||
202
+ p.output;
203
  // form the output string (can now get a new output string from the server)
204
+ s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || output : output )
205
  // {page} = one-based index; {page+#} = zero based index +/- value
206
+ .replace(/\{page([\-+]\d+)?\}/gi, function(m, n) {
207
  return p.totalPages ? p.page + (n ? parseInt(n, 10) : 1) : 0;
208
  })
209
  // {totalPages}, {extra}, {extra:0} (array) or {extra : key} (object)
210
+ .replace(/\{\w+(\s*:\s*\w+)?\}/gi, function(m) {
211
  var len, indx,
212
  str = m.replace(/[{}\s]/g, ''),
213
  extra = str.split(':'),
222
  return extra.length > 1 && data && data[extra[0]] ? data[extra[0]][extra[1]] : p[str] || (data ? data[str] : deflt) || deflt;
223
  });
224
  }
225
+ $el = p.$container.find(p.cssGoto);
226
+ if ( $el.length ) {
227
  t = '';
228
  options = buildPageSelect( table, p );
229
  len = options.length;
231
  t += '<option value="' + options[indx] + '">' + options[indx] + '</option>';
232
  }
233
  // innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228
234
+ $el.html(t).val( p.page + 1 );
235
  }
236
  if ($out.length) {
237
  $out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
238
  // rebind startRow/page inputs
239
+ $out.find('.ts-startRow, .ts-page').unbind('change' + namespace).bind('change' + namespace, function() {
240
  var v = $(this).val(),
241
  pg = $(this).hasClass('ts-startRow') ? Math.floor( v / sz ) + 1 : v;
242
  c.$table.triggerHandler('pageSet' + namespace, [ pg ]);
246
  pagerArrows( table, p );
247
  fixHeight(table, p);
248
  if (p.initialized && completed !== false) {
249
+ if (ts.debug(c, 'pager')) {
250
+ console.log('Pager >> Triggering pagerComplete');
251
  }
252
  c.$table.triggerHandler('pagerComplete', p);
253
  // save pager info to storage
321
  },
322
 
323
  fixHeight = function(table, p) {
324
+ var d, h, bs,
325
  c = table.config,
326
  $b = c.$tbodies.eq(0);
327
  $b.find('tr.pagerSavedHeightSpacer').remove();
328
  if (p.fixedHeight && !p.isDisabled) {
329
  h = $.data(table, 'pagerSavedHeight');
330
  if (h) {
331
+ bs = 0;
332
+ if ($(table).css('border-spacing').split(' ').length > 1) {
333
+ bs = $(table).css('border-spacing').split(' ')[1].replace(/[^-\d\.]/g, '');
334
+ }
335
+ d = h - $b.height() + (bs * p.size) - bs;
336
+ if (
337
+ d > 5 && $.data(table, 'pagerLastSize') === p.size &&
338
+ $b.children('tr:visible').length < (p.size === 'all' ? p.totalRows : p.size)
339
+ ) {
340
  $b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '" style="height:' + d + 'px;"></tr>');
341
  }
342
  }
357
  $.data(table, 'pagerLastSize', p.size);
358
  },
359
 
360
+ hideRows = function(table, p) {
361
  if (!p.ajaxUrl) {
362
  var i,
363
  lastIndex = 0,
367
  sz = p.size === 'all' ? p.totalRows : p.size,
368
  s = ( p.page * sz ),
369
  e = s + sz,
370
+ last = -1, // for cache indexing
371
  j = 0; // size counter
372
  p.cacheIndex = [];
373
+ for ( i = 0; i < l; i++ ) {
374
  if ( !p.regexFiltered.test(rows[i].className) ) {
375
  if (j === s && rows[i].className.match(c.cssChildRow)) {
376
  // hide child rows @ start of pager (if already visible)
398
  }
399
  },
400
 
401
+ hideRowsSetup = function(table, p) {
402
+ p.size = parsePageSize( p, p.$container.find(p.cssPageSize).val(), 'get' );
403
+ setPageSize( table, p.size, p );
 
404
  pagerArrows( table, p );
405
  if ( !p.removeRows ) {
406
  hideRows(table, p);
407
+ $(table).bind('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function() {
408
  hideRows(table, p);
409
  });
410
  }
411
  },
412
 
413
+ renderAjax = function(data, table, p, xhr, settings, exception) {
414
  // process data
415
  if ( typeof p.ajaxProcessing === 'function' ) {
416
 
424
  c = table.config,
425
  $table = c.$table,
426
  tds = '',
427
+ result = p.ajaxProcessing(data, table, xhr) || [ 0, [] ];
 
 
428
  // Clean up any previous error.
429
  ts.showError( table );
430
 
431
  if ( exception ) {
432
+ if (ts.debug(c, 'pager')) {
433
+ console.error('Pager >> Ajax Error', xhr, settings, exception);
434
  }
435
  ts.showError( table, xhr, settings, exception );
436
  c.$tbodies.eq(0).children('tr').detach();
456
  th = result[2]; // headers
457
  }
458
  l = d && d.length;
459
+ if (d instanceof $) {
460
  if (p.processAjaxOnInit) {
461
  // append jQuery object
462
  c.$tbodies.eq(0).empty();
478
  }
479
  }
480
  p.processAjaxOnInit = true;
481
+ // update new header text
482
+ if ( th ) {
483
  hsh = $table.hasClass('hasStickyHeaders');
484
+ $sh = hsh ?
485
+ c.widgetOptions.$sticky.children('thead:first').children('tr:not(.' + c.cssIgnoreRow + ')').children() :
486
+ '';
487
  $f = $table.find('tfoot tr:first').children();
488
  // don't change td headers (may contain pager)
489
  $headers = c.$headers.filter( 'th ' );
493
  // add new test within the first span it finds, or just in the header
494
  if ( $h.find('.' + ts.css.icon).length ) {
495
  icon = $h.find('.' + ts.css.icon).clone(true);
496
+ $h.find('.' + ts.css.headerIn).html( th[j] ).append(icon);
497
  if ( hsh && $sh.length ) {
498
  icon = $sh.eq(j).find('.' + ts.css.icon).clone(true);
499
+ $sh.eq(j).find('.' + ts.css.headerIn).html( th[j] ).append(icon);
500
  }
501
  } else {
502
+ $h.find('.' + ts.css.headerIn).html( th[j] );
503
  if (hsh && $sh.length) {
504
+ // add sticky header to container just in case it contains pager controls
505
+ p.$container = p.$container.add( c.widgetOptions.$sticky );
506
+ $sh.eq(j).find('.' + ts.css.headerIn).html( th[j] );
507
  }
508
  }
509
  $f.eq(j).html( th[j] );
522
  p.last.sortList = (c.sortList || []).join(',');
523
  updatePageDisplay(table, p, false);
524
  // tablesorter core updateCache (not pager)
525
+ ts.updateCache( c, function() {
526
  if (p.initialized) {
527
  // apply widgets after table has rendered & after a delay to prevent
528
  // multiple applyWidget blocking code from blocking this trigger
529
+ setTimeout(function() {
530
+ if (ts.debug(c, 'pager')) {
531
+ console.log('Pager >> Triggering pagerChange');
532
  }
533
  $table.triggerHandler( 'pagerChange', p );
534
  ts.applyWidget( table );
564
  p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
565
  p.ajaxObject.success = function(data, status, jqxhr) {
566
  // Refuse to process old ajax commands that were overwritten by new ones - see #443
567
+ if (counter < p.ajaxCounter) {
568
  return;
569
  }
570
  renderAjax(data, table, p, jqxhr);
573
  p.oldAjaxSuccess(data);
574
  }
575
  };
576
+ if (ts.debug(c, 'pager')) {
577
+ console.log('Pager >> Ajax initialized', p.ajaxObject);
578
  }
579
  $.ajax(p.ajaxObject);
580
  }
585
  c = table.config,
586
  url = (p.ajaxUrl) ? p.ajaxUrl
587
  // allow using "{page+1}" in the url string to switch to a non-zero based index
588
+ .replace(/\{page([\-+]\d+)?\}/, function(s, n) { return p.page + (n ? parseInt(n, 10) : 0); })
589
  // this will pass "all" to server when size is set to "all"
590
  .replace(/\{size\}/g, p.size) : '',
591
  sortList = c.sortList,
618
  if ( typeof p.customAjaxUrl === 'function' ) {
619
  url = p.customAjaxUrl(table, url);
620
  }
621
+ if (ts.debug(c, 'pager')) {
622
+ console.log('Pager >> Ajax url = ' + url);
623
  }
624
  return url;
625
  },
628
  var $tb, index, count, added,
629
  $t = $(table),
630
  c = table.config,
631
+ debug = ts.debug(c, 'pager'),
632
  f = c.$table.hasClass('hasFilters'),
633
  l = rows && rows.length || 0, // rows may be undefined
634
  e = p.size === 'all' ? p.totalRows : p.size,
635
  s = ( p.page * e );
636
  if ( l < 1 ) {
637
+ if (debug) {
638
+ console.warn('Pager >> No rows for pager to render');
639
  }
640
  // empty table, abort!
641
  return;
647
  p.cacheIndex = [];
648
  p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
649
  if (p.initialized) {
650
+ if (debug) {
651
+ console.log('Pager >> Triggering pagerChange');
652
  }
653
  $t.triggerHandler( 'pagerChange', p );
654
  }
663
  count = f ? 0 : s;
664
  added = 0;
665
  while (added < e && index < rows.length) {
666
+ if (!f || !p.regexFiltered.test(rows[index][0].className)) {
667
  count++;
668
  if (count > s && added <= e) {
669
  added++;
677
  }
678
  updatePageDisplay(table, p);
679
  if (table.isUpdating) {
680
+ if (debug) {
681
+ console.log('Pager >> Triggering updateComplete');
682
  }
683
  $t.triggerHandler('updateComplete', [ table, true ]);
684
  }
692
  $.data(table, 'pagerLastPage', p.page);
693
  $.data(table, 'pagerLastSize', p.size);
694
  p.page = 0;
695
+ p.size = p.totalRows;
696
  p.totalPages = 1;
697
  $(table)
698
+ .addClass('pagerDisabled')
699
+ .removeAttr('aria-describedby')
700
+ .find('tr.pagerSavedHeightSpacer').remove();
701
  renderTable(table, table.config.rowsCopy, p);
702
  p.isDisabled = true;
703
  ts.applyWidget( table );
704
+ if (ts.debug(table.config, 'pager')) {
705
+ console.log('Pager >> Disabled');
706
  }
707
  }
708
  // disable size selector
709
+ $controls = p.$container.find( p.cssGoto + ',' + p.cssPageSize + ', .ts-startRow, .ts-page' );
 
 
710
  len = $controls.length;
711
  for ( index = 0; index < len; index++ ) {
712
+ $controls.eq( index ).addClass( p.cssDisabled )[0].disabled = true;
713
+ $controls[ index ].ariaDisabled = true;
 
714
  }
715
  },
716
 
719
  var c = table.config,
720
  p = c.pager;
721
  // tablesorter core updateCache (not pager)
722
+ ts.updateCache( c, function() {
723
  var i,
724
  rows = [],
725
  n = table.config.cache[0].normalized;
735
  moveToPage = function(table, p, pageMoved) {
736
  if ( p.isDisabled ) { return; }
737
  var tmp,
738
+ c = table.config,
739
+ debug = ts.debug(c, 'pager'),
740
+ $t = $(table),
741
+ l = p.last;
742
  if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) {
743
  return updateCache(table);
744
  }
758
  // & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
759
  (l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
760
  l.sortList === (c.sortList || []).join(',') ) { return; }
761
+ if (debug) {
762
+ console.log('Pager >> Changing to page ' + p.page);
763
  }
764
  p.last = {
765
  page : p.page,
776
  p.processAjaxOnInit = true;
777
  tmp = p.initialRows;
778
  p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
779
+ ( debug ? console.error('Pager >> No initial total page set!') || 0 : 0 );
780
  p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered :
781
+ ( debug ? console.error('Pager >> No initial filtered page set!') || 0 : 0 );
782
  pagerInitialized( table, p );
783
  } else {
784
  getAjax(table, p);
788
  }
789
  $.data(table, 'pagerLastPage', p.page);
790
  if (p.initialized && pageMoved !== false) {
791
+ if (debug) {
792
+ console.log('Pager >> Triggering pageMoved');
793
  }
794
  $t.triggerHandler('pageMoved', p);
795
  ts.applyWidget( table );
796
  if (table.isUpdating) {
797
+ if (debug) {
798
+ console.log('Pager >> Triggering updateComplete');
799
  }
800
  $t.triggerHandler('updateComplete', [ table, true ]);
801
  }
803
  },
804
 
805
  getTotalPages = function( table, p ) {
806
+ return ts.hasWidget( table, 'filter' ) ?
807
+ Math.min( p.totalPages, p.filteredPages ) :
808
+ p.totalPages;
 
 
 
 
 
 
809
  },
810
 
811
  parsePageNumber = function( table, p ) {
816
  return p.page;
817
  },
818
 
819
+ // set to either set or get value
820
+ parsePageSize = function( p, size, mode ) {
821
+ var s = parseInt( size, 10 ) || p.size || p.settings.size || 10;
822
+ if (p.initialized && (/all/i.test( s + ' ' + size ) || s === p.totalRows)) {
823
+ // Fixing #1364 & #1366
824
+ return p.$container.find(p.cssPageSize + ' option[value="all"]').length ?
825
+ 'all' : p.totalRows;
826
+ }
827
+ // "get" to get `p.size` or "set" to set `pageSize.val()`
828
+ return mode === 'get' ? s : p.size;
829
+ },
830
+
831
  setPageSize = function(table, size, p) {
832
+ // "all" size is only returned if an "all" option exists - fixes #1366
833
  p.size = parsePageSize( p, size, 'get' );
834
+ p.$container.find( p.cssPageSize ).val( p.size );
835
  $.data(table, 'pagerLastPage', parsePageNumber( table, p ) );
836
  $.data(table, 'pagerLastSize', p.size);
837
  p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
838
  p.filteredPages = p.size === 'all' ? 1 : Math.ceil( p.filteredRows / p.size );
 
839
  },
840
 
841
  moveToFirstPage = function(table, p) {
868
  pagerInitialized = function(table, p) {
869
  p.initialized = true;
870
  p.initializing = false;
871
+ if (ts.debug(table.config, 'pager')) {
872
+ console.log('Pager >> Triggering pagerInitialized');
873
  }
874
  $(table).triggerHandler( 'pagerInitialized', p );
875
  ts.applyWidget( table );
876
  updatePageDisplay(table, p);
877
  },
878
 
879
+ resetState = function(table, p) {
880
+ var c = table.config;
881
+ c.pager = $.extend( true, {}, $.tablesorterPager.defaults, p.settings );
882
+ init(table, p.settings);
883
+ },
884
+
885
  destroyPager = function(table, p) {
886
  var c = table.config,
887
  namespace = c.namespace + 'pager',
905
  enablePager = function(table, p, triggered) {
906
  var info, size, $el,
907
  c = table.config;
908
+ p.$container.find(p.cssGoto + ',' + p.cssPageSize + ',.ts-startRow, .ts-page')
909
  .removeClass(p.cssDisabled)
910
  .removeAttr('disabled')
911
+ .each(function() {
912
+ this.ariaDisabled = false;
913
+ });
914
  p.isDisabled = false;
915
  p.page = $.data(table, 'pagerLastPage') || p.page || 0;
916
+ $el = p.$container.find(p.cssPageSize);
917
+ size = $el.find('option[selected]').val();
918
  p.size = $.data(table, 'pagerLastSize') || parsePageSize( p, size, 'get' );
 
919
  p.totalPages = p.size === 'all' ? 1 : Math.ceil( getTotalPages( table, p ) / p.size );
920
+ setPageSize(table, p.size, p); // set page size
921
  // if table id exists, include page display with aria info
922
  if ( table.id && !c.$table.attr( 'aria-describedby' ) ) {
923
  $el = p.$container.find( p.cssPageDisplay );
934
  // tablesorter core update table
935
  ts.update( c );
936
  setPageSize(table, p.size, p);
937
+ moveToPage(table, p);
938
+ hideRowsSetup(table, p);
939
+ if (ts.debug(c, 'pager')) {
940
+ console.log('Pager >> Enabled');
941
+ }
942
+ }
943
+ },
944
+
945
+ init = function(table, settings) {
946
+ var t, ctrls, fxn, $el,
947
+ c = table.config,
948
+ wo = c.widgetOptions,
949
+ debug = ts.debug(c, 'pager'),
950
+ p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ),
951
+ $t = c.$table,
952
+ namespace = c.namespace + 'pager',
953
+ // added in case the pager is reinitialized after being destroyed.
954
+ pager = p.$container = $(p.container).addClass('tablesorter-pager').show();
955
+ // save a copy of the original settings
956
+ p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
957
+ if (debug) {
958
+ console.log('Pager >> Initializing');
959
+ }
960
+ p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
961
+ c.appender = $this.appender;
962
+ p.initializing = true;
963
+ if (p.savePages && ts.storage) {
964
+ t = ts.storage(table, p.storageKey) || {}; // fixes #387
965
+ p.page = isNaN(t.page) ? p.page : t.page;
966
+ p.size = t.size === 'all' ? t.size : ( isNaN( t.size ) ? p.size : t.size ) || p.setSize || 10;
967
+ setPageSize(table, p.size, p);
968
+ }
969
+ // skipped rows
970
+ p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
971
+ p.regexFiltered = new RegExp(wo.filter_filteredRow || 'filtered');
972
+
973
+ $t
974
+ // .unbind( namespace ) adding in jQuery 1.4.3 ( I think )
975
+ .unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
976
+ .bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
977
+ p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
978
+ var filtersEqual;
979
+ if (p.ajax && e.type === 'filterInit') {
980
+ // ensure pager ajax is called after filter widget has initialized
981
+ return moveToPage( table, p, false );
982
+ }
983
+ if (ts.filter.equalFilters) {
984
+ filtersEqual = ts.filter.equalFilters(c, c.lastSearch, p.currentFilters);
985
+ } else {
986
+ // will miss filter changes of the same value in a different column, see #1363
987
+ filtersEqual = (c.lastSearch || []).join('') !== (p.currentFilters || []).join('');
988
+ }
989
+ // don't change page if filters are the same (pager updating, etc)
990
+ if (e.type === 'filterStart' && p.pageReset !== false && !filtersEqual) {
991
+ p.page = p.pageReset; // fixes #456 & #565
992
+ }
993
+ })
994
+ // update pager after filter widget completes
995
+ .bind('filterEnd sortEnd '.split(' ').join(namespace + ' '), function() {
996
+ p.currentFilters = c.$table.data('lastSearch');
997
+ if (p.initialized || p.initializing) {
998
+ if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
999
+ // make sure we have a copy of all table rows once the cache has been built
1000
+ updateCache(table);
1001
+ }
1002
+ updatePageDisplay(table, p, false);
1003
+ moveToPage(table, p, false);
1004
+ ts.applyWidget( table );
1005
+ }
1006
+ })
1007
+ .bind('disablePager' + namespace, function(e) {
1008
+ e.stopPropagation();
1009
+ showAllRows(table, p);
1010
+ })
1011
+ .bind('enablePager' + namespace, function(e) {
1012
+ e.stopPropagation();
1013
+ enablePager(table, p, true);
1014
+ })
1015
+ .bind('destroyPager' + namespace, function(e) {
1016
+ e.stopPropagation();
1017
+ destroyPager(table, p);
1018
+ })
1019
+ .bind('resetToLoadState' + namespace, function(e) {
1020
+ e.stopPropagation();
1021
+ resetState(table, p);
1022
+ })
1023
+ .bind('updateComplete' + namespace, function(e, table, triggered) {
1024
+ e.stopPropagation();
1025
+ // table can be unintentionally undefined in tablesorter v2.17.7 and earlier
1026
+ // don't recalculate total rows/pages if using ajax
1027
+ if ( !table || triggered || p.ajax ) { return; }
1028
+ var $rows = c.$tbodies.eq(0).children('tr').not(c.selectorRemove);
1029
+ p.totalRows = $rows.length - ( p.countChildRows ? 0 : $rows.filter('.' + c.cssChildRow).length );
1030
+ p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size );
1031
+ if ($rows.length && c.rowsCopy && c.rowsCopy.length === 0) {
1032
+ // make a copy of all table rows once the cache has been built
1033
+ updateCache(table);
1034
+ }
1035
+ if ( p.page >= p.totalPages ) {
1036
+ moveToLastPage(table, p);
1037
+ }
1038
+ hideRows(table, p);
1039
+ changeHeight(table, p);
1040
+ updatePageDisplay(table, p, true);
1041
+ })
1042
+ .bind('pageSize refreshComplete '.split(' ').join(namespace + ' '), function(e, size) {
1043
+ e.stopPropagation();
1044
+ setPageSize(table, parsePageSize( p, size, 'get' ), p);
1045
+ moveToPage(table, p);
1046
+ hideRows(table, p);
1047
+ updatePageDisplay(table, p, false);
1048
+ })
1049
+ .bind('pageSet pagerUpdate '.split(' ').join(namespace + ' '), function(e, num) {
1050
+ e.stopPropagation();
1051
+ // force pager refresh
1052
+ if (e.type === 'pagerUpdate') {
1053
+ num = typeof num === 'undefined' ? p.page + 1 : num;
1054
+ p.last.page = true;
1055
+ }
1056
+ p.page = (parseInt(num, 10) || 1) - 1;
1057
+ moveToPage(table, p, true);
1058
+ updatePageDisplay(table, p, false);
1059
+ })
1060
+ .bind('pageAndSize' + namespace, function(e, page, size) {
1061
+ e.stopPropagation();
1062
+ p.page = (parseInt(page, 10) || 1) - 1;
1063
+ setPageSize(table, parsePageSize( p, size, 'get' ), p);
1064
+ moveToPage(table, p, true);
1065
+ hideRows(table, p);
1066
+ updatePageDisplay(table, p, false);
1067
+ });
1068
+
1069
+ // clicked controls
1070
+ ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
1071
+ fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
1072
+ if (debug && !pager.length) {
1073
+ console.warn('Pager >> "container" not found');
1074
+ }
1075
+ pager.find(ctrls.join(','))
1076
+ .attr('tabindex', 0)
1077
+ .unbind('click' + namespace)
1078
+ .bind('click' + namespace, function(e) {
1079
+ e.stopPropagation();
1080
+ var i, $t = $(this), l = ctrls.length;
1081
+ if ( !$t.hasClass(p.cssDisabled) ) {
1082
+ for (i = 0; i < l; i++) {
1083
+ if ($t.is(ctrls[i])) {
1084
+ fxn[i](table, p);
1085
+ break;
1086
+ }
1087
+ }
1088
+ }
1089
+ });
1090
+
1091
+ // goto selector
1092
+ $el = pager.find(p.cssGoto);
1093
+ if ( $el.length ) {
1094
+ $el
1095
+ .unbind('change' + namespace)
1096
+ .bind('change' + namespace, function() {
1097
+ p.page = $(this).val() - 1;
1098
+ moveToPage(table, p, true);
1099
+ updatePageDisplay(table, p, false);
1100
+ });
1101
+ } else if (debug) {
1102
+ console.warn('Pager >> "goto" selector not found');
1103
+ }
1104
+ // page size selector
1105
+ $el = pager.find(p.cssPageSize);
1106
+ if ( $el.length ) {
1107
+ // setting an option as selected appears to cause issues with initial page size
1108
+ $el.find('option').removeAttr('selected');
1109
+ $el.unbind('change' + namespace).bind('change' + namespace, function() {
1110
+ if ( !$(this).hasClass(p.cssDisabled) ) {
1111
+ var size = $(this).val();
1112
+ // in case there are more than one pager
1113
+ setPageSize(table, size, p);
1114
+ moveToPage(table, p);
1115
+ changeHeight(table, p);
1116
+ }
1117
+ return false;
1118
+ });
1119
+ } else if (debug) {
1120
+ console.warn('Pager >> "size" selector not found');
1121
+ }
1122
+
1123
+ // clear initialized flag
1124
+ p.initialized = false;
1125
+ // before initialization event
1126
+ $t.triggerHandler('pagerBeforeInitialized', p);
1127
+
1128
+ enablePager(table, p, false);
1129
+ if ( typeof p.ajaxUrl === 'string' ) {
1130
+ // ajax pager; interact with database
1131
+ p.ajax = true;
1132
+ // When filtering with ajax, allow only custom filtering function, disable default
1133
+ // filtering since it will be done server side.
1134
+ c.widgetOptions.filter_serversideFiltering = true;
1135
+ c.serverSideSorting = true;
1136
+ moveToPage(table, p);
1137
+ } else {
1138
+ p.ajax = false;
1139
+ // Regular pager; all rows stored in memory
1140
+ ts.appendCache( c, true ); // true = don't apply widgets
1141
  hideRowsSetup(table, p);
1142
+ }
1143
+
1144
+ // pager initialized
1145
+ if (!p.ajax && !p.initialized) {
1146
+ p.initializing = false;
1147
+ p.initialized = true;
1148
+ // update page size on init
1149
+ setPageSize(table, p.size, p);
1150
+ moveToPage(table, p);
1151
+ if (debug) {
1152
+ console.log('Pager >> Triggering pagerInitialized');
1153
+ }
1154
+ c.$table.triggerHandler( 'pagerInitialized', p );
1155
+ if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
1156
+ updatePageDisplay(table, p, false);
1157
  }
1158
  }
1159
+
1160
+ // make the hasWidget function think that the pager widget is being used
1161
+ c.widgetInit.pager = true;
1162
  };
1163
 
1164
  $this.appender = function(table, rows) {
1179
  return this.each(function() {
1180
  // check if tablesorter has initialized
1181
  if (!(this.config && this.hasInitialized)) { return; }
1182
+ init(this, settings);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1183
  });
1184
  };
1185
 
1188
 
1189
  // see #486
1190
  ts.showError = function( table, xhr, settings, exception ) {
1191
+ var $table = $( table ),
 
1192
  c = $table[0].config,
1193
  wo = c && c.widgetOptions,
1194
  errorRow = c.pager && c.pager.cssErrorRow ||
1197
  typ = typeof xhr,
1198
  valid = true,
1199
  message = '',
1200
+ removeRow = function() {
1201
+ c.$table.find( 'thead' ).find( c.selectorRemove ).remove();
1202
  };
1203
 
1204
  if ( !$table.length ) {
1243
  }
1244
 
1245
  // allow message to include entire row HTML!
1246
+ $( /tr\>/.test(message) ? message : '<tr><td colspan="' + c.columns + '">' + message + '</td></tr>' )
1247
  .click( function() {
1248
  $( this ).remove();
1249
  })
js/jquery.tablesorter.widgets.js ADDED
@@ -0,0 +1,3184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*** This file is dynamically generated ***
2
+ █████▄ ▄████▄ █████▄ ▄████▄ ██████ ███████▄ ▄████▄ █████▄ ██ ██████ ██ ██
3
+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▄▄ ██▄▄██
4
+ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀██
5
+ █████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
6
+ */
7
+ /*! tablesorter (FORK) - updated 2020-03-03 (v2.31.3)*/
8
+ /* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
9
+ (function(factory){if (typeof define === 'function' && define.amd){define(['jquery'], factory);} else if (typeof module === 'object' && typeof module.exports === 'object'){module.exports = factory(require('jquery'));} else {factory(jQuery);}}(function(jQuery) {
10
+ /*! Widget: storage - updated 2018-03-18 (v2.30.0) */
11
+ /*global JSON:false */
12
+ ;(function ($, window, document) {
13
+ 'use strict';
14
+
15
+ var ts = $.tablesorter || {};
16
+
17
+ // update defaults for validator; these values must be falsy!
18
+ $.extend(true, ts.defaults, {
19
+ fixedUrl: '',
20
+ widgetOptions: {
21
+ storage_fixedUrl: '',
22
+ storage_group: '',
23
+ storage_page: '',
24
+ storage_storageType: '',
25
+ storage_tableId: '',
26
+ storage_useSessionStorage: ''
27
+ }
28
+ });
29
+
30
+ // *** Store data in local storage, with a cookie fallback ***
31
+ /* IE7 needs JSON library for JSON.stringify - (http://caniuse.com/#search=json)
32
+ if you need it, then include https://github.com/douglascrockford/JSON-js
33
+
34
+ $.parseJSON is not available is jQuery versions older than 1.4.1, using older
35
+ versions will only allow storing information for one page at a time
36
+
37
+ // *** Save data (JSON format only) ***
38
+ // val must be valid JSON... use http://jsonlint.com/ to ensure it is valid
39
+ var val = { "mywidget" : "data1" }; // valid JSON uses double quotes
40
+ // $.tablesorter.storage(table, key, val);
41
+ $.tablesorter.storage(table, 'tablesorter-mywidget', val);
42
+
43
+ // *** Get data: $.tablesorter.storage(table, key); ***
44
+ v = $.tablesorter.storage(table, 'tablesorter-mywidget');
45
+ // val may be empty, so also check for your data
46
+ val = (v && v.hasOwnProperty('mywidget')) ? v.mywidget : '';
47
+ alert(val); // 'data1' if saved, or '' if not
48
+ */
49
+ ts.storage = function(table, key, value, options) {
50
+ table = $(table)[0];
51
+ var cookieIndex, cookies, date,
52
+ hasStorage = false,
53
+ values = {},
54
+ c = table.config,
55
+ wo = c && c.widgetOptions,
56
+ debug = ts.debug(c, 'storage'),
57
+ storageType = (
58
+ ( options && options.storageType ) || ( wo && wo.storage_storageType )
59
+ ).toString().charAt(0).toLowerCase(),
60
+ // deprecating "useSessionStorage"; any storageType setting overrides it
61
+ session = storageType ? '' :
62
+ ( options && options.useSessionStorage ) || ( wo && wo.storage_useSessionStorage ),
63
+ $table = $(table),
64
+ // id from (1) options ID, (2) table 'data-table-group' attribute, (3) widgetOptions.storage_tableId,
65
+ // (4) table ID, then (5) table index
66
+ id = options && options.id ||
67
+ $table.attr( options && options.group || wo && wo.storage_group || 'data-table-group') ||
68
+ wo && wo.storage_tableId || table.id || $('.tablesorter').index( $table ),
69
+ // url from (1) options url, (2) table 'data-table-page' attribute, (3) widgetOptions.storage_fixedUrl,
70
+ // (4) table.config.fixedUrl (deprecated), then (5) window location path
71
+ url = options && options.url ||
72
+ $table.attr(options && options.page || wo && wo.storage_page || 'data-table-page') ||
73
+ wo && wo.storage_fixedUrl || c && c.fixedUrl || window.location.pathname;
74
+
75
+ // skip if using cookies
76
+ if (storageType !== 'c') {
77
+ storageType = (storageType === 's' || session) ? 'sessionStorage' : 'localStorage';
78
+ // https://gist.github.com/paulirish/5558557
79
+ if (storageType in window) {
80
+ try {
81
+ window[storageType].setItem('_tmptest', 'temp');
82
+ hasStorage = true;
83
+ window[storageType].removeItem('_tmptest');
84
+ } catch (error) {
85
+ console.warn( storageType + ' is not supported in this browser' );
86
+ }
87
+ }
88
+ }
89
+ if (debug) {
90
+ console.log('Storage >> Using', hasStorage ? storageType : 'cookies');
91
+ }
92
+ // *** get value ***
93
+ if ($.parseJSON) {
94
+ if (hasStorage) {
95
+ values = $.parseJSON( window[storageType][key] || 'null' ) || {};
96
+ } else {
97
+ // old browser, using cookies
98
+ cookies = document.cookie.split(/[;\s|=]/);
99
+ // add one to get from the key to the value
100
+ cookieIndex = $.inArray(key, cookies) + 1;
101
+ values = (cookieIndex !== 0) ? $.parseJSON(cookies[cookieIndex] || 'null') || {} : {};
102
+ }
103
+ }
104
+ // allow value to be an empty string too
105
+ if (typeof value !== 'undefined' && window.JSON && JSON.hasOwnProperty('stringify')) {
106
+ // add unique identifiers = url pathname > table ID/index on page > data
107
+ if (!values[url]) {
108
+ values[url] = {};
109
+ }
110
+ values[url][id] = value;
111
+ // *** set value ***
112
+ if (hasStorage) {
113
+ window[storageType][key] = JSON.stringify(values);
114
+ } else {
115
+ date = new Date();
116
+ date.setTime(date.getTime() + (31536e+6)); // 365 days
117
+ document.cookie = key + '=' + (JSON.stringify(values)).replace(/\"/g, '\"') + '; expires=' + date.toGMTString() + '; path=/';
118
+ }
119
+ } else {
120
+ return values && values[url] ? values[url][id] : '';
121
+ }
122
+ };
123
+
124
+ })(jQuery, window, document);
125
+
126
+ /*! Widget: uitheme - updated 2018-03-18 (v2.30.0) */
127
+ ;(function ($) {
128
+ 'use strict';
129
+ var ts = $.tablesorter || {};
130
+
131
+ ts.themes = {
132
+ 'bootstrap' : {
133
+ table : 'table table-bordered table-striped',
134
+ caption : 'caption',
135
+ // header class names
136
+ header : 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css)
137
+ sortNone : '',
138
+ sortAsc : '',
139
+ sortDesc : '',
140
+ active : '', // applied when column is sorted
141
+ hover : '', // custom css required - a defined bootstrap style may not override other classes
142
+ // icon class names
143
+ icons : '', // add 'bootstrap-icon-white' to make them white; this icon class is added to the <i> in the header
144
+ iconSortNone : 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted
145
+ iconSortAsc : 'glyphicon glyphicon-chevron-up', // class name added to icon when column has ascending sort
146
+ iconSortDesc : 'glyphicon glyphicon-chevron-down', // class name added to icon when column has descending sort
147
+ filterRow : '', // filter row class
148
+ footerRow : '',
149
+ footerCells : '',
150
+ even : '', // even row zebra striping
151
+ odd : '' // odd row zebra striping
152
+ },
153
+ 'jui' : {
154
+ table : 'ui-widget ui-widget-content ui-corner-all', // table classes
155
+ caption : 'ui-widget-content',
156
+ // header class names
157
+ header : 'ui-widget-header ui-corner-all ui-state-default', // header classes
158
+ sortNone : '',
159
+ sortAsc : '',
160
+ sortDesc : '',
161
+ active : 'ui-state-active', // applied when column is sorted
162
+ hover : 'ui-state-hover', // hover class
163
+ // icon class names
164
+ icons : 'ui-icon', // icon class added to the <i> in the header
165
+ iconSortNone : 'ui-icon-carat-2-n-s ui-icon-caret-2-n-s', // class name added to icon when column is not sorted
166
+ iconSortAsc : 'ui-icon-carat-1-n ui-icon-caret-1-n', // class name added to icon when column has ascending sort
167
+ iconSortDesc : 'ui-icon-carat-1-s ui-icon-caret-1-s', // class name added to icon when column has descending sort
168
+ filterRow : '',
169
+ footerRow : '',
170
+ footerCells : '',
171
+ even : 'ui-widget-content', // even row zebra striping
172
+ odd : 'ui-state-default' // odd row zebra striping
173
+ }
174
+ };
175
+
176
+ $.extend(ts.css, {
177
+ wrapper : 'tablesorter-wrapper' // ui theme & resizable
178
+ });
179
+
180
+ ts.addWidget({
181
+ id: 'uitheme',
182
+ priority: 10,
183
+ format: function(table, c, wo) {
184
+ var i, tmp, hdr, icon, time, $header, $icon, $tfoot, $h, oldtheme, oldremove, oldIconRmv, hasOldTheme,
185
+ themesAll = ts.themes,
186
+ $table = c.$table.add( $( c.namespace + '_extra_table' ) ),
187
+ $headers = c.$headers.add( $( c.namespace + '_extra_headers' ) ),
188
+ theme = c.theme || 'jui',
189
+ themes = themesAll[theme] || {},
190
+ remove = $.trim( [ themes.sortNone, themes.sortDesc, themes.sortAsc, themes.active ].join( ' ' ) ),
191
+ iconRmv = $.trim( [ themes.iconSortNone, themes.iconSortDesc, themes.iconSortAsc ].join( ' ' ) ),
192
+ debug = ts.debug(c, 'uitheme');
193
+ if (debug) { time = new Date(); }
194
+ // initialization code - run once
195
+ if (!$table.hasClass('tablesorter-' + theme) || c.theme !== c.appliedTheme || !wo.uitheme_applied) {
196
+ wo.uitheme_applied = true;
197
+ oldtheme = themesAll[c.appliedTheme] || {};
198
+ hasOldTheme = !$.isEmptyObject(oldtheme);
199
+ oldremove = hasOldTheme ? [ oldtheme.sortNone, oldtheme.sortDesc, oldtheme.sortAsc, oldtheme.active ].join( ' ' ) : '';
200
+ oldIconRmv = hasOldTheme ? [ oldtheme.iconSortNone, oldtheme.iconSortDesc, oldtheme.iconSortAsc ].join( ' ' ) : '';
201
+ if (hasOldTheme) {
202
+ wo.zebra[0] = $.trim( ' ' + wo.zebra[0].replace(' ' + oldtheme.even, '') );
203
+ wo.zebra[1] = $.trim( ' ' + wo.zebra[1].replace(' ' + oldtheme.odd, '') );
204
+ c.$tbodies.children().removeClass( [ oldtheme.even, oldtheme.odd ].join(' ') );
205
+ }
206
+ // update zebra stripes
207
+ if (themes.even) { wo.zebra[0] += ' ' + themes.even; }
208
+ if (themes.odd) { wo.zebra[1] += ' ' + themes.odd; }
209
+ // add caption style
210
+ $table.children('caption')
211
+ .removeClass(oldtheme.caption || '')
212
+ .addClass(themes.caption);
213
+ // add table/footer class names
214
+ $tfoot = $table
215
+ // remove other selected themes
216
+ .removeClass( (c.appliedTheme ? 'tablesorter-' + (c.appliedTheme || '') : '') + ' ' + (oldtheme.table || '') )
217
+ .addClass('tablesorter-' + theme + ' ' + (themes.table || '')) // add theme widget class name
218
+ .children('tfoot');
219
+ c.appliedTheme = c.theme;
220
+
221
+ if ($tfoot.length) {
222
+ $tfoot
223
+ // if oldtheme.footerRow or oldtheme.footerCells are undefined, all class names are removed
224
+ .children('tr').removeClass(oldtheme.footerRow || '').addClass(themes.footerRow)
225
+ .children('th, td').removeClass(oldtheme.footerCells || '').addClass(themes.footerCells);
226
+ }
227
+ // update header classes
228
+ $headers
229
+ .removeClass( (hasOldTheme ? [ oldtheme.header, oldtheme.hover, oldremove ].join(' ') : '') || '' )
230
+ .addClass(themes.header)
231
+ .not('.sorter-false')
232
+ .unbind('mouseenter.tsuitheme mouseleave.tsuitheme')
233
+ .bind('mouseenter.tsuitheme mouseleave.tsuitheme', function(event) {
234
+ // toggleClass with switch added in jQuery 1.3
235
+ $(this)[ event.type === 'mouseenter' ? 'addClass' : 'removeClass' ](themes.hover || '');
236
+ });
237
+
238
+ $headers.each(function() {
239
+ var $this = $(this);
240
+ if (!$this.find('.' + ts.css.wrapper).length) {
241
+ // Firefox needs this inner div to position the icon & resizer correctly
242
+ $this.wrapInner('<div class="' + ts.css.wrapper + '" style="position:relative;height:100%;width:100%"></div>');
243
+ }
244
+ });
245
+ if (c.cssIcon) {
246
+ // if c.cssIcon is '', then no <i> is added to the header
247
+ $headers
248
+ .find('.' + ts.css.icon)
249
+ .removeClass(hasOldTheme ? [ oldtheme.icons, oldIconRmv ].join(' ') : '')
250
+ .addClass(themes.icons || '');
251
+ }
252
+ // filter widget initializes after uitheme
253
+ if (ts.hasWidget( c.table, 'filter' )) {
254
+ tmp = function() {
255
+ $table.children('thead').children('.' + ts.css.filterRow)
256
+ .removeClass(hasOldTheme ? oldtheme.filterRow || '' : '')
257
+ .addClass(themes.filterRow || '');
258
+ };
259
+ if (wo.filter_initialized) {
260
+ tmp();
261
+ } else {
262
+ $table.one('filterInit', function() {
263
+ tmp();
264
+ });
265
+ }
266
+ }
267
+ }
268
+ for (i = 0; i < c.columns; i++) {
269
+ $header = c.$headers
270
+ .add($(c.namespace + '_extra_headers'))
271
+ .not('.sorter-false')
272
+ .filter('[data-column="' + i + '"]');
273
+ $icon = (ts.css.icon) ? $header.find('.' + ts.css.icon) : $();
274
+ $h = $headers.not('.sorter-false').filter('[data-column="' + i + '"]:last');
275
+ if ($h.length) {
276
+ $header.removeClass(remove);
277
+ $icon.removeClass(iconRmv);
278
+ if ($h[0].sortDisabled) {
279
+ // no sort arrows for disabled columns!
280
+ $icon.removeClass(themes.icons || '');
281
+ } else {
282
+ hdr = themes.sortNone;
283
+ icon = themes.iconSortNone;
284
+ if ($h.hasClass(ts.css.sortAsc)) {
285
+ hdr = [ themes.sortAsc, themes.active ].join(' ');
286
+ icon = themes.iconSortAsc;
287
+ } else if ($h.hasClass(ts.css.sortDesc)) {
288
+ hdr = [ themes.sortDesc, themes.active ].join(' ');
289
+ icon = themes.iconSortDesc;
290
+ }
291
+ $header.addClass(hdr);
292
+ $icon.addClass(icon || '');
293
+ }
294
+ }
295
+ }
296
+ if (debug) {
297
+ console.log('uitheme >> Applied ' + theme + ' theme' + ts.benchmark(time));
298
+ }
299
+ },
300
+ remove: function(table, c, wo, refreshing) {
301
+ if (!wo.uitheme_applied) { return; }
302
+ var $table = c.$table,
303
+ theme = c.appliedTheme || 'jui',
304
+ themes = ts.themes[ theme ] || ts.themes.jui,
305
+ $headers = $table.children('thead').children(),
306
+ remove = themes.sortNone + ' ' + themes.sortDesc + ' ' + themes.sortAsc,
307
+ iconRmv = themes.iconSortNone + ' ' + themes.iconSortDesc + ' ' + themes.iconSortAsc;
308
+ $table.removeClass('tablesorter-' + theme + ' ' + themes.table);
309
+ wo.uitheme_applied = false;
310
+ if (refreshing) { return; }
311
+ $table.find(ts.css.header).removeClass(themes.header);
312
+ $headers
313
+ .unbind('mouseenter.tsuitheme mouseleave.tsuitheme') // remove hover
314
+ .removeClass(themes.hover + ' ' + remove + ' ' + themes.active)
315
+ .filter('.' + ts.css.filterRow)
316
+ .removeClass(themes.filterRow);
317
+ $headers.find('.' + ts.css.icon).removeClass(themes.icons + ' ' + iconRmv);
318
+ }
319
+ });
320
+
321
+ })(jQuery);
322
+
323
+ /*! Widget: columns - updated 5/24/2017 (v2.28.11) */
324
+ ;(function ($) {
325
+ 'use strict';
326
+ var ts = $.tablesorter || {};
327
+
328
+ ts.addWidget({
329
+ id: 'columns',
330
+ priority: 65,
331
+ options : {
332
+ columns : [ 'primary', 'secondary', 'tertiary' ]
333
+ },
334
+ format: function(table, c, wo) {
335
+ var $tbody, tbodyIndex, $rows, rows, $row, $cells, remove, indx,
336
+ $table = c.$table,
337
+ $tbodies = c.$tbodies,
338
+ sortList = c.sortList,
339
+ len = sortList.length,
340
+ // removed c.widgetColumns support
341
+ css = wo && wo.columns || [ 'primary', 'secondary', 'tertiary' ],
342
+ last = css.length - 1;
343
+ remove = css.join(' ');
344
+ // check if there is a sort (on initialization there may not be one)
345
+ for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
346
+ $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // detach tbody
347
+ $rows = $tbody.children('tr');
348
+ // loop through the visible rows
349
+ $rows.each(function() {
350
+ $row = $(this);
351
+ if (this.style.display !== 'none') {
352
+ // remove all columns class names
353
+ $cells = $row.children().removeClass(remove);
354
+ // add appropriate column class names
355
+ if (sortList && sortList[0]) {
356
+ // primary sort column class
357
+ $cells.eq(sortList[0][0]).addClass(css[0]);
358
+ if (len > 1) {
359
+ for (indx = 1; indx < len; indx++) {
360
+ // secondary, tertiary, etc sort column classes
361
+ $cells.eq(sortList[indx][0]).addClass( css[indx] || css[last] );
362
+ }
363
+ }
364
+ }
365
+ }
366
+ });
367
+ ts.processTbody(table, $tbody, false);
368
+ }
369
+ // add classes to thead and tfoot
370
+ rows = wo.columns_thead !== false ? [ 'thead tr' ] : [];
371
+ if (wo.columns_tfoot !== false) {
372
+ rows.push('tfoot tr');
373
+ }
374
+ if (rows.length) {
375
+ $rows = $table.find( rows.join(',') ).children().removeClass(remove);
376
+ if (len) {
377
+ for (indx = 0; indx < len; indx++) {
378
+ // add primary. secondary, tertiary, etc sort column classes
379
+ $rows.filter('[data-column="' + sortList[indx][0] + '"]').addClass(css[indx] || css[last]);
380
+ }
381
+ }
382
+ }
383
+ },
384
+ remove: function(table, c, wo) {
385
+ var tbodyIndex, $tbody,
386
+ $tbodies = c.$tbodies,
387
+ remove = (wo.columns || [ 'primary', 'secondary', 'tertiary' ]).join(' ');
388
+ c.$headers.removeClass(remove);
389
+ c.$table.children('tfoot').children('tr').children('th, td').removeClass(remove);
390
+ for (tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
391
+ $tbody = ts.processTbody(table, $tbodies.eq(tbodyIndex), true); // remove tbody
392
+ $tbody.children('tr').each(function() {
393
+ $(this).children().removeClass(remove);
394
+ });
395
+ ts.processTbody(table, $tbody, false); // restore tbody
396
+ }
397
+ }
398
+ });
399
+
400
+ })(jQuery);
401
+
402
+ /*! Widget: filter - updated 2018-03-18 (v2.30.0) *//*
403
+ * Requires tablesorter v2.8+ and jQuery 1.7+
404
+ * by Rob Garrison
405
+ */
406
+ ;( function ( $ ) {
407
+ 'use strict';
408
+ var tsf, tsfRegex,
409
+ ts = $.tablesorter || {},
410
+ tscss = ts.css,
411
+ tskeyCodes = ts.keyCodes;
412
+
413
+ $.extend( tscss, {
414
+ filterRow : 'tablesorter-filter-row',
415
+ filter : 'tablesorter-filter',
416
+ filterDisabled : 'disabled',
417
+ filterRowHide : 'hideme'
418
+ });
419
+
420
+ $.extend( tskeyCodes, {
421
+ backSpace : 8,
422
+ escape : 27,
423
+ space : 32,
424
+ left : 37,
425
+ down : 40
426
+ });
427
+
428
+ ts.addWidget({
429
+ id: 'filter',
430
+ priority: 50,
431
+ options : {
432
+ filter_cellFilter : '', // css class name added to the filter cell ( string or array )
433
+ filter_childRows : false, // if true, filter includes child row content in the search
434
+ filter_childByColumn : false, // ( filter_childRows must be true ) if true = search child rows by column; false = search all child row text grouped
435
+ filter_childWithSibs : true, // if true, include matching child row siblings
436
+ filter_columnAnyMatch: true, // if true, allows using '#:{query}' in AnyMatch searches ( column:query )
437
+ filter_columnFilters : true, // if true, a filter will be added to the top of each table column
438
+ filter_cssFilter : '', // css class name added to the filter row & each input in the row ( tablesorter-filter is ALWAYS added )
439
+ filter_defaultAttrib : 'data-value', // data attribute in the header cell that contains the default filter value
440
+ filter_defaultFilter : {}, // add a default column filter type '~{query}' to make fuzzy searches default; '{q1} AND {q2}' to make all searches use a logical AND.
441
+ filter_excludeFilter : {}, // filters to exclude, per column
442
+ filter_external : '', // jQuery selector string ( or jQuery object ) of external filters
443
+ filter_filteredRow : 'filtered', // class added to filtered rows; define in css with "display:none" to hide the filtered-out rows
444
+ filter_filterLabel : 'Filter "{{label}}" column by...', // Aria-label added to filter input/select; see #1495
445
+ filter_formatter : null, // add custom filter elements to the filter row
446
+ filter_functions : null, // add custom filter functions using this option
447
+ filter_hideEmpty : true, // hide filter row when table is empty
448
+ filter_hideFilters : false, // collapse filter row when mouse leaves the area
449
+ filter_ignoreCase : true, // if true, make all searches case-insensitive
450
+ filter_liveSearch : true, // if true, search column content while the user types ( with a delay )
451
+ filter_matchType : { 'input': 'exact', 'select': 'exact' }, // global query settings ('exact' or 'match'); overridden by "filter-match" or "filter-exact" class
452
+ filter_onlyAvail : 'filter-onlyAvail', // a header with a select dropdown & this class name will only show available ( visible ) options within the drop down
453
+ filter_placeholder : { search : '', select : '' }, // default placeholder text ( overridden by any header 'data-placeholder' setting )
454
+ filter_reset : null, // jQuery selector string of an element used to reset the filters
455
+ filter_resetOnEsc : true, // Reset filter input when the user presses escape - normalized across browsers
456
+ filter_saveFilters : false, // Use the $.tablesorter.storage utility to save the most recent filters
457
+ filter_searchDelay : 300, // typing delay in milliseconds before starting a search
458
+ filter_searchFiltered: true, // allow searching through already filtered rows in special circumstances; will speed up searching in large tables if true
459
+ filter_selectSource : null, // include a function to return an array of values to be added to the column filter select
460
+ filter_selectSourceSeparator : '|', // filter_selectSource array text left of the separator is added to the option value, right into the option text
461
+ filter_serversideFiltering : false, // if true, must perform server-side filtering b/c client-side filtering is disabled, but the ui and events will still be used.
462
+ filter_startsWith : false, // if true, filter start from the beginning of the cell contents
463
+ filter_useParsedData : false // filter all data using parsed content
464
+ },
465
+ format: function( table, c, wo ) {
466
+ if ( !c.$table.hasClass( 'hasFilters' ) ) {
467
+ tsf.init( table, c, wo );
468
+ }
469
+ },
470
+ remove: function( table, c, wo, refreshing ) {
471
+ var tbodyIndex, $tbody,
472
+ $table = c.$table,
473
+ $tbodies = c.$tbodies,
474
+ events = (
475
+ 'addRows updateCell update updateRows updateComplete appendCache filterReset ' +
476
+ 'filterAndSortReset filterFomatterUpdate filterEnd search stickyHeadersInit '
477
+ ).split( ' ' ).join( c.namespace + 'filter ' );
478
+ $table
479
+ .removeClass( 'hasFilters' )
480
+ // add filter namespace to all BUT search
481
+ .unbind( events.replace( ts.regex.spaces, ' ' ) )
482
+ // remove the filter row even if refreshing, because the column might have been moved
483
+ .find( '.' + tscss.filterRow ).remove();
484
+ wo.filter_initialized = false;
485
+ if ( refreshing ) { return; }
486
+ for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
487
+ $tbody = ts.processTbody( table, $tbodies.eq( tbodyIndex ), true ); // remove tbody
488
+ $tbody.children().removeClass( wo.filter_filteredRow ).show();
489
+ ts.processTbody( table, $tbody, false ); // restore tbody
490
+ }
491
+ if ( wo.filter_reset ) {
492
+ $( document ).undelegate( wo.filter_reset, 'click' + c.namespace + 'filter' );
493
+ }
494
+ }
495
+ });
496
+
497
+ tsf = ts.filter = {
498
+
499
+ // regex used in filter 'check' functions - not for general use and not documented
500
+ regex: {
501
+ regex : /^\/((?:\\\/|[^\/])+)\/([migyu]{0,5})?$/, // regex to test for regex
502
+ child : /tablesorter-childRow/, // child row class name; this gets updated in the script
503
+ filtered : /filtered/, // filtered (hidden) row class name; updated in the script
504
+ type : /undefined|number/, // check type
505
+ exact : /(^[\"\'=]+)|([\"\'=]+$)/g, // exact match (allow '==')
506
+ operators : /[<>=]/g, // replace operators
507
+ query : '(q|query)', // replace filter queries
508
+ wild01 : /\?/g, // wild card match 0 or 1
509
+ wild0More : /\*/g, // wild care match 0 or more
510
+ quote : /\"/g,
511
+ isNeg1 : /(>=?\s*-\d)/,
512
+ isNeg2 : /(<=?\s*\d)/
513
+ },
514
+ // function( c, data ) { }
515
+ // c = table.config
516
+ // data.$row = jQuery object of the row currently being processed
517
+ // data.$cells = jQuery object of all cells within the current row
518
+ // data.filters = array of filters for all columns ( some may be undefined )
519
+ // data.filter = filter for the current column
520
+ // data.iFilter = same as data.filter, except lowercase ( if wo.filter_ignoreCase is true )
521
+ // data.exact = table cell text ( or parsed data if column parser enabled; may be a number & not a string )
522
+ // data.iExact = same as data.exact, except lowercase ( if wo.filter_ignoreCase is true; may be a number & not a string )
523
+ // data.cache = table cell text from cache, so it has been parsed ( & in all lower case if c.ignoreCase is true )
524
+ // data.cacheArray = An array of parsed content from each table cell in the row being processed
525
+ // data.index = column index; table = table element ( DOM )
526
+ // data.parsed = array ( by column ) of boolean values ( from filter_useParsedData or 'filter-parsed' class )
527
+ types: {
528
+ or : function( c, data, vars ) {
529
+ // look for "|", but not if it is inside of a regular expression
530
+ if ( ( tsfRegex.orTest.test( data.iFilter ) || tsfRegex.orSplit.test( data.filter ) ) &&
531
+ // this test for regex has potential to slow down the overall search
532
+ !tsfRegex.regex.test( data.filter ) ) {
533
+ var indx, filterMatched, query, regex,
534
+ // duplicate data but split filter
535
+ data2 = $.extend( {}, data ),
536
+ filter = data.filter.split( tsfRegex.orSplit ),
537
+ iFilter = data.iFilter.split( tsfRegex.orSplit ),
538
+ len = filter.length;
539
+ for ( indx = 0; indx < len; indx++ ) {
540
+ data2.nestedFilters = true;
541
+ data2.filter = '' + ( tsf.parseFilter( c, filter[ indx ], data ) || '' );
542
+ data2.iFilter = '' + ( tsf.parseFilter( c, iFilter[ indx ], data ) || '' );
543
+ query = '(' + ( tsf.parseFilter( c, data2.filter, data ) || '' ) + ')';
544
+ try {
545
+ // use try/catch, because query may not be a valid regex if "|" is contained within a partial regex search,
546
+ // e.g "/(Alex|Aar" -> Uncaught SyntaxError: Invalid regular expression: /(/(Alex)/: Unterminated group
547
+ regex = new RegExp( data.isMatch ? query : '^' + query + '$', c.widgetOptions.filter_ignoreCase ? 'i' : '' );
548
+ // filterMatched = data2.filter === '' && indx > 0 ? true
549
+ // look for an exact match with the 'or' unless the 'filter-match' class is found
550
+ filterMatched = regex.test( data2.exact ) || tsf.processTypes( c, data2, vars );
551
+ if ( filterMatched ) {
552
+ return filterMatched;
553
+ }
554
+ } catch ( error ) {
555
+ return null;
556
+ }
557
+ }
558
+ // may be null from processing types
559
+ return filterMatched || false;
560
+ }
561
+ return null;
562
+ },
563
+ // Look for an AND or && operator ( logical and )
564
+ and : function( c, data, vars ) {
565
+ if ( tsfRegex.andTest.test( data.filter ) ) {
566
+ var indx, filterMatched, result, query, regex,
567
+ // duplicate data but split filter
568
+ data2 = $.extend( {}, data ),
569
+ filter = data.filter.split( tsfRegex.andSplit ),
570
+ iFilter = data.iFilter.split( tsfRegex.andSplit ),
571
+ len = filter.length;
572
+ for ( indx = 0; indx < len; indx++ ) {
573
+ data2.nestedFilters = true;
574
+ data2.filter = '' + ( tsf.parseFilter( c, filter[ indx ], data ) || '' );
575
+ data2.iFilter = '' + ( tsf.parseFilter( c, iFilter[ indx ], data ) || '' );
576
+ query = ( '(' + ( tsf.parseFilter( c, data2.filter, data ) || '' ) + ')' )
577
+ // replace wild cards since /(a*)/i will match anything
578
+ .replace( tsfRegex.wild01, '\\S{1}' ).replace( tsfRegex.wild0More, '\\S*' );
579
+ try {
580
+ // use try/catch just in case RegExp is invalid
581
+ regex = new RegExp( data.isMatch ? query : '^' + query + '$', c.widgetOptions.filter_ignoreCase ? 'i' : '' );
582
+ // look for an exact match with the 'and' unless the 'filter-match' class is found
583
+ result = ( regex.test( data2.exact ) || tsf.processTypes( c, data2, vars ) );
584
+ if ( indx === 0 ) {
585
+ filterMatched = result;
586
+ } else {
587
+ filterMatched = filterMatched && result;
588
+ }
589
+ } catch ( error ) {
590
+ return null;
591
+ }
592
+ }
593
+ // may be null from processing types
594
+ return filterMatched || false;
595
+ }
596
+ return null;
597
+ },
598
+ // Look for regex
599
+ regex: function( c, data ) {
600
+ if ( tsfRegex.regex.test( data.filter ) ) {
601
+ var matches,
602
+ // cache regex per column for optimal speed
603
+ regex = data.filter_regexCache[ data.index ] || tsfRegex.regex.exec( data.filter ),
604
+ isRegex = regex instanceof RegExp;
605
+ try {
606
+ if ( !isRegex ) {
607
+ // force case insensitive search if ignoreCase option set?
608
+ // if ( c.ignoreCase && !regex[2] ) { regex[2] = 'i'; }
609
+ data.filter_regexCache[ data.index ] = regex = new RegExp( regex[1], regex[2] );
610
+ }
611
+ matches = regex.test( data.exact );
612
+ } catch ( error ) {
613
+ matches = false;
614
+ }
615
+ return matches;
616
+ }
617
+ return null;
618
+ },
619
+ // Look for operators >, >=, < or <=
620
+ operators: function( c, data ) {
621
+ // ignore empty strings... because '' < 10 is true
622
+ if ( tsfRegex.operTest.test( data.iFilter ) && data.iExact !== '' ) {
623
+ var cachedValue, result, txt,
624
+ table = c.table,
625
+ parsed = data.parsed[ data.index ],
626
+ query = ts.formatFloat( data.iFilter.replace( tsfRegex.operators, '' ), table ),
627
+ parser = c.parsers[ data.index ] || {},
628
+ savedSearch = query;
629
+ // parse filter value in case we're comparing numbers ( dates )
630
+ if ( parsed || parser.type === 'numeric' ) {
631
+ txt = $.trim( '' + data.iFilter.replace( tsfRegex.operators, '' ) );
632
+ result = tsf.parseFilter( c, txt, data, true );
633
+ query = ( typeof result === 'number' && result !== '' && !isNaN( result ) ) ? result : query;
634
+ }
635
+ // iExact may be numeric - see issue #149;
636
+ // check if cached is defined, because sometimes j goes out of range? ( numeric columns )
637
+ if ( ( parsed || parser.type === 'numeric' ) && !isNaN( query ) &&
638
+ typeof data.cache !== 'undefined' ) {
639
+ cachedValue = data.cache;
640
+ } else {
641
+ txt = isNaN( data.iExact ) ? data.iExact.replace( ts.regex.nondigit, '' ) : data.iExact;
642
+ cachedValue = ts.formatFloat( txt, table );
643
+ }
644
+ if ( tsfRegex.gtTest.test( data.iFilter ) ) {
645
+ result = tsfRegex.gteTest.test( data.iFilter ) ? cachedValue >= query : cachedValue > query;
646
+ } else if ( tsfRegex.ltTest.test( data.iFilter ) ) {
647
+ result = tsfRegex.lteTest.test( data.iFilter ) ? cachedValue <= query : cachedValue < query;
648
+ }
649
+ // keep showing all rows if nothing follows the operator
650
+ if ( !result && savedSearch === '' ) {
651
+ result = true;
652
+ }
653
+ return result;
654
+ }
655
+ return null;
656
+ },
657
+ // Look for a not match
658
+ notMatch: function( c, data ) {
659
+ if ( tsfRegex.notTest.test( data.iFilter ) ) {
660
+ var indx,
661
+ txt = data.iFilter.replace( '!', '' ),
662
+ filter = tsf.parseFilter( c, txt, data ) || '';
663
+ if ( tsfRegex.exact.test( filter ) ) {
664
+ // look for exact not matches - see #628
665
+ filter = filter.replace( tsfRegex.exact, '' );
666
+ return filter === '' ? true : $.trim( filter ) !== data.iExact;
667
+ } else {
668
+ indx = data.iExact.search( $.trim( filter ) );
669
+ return filter === '' ? true :
670
+ // return true if not found
671
+ data.anyMatch ? indx < 0 :
672
+ // return false if found
673
+ !( c.widgetOptions.filter_startsWith ? indx === 0 : indx >= 0 );
674
+ }
675
+ }
676
+ return null;
677
+ },
678
+ // Look for quotes or equals to get an exact match; ignore type since iExact could be numeric
679
+ exact: function( c, data ) {
680
+ /*jshint eqeqeq:false */
681
+ if ( tsfRegex.exact.test( data.iFilter ) ) {
682
+ var txt = data.iFilter.replace( tsfRegex.exact, '' ),
683
+ filter = tsf.parseFilter( c, txt, data ) || '';
684
+ // eslint-disable-next-line eqeqeq
685
+ return data.anyMatch ? $.inArray( filter, data.rowArray ) >= 0 : filter == data.iExact;
686
+ }
687
+ return null;
688
+ },
689
+ // Look for a range ( using ' to ' or ' - ' ) - see issue #166; thanks matzhu!
690
+ range : function( c, data ) {
691
+ if ( tsfRegex.toTest.test( data.iFilter ) ) {
692
+ var result, tmp, range1, range2,
693
+ table = c.table,
694
+ index = data.index,
695
+ parsed = data.parsed[index],
696
+ // make sure the dash is for a range and not indicating a negative number
697
+ query = data.iFilter.split( tsfRegex.toSplit );
698
+
699
+ tmp = query[0].replace( ts.regex.nondigit, '' ) || '';
700
+ range1 = ts.formatFloat( tsf.parseFilter( c, tmp, data ), table );
701
+ tmp = query[1].replace( ts.regex.nondigit, '' ) || '';
702
+ range2 = ts.formatFloat( tsf.parseFilter( c, tmp, data ), table );
703
+ // parse filter value in case we're comparing numbers ( dates )
704
+ if ( parsed || c.parsers[ index ].type === 'numeric' ) {
705
+ result = c.parsers[ index ].format( '' + query[0], table, c.$headers.eq( index ), index );
706
+ range1 = ( result !== '' && !isNaN( result ) ) ? result : range1;
707
+ result = c.parsers[ index ].format( '' + query[1], table, c.$headers.eq( index ), index );
708
+ range2 = ( result !== '' && !isNaN( result ) ) ? result : range2;
709
+ }
710
+ if ( ( parsed || c.parsers[ index ].type === 'numeric' ) && !isNaN( range1 ) && !isNaN( range2 ) ) {
711
+ result = data.cache;
712
+ } else {
713
+ tmp = isNaN( data.iExact ) ? data.iExact.replace( ts.regex.nondigit, '' ) : data.iExact;
714
+ result = ts.formatFloat( tmp, table );
715
+ }
716
+ if ( range1 > range2 ) {
717
+ tmp = range1; range1 = range2; range2 = tmp; // swap
718
+ }
719
+ return ( result >= range1 && result <= range2 ) || ( range1 === '' || range2 === '' );
720
+ }
721
+ return null;
722
+ },
723
+ // Look for wild card: ? = single, * = multiple, or | = logical OR
724
+ wild : function( c, data ) {
725
+ if ( tsfRegex.wildOrTest.test( data.iFilter ) ) {
726
+ var query = '' + ( tsf.parseFilter( c, data.iFilter, data ) || '' );
727
+ // look for an exact match with the 'or' unless the 'filter-match' class is found
728
+ if ( !tsfRegex.wildTest.test( query ) && data.nestedFilters ) {
729
+ query = data.isMatch ? query : '^(' + query + ')$';
730
+ }
731
+ // parsing the filter may not work properly when using wildcards =/
732
+ try {
733
+ return new RegExp(
734
+ query.replace( tsfRegex.wild01, '\\S{1}' ).replace( tsfRegex.wild0More, '\\S*' ),
735
+ c.widgetOptions.filter_ignoreCase ? 'i' : ''
736
+ )
737
+ .test( data.exact );
738
+ } catch ( error ) {
739
+ return null;
740
+ }
741
+ }
742
+ return null;
743
+ },
744
+ // fuzzy text search; modified from https://github.com/mattyork/fuzzy ( MIT license )
745
+ fuzzy: function( c, data ) {
746
+ if ( tsfRegex.fuzzyTest.test( data.iFilter ) ) {
747
+ var indx,
748
+ patternIndx = 0,
749
+ len = data.iExact.length,
750
+ txt = data.iFilter.slice( 1 ),
751
+ pattern = tsf.parseFilter( c, txt, data ) || '';
752
+ for ( indx = 0; indx < len; indx++ ) {
753
+ if ( data.iExact[ indx ] === pattern[ patternIndx ] ) {
754
+ patternIndx += 1;
755
+ }
756
+ }
757
+ return patternIndx === pattern.length;
758
+ }
759
+ return null;
760
+ }
761
+ },
762
+ init: function( table ) {
763
+ // filter language options
764
+ ts.language = $.extend( true, {}, {
765
+ to : 'to',
766
+ or : 'or',
767
+ and : 'and'
768
+ }, ts.language );
769
+
770
+ var options, string, txt, $header, column, val, fxn, noSelect,
771
+ c = table.config,
772
+ wo = c.widgetOptions,
773
+ processStr = function(prefix, str, suffix) {
774
+ str = str.trim();
775
+ // don't include prefix/suffix if str is empty
776
+ return str === '' ? '' : (prefix || '') + str + (suffix || '');
777
+ };
778
+ c.$table.addClass( 'hasFilters' );
779
+ c.lastSearch = [];
780
+
781
+ // define timers so using clearTimeout won't cause an undefined error
782
+ wo.filter_searchTimer = null;
783
+ wo.filter_initTimer = null;
784
+ wo.filter_formatterCount = 0;
785
+ wo.filter_formatterInit = [];
786
+ wo.filter_anyColumnSelector = '[data-column="all"],[data-column="any"]';
787
+ wo.filter_multipleColumnSelector = '[data-column*="-"],[data-column*=","]';
788
+
789
+ val = '\\{' + tsfRegex.query + '\\}';
790
+ $.extend( tsfRegex, {
791
+ child : new RegExp( c.cssChildRow ),
792
+ filtered : new RegExp( wo.filter_filteredRow ),
793
+ alreadyFiltered : new RegExp( '(\\s+(-' + processStr('|', ts.language.or) + processStr('|', ts.language.to) + ')\\s+)', 'i' ),
794
+ toTest : new RegExp( '\\s+(-' + processStr('|', ts.language.to) + ')\\s+', 'i' ),
795
+ toSplit : new RegExp( '(?:\\s+(?:-' + processStr('|', ts.language.to) + ')\\s+)', 'gi' ),
796
+ andTest : new RegExp( '\\s+(' + processStr('', ts.language.and, '|') + '&&)\\s+', 'i' ),
797
+ andSplit : new RegExp( '(?:\\s+(?:' + processStr('', ts.language.and, '|') + '&&)\\s+)', 'gi' ),
798
+ orTest : new RegExp( '(\\|' + processStr('|\\s+', ts.language.or, '\\s+') + ')', 'i' ),
799
+ orSplit : new RegExp( '(?:\\|' + processStr('|\\s+(?:', ts.language.or, ')\\s+') + ')', 'gi' ),
800
+ iQuery : new RegExp( val, 'i' ),
801
+ igQuery : new RegExp( val, 'ig' ),
802
+ operTest : /^[<>]=?/,
803
+ gtTest : />/,
804
+ gteTest : />=/,
805
+ ltTest : /</,
806
+ lteTest : /<=/,
807
+ notTest : /^\!/,
808
+ wildOrTest : /[\?\*\|]/,
809
+ wildTest : /\?\*/,
810
+ fuzzyTest : /^~/,
811
+ exactTest : /[=\"\|!]/
812
+ });
813
+
814
+ // don't build filter row if columnFilters is false or all columns are set to 'filter-false'
815
+ // see issue #156
816
+ val = c.$headers.filter( '.filter-false, .parser-false' ).length;
817
+ if ( wo.filter_columnFilters !== false && val !== c.$headers.length ) {
818
+ // build filter row
819
+ tsf.buildRow( table, c, wo );
820
+ }
821
+
822
+ txt = 'addRows updateCell update updateRows updateComplete appendCache filterReset ' +
823
+ 'filterAndSortReset filterResetSaved filterEnd search '.split( ' ' ).join( c.namespace + 'filter ' );
824
+ c.$table.bind( txt, function( event, filter ) {
825
+ val = wo.filter_hideEmpty &&
826
+ $.isEmptyObject( c.cache ) &&
827
+ !( c.delayInit && event.type === 'appendCache' );
828
+ // hide filter row using the 'filtered' class name
829
+ c.$table.find( '.' + tscss.filterRow ).toggleClass( wo.filter_filteredRow, val ); // fixes #450
830
+ if ( !/(search|filter)/.test( event.type ) ) {
831
+ event.stopPropagation();
832
+ tsf.buildDefault( table, true );
833
+ }
834
+ // Add filterAndSortReset - see #1361
835
+ if ( event.type === 'filterReset' || event.type === 'filterAndSortReset' ) {
836
+ c.$table.find( '.' + tscss.filter ).add( wo.filter_$externalFilters ).val( '' );
837
+ if ( event.type === 'filterAndSortReset' ) {
838
+ ts.sortReset( this.config, function() {
839
+ tsf.searching( table, [] );
840
+ });
841
+ } else {
842
+ tsf.searching( table, [] );
843
+ }
844
+ } else if ( event.type === 'filterResetSaved' ) {
845
+ ts.storage( table, 'tablesorter-filters', '' );
846
+ } else if ( event.type === 'filterEnd' ) {
847
+ tsf.buildDefault( table, true );
848
+ } else {
849
+ // send false argument to force a new search; otherwise if the filter hasn't changed,
850
+ // it will return
851
+ filter = event.type === 'search' ? filter :
852
+ event.type === 'updateComplete' ? c.$table.data( 'lastSearch' ) : '';
853
+ if ( /(update|add)/.test( event.type ) && event.type !== 'updateComplete' ) {
854
+ // force a new search since content has changed
855
+ c.lastCombinedFilter = null;
856
+ c.lastSearch = [];
857
+ // update filterFormatters after update (& small delay) - Fixes #1237
858
+ setTimeout(function() {
859
+ c.$table.triggerHandler( 'filterFomatterUpdate' );
860
+ }, 100);
861
+ }
862
+ // pass true ( skipFirst ) to prevent the tablesorter.setFilters function from skipping the first
863
+ // input ensures all inputs are updated when a search is triggered on the table
864
+ // $( 'table' ).trigger( 'search', [...] );
865
+ tsf.searching( table, filter, true );
866
+ }
867
+ return false;
868
+ });
869
+
870
+ // reset button/link
871
+ if ( wo.filter_reset ) {
872
+ if ( wo.filter_reset instanceof $ ) {
873
+ // reset contains a jQuery object, bind to it
874
+ wo.filter_reset.click( function() {
875
+ c.$table.triggerHandler( 'filterReset' );
876
+ });
877
+ } else if ( $( wo.filter_reset ).length ) {
878
+ // reset is a jQuery selector, use event delegation
879
+ $( document )
880
+ .undelegate( wo.filter_reset, 'click' + c.namespace + 'filter' )
881
+ .delegate( wo.filter_reset, 'click' + c.namespace + 'filter', function() {
882
+ // trigger a reset event, so other functions ( filter_formatter ) know when to reset
883
+ c.$table.triggerHandler( 'filterReset' );
884
+ });
885
+ }
886
+ }
887
+ if ( wo.filter_functions ) {
888
+ for ( column = 0; column < c.columns; column++ ) {
889
+ fxn = ts.getColumnData( table, wo.filter_functions, column );
890
+ if ( fxn ) {
891
+ // remove 'filter-select' from header otherwise the options added here are replaced with
892
+ // all options
893
+ $header = c.$headerIndexed[ column ].removeClass( 'filter-select' );
894
+ // don't build select if 'filter-false' or 'parser-false' set
895
+ noSelect = !( $header.hasClass( 'filter-false' ) || $header.hasClass( 'parser-false' ) );
896
+ options = '';
897
+ if ( fxn === true && noSelect ) {
898
+ tsf.buildSelect( table, column );
899
+ } else if ( typeof fxn === 'object' && noSelect ) {
900
+ // add custom drop down list
901
+ for ( string in fxn ) {
902
+ if ( typeof string === 'string' ) {
903
+ options += options === '' ?
904
+ '<option value="">' +
905
+ ( $header.data( 'placeholder' ) ||
906
+ $header.attr( 'data-placeholder' ) ||
907
+ wo.filter_placeholder.select ||
908
+ ''
909
+ ) +
910
+ '</option>' : '';
911
+ val = string;
912
+ txt = string;
913
+ if ( string.indexOf( wo.filter_selectSourceSeparator ) >= 0 ) {
914
+ val = string.split( wo.filter_selectSourceSeparator );
915
+ txt = val[1];
916
+ val = val[0];
917
+ }
918
+ options += '<option ' +
919
+ ( txt === val ? '' : 'data-function-name="' + string + '" ' ) +
920
+ 'value="' + val + '">' + txt + '</option>';
921
+ }
922
+ }
923
+ c.$table
924
+ .find( 'thead' )
925
+ .find( 'select.' + tscss.filter + '[data-column="' + column + '"]' )
926
+ .append( options );
927
+ txt = wo.filter_selectSource;
928
+ fxn = typeof txt === 'function' ? true : ts.getColumnData( table, txt, column );
929
+ if ( fxn ) {
930
+ // updating so the extra options are appended
931
+ tsf.buildSelect( c.table, column, '', true, $header.hasClass( wo.filter_onlyAvail ) );
932
+ }
933
+ }
934
+ }
935
+ }
936
+ }
937
+ // not really updating, but if the column has both the 'filter-select' class &
938
+ // filter_functions set to true, it would append the same options twice.
939
+ tsf.buildDefault( table, true );
940
+
941
+ tsf.bindSearch( table, c.$table.find( '.' + tscss.filter ), true );
942
+ if ( wo.filter_external ) {
943
+ tsf.bindSearch( table, wo.filter_external );
944
+ }
945
+
946
+ if ( wo.filter_hideFilters ) {
947
+ tsf.hideFilters( c );
948
+ }
949
+
950
+ // show processing icon
951
+ if ( c.showProcessing ) {
952
+ txt = 'filterStart filterEnd '.split( ' ' ).join( c.namespace + 'filter-sp ' );
953
+ c.$table
954
+ .unbind( txt.replace( ts.regex.spaces, ' ' ) )
955
+ .bind( txt, function( event, columns ) {
956
+ // only add processing to certain columns to all columns
957
+ $header = ( columns ) ?
958
+ c.$table
959
+ .find( '.' + tscss.header )
960
+ .filter( '[data-column]' )
961
+ .filter( function() {
962
+ return columns[ $( this ).data( 'column' ) ] !== '';
963
+ }) : '';
964
+ ts.isProcessing( table, event.type === 'filterStart', columns ? $header : '' );
965
+ });
966
+ }
967
+
968
+ // set filtered rows count ( intially unfiltered )
969
+ c.filteredRows = c.totalRows;
970
+
971
+ // add default values
972
+ txt = 'tablesorter-initialized pagerBeforeInitialized '.split( ' ' ).join( c.namespace + 'filter ' );
973
+ c.$table
974
+ .unbind( txt.replace( ts.regex.spaces, ' ' ) )
975
+ .bind( txt, function() {
976
+ tsf.completeInit( this );
977
+ });
978
+ // if filter widget is added after pager has initialized; then set filter init flag
979
+ if ( c.pager && c.pager.initialized && !wo.filter_initialized ) {
980
+ c.$table.triggerHandler( 'filterFomatterUpdate' );
981
+ setTimeout( function() {
982
+ tsf.filterInitComplete( c );
983
+ }, 100 );
984
+ } else if ( !wo.filter_initialized ) {
985
+ tsf.completeInit( table );
986
+ }
987
+ },
988
+ completeInit: function( table ) {
989
+ // redefine 'c' & 'wo' so they update properly inside this callback
990
+ var c = table.config,
991
+ wo = c.widgetOptions,
992
+ filters = tsf.setDefaults( table, c, wo ) || [];
993
+ if ( filters.length ) {
994
+ // prevent delayInit from triggering a cache build if filters are empty
995
+ if ( !( c.delayInit && filters.join( '' ) === '' ) ) {
996
+ ts.setFilters( table, filters, true );
997
+ }
998
+ }
999
+ c.$table.triggerHandler( 'filterFomatterUpdate' );
1000
+ // trigger init after setTimeout to prevent multiple filterStart/End/Init triggers
1001
+ setTimeout( function() {
1002
+ if ( !wo.filter_initialized ) {
1003
+ tsf.filterInitComplete( c );
1004
+ }
1005
+ }, 100 );
1006
+ },
1007
+
1008
+ // $cell parameter, but not the config, is passed to the filter_formatters,
1009
+ // so we have to work with it instead
1010
+ formatterUpdated: function( $cell, column ) {
1011
+ // prevent error if $cell is undefined - see #1056
1012
+ var $table = $cell && $cell.closest( 'table' );
1013
+ var config = $table.length && $table[0].config,
1014
+ wo = config && config.widgetOptions;
1015
+ if ( wo && !wo.filter_initialized ) {
1016
+ // add updates by column since this function
1017
+ // may be called numerous times before initialization
1018
+ wo.filter_formatterInit[ column ] = 1;
1019
+ }
1020
+ },
1021
+ filterInitComplete: function( c ) {
1022
+ var indx, len,
1023
+ wo = c.widgetOptions,
1024
+ count = 0,
1025
+ completed = function() {
1026
+ wo.filter_initialized = true;
1027
+ // update lastSearch - it gets cleared often
1028
+ c.lastSearch = c.$table.data( 'lastSearch' );
1029
+ c.$table.triggerHandler( 'filterInit', c );
1030
+ tsf.findRows( c.table, c.lastSearch || [] );
1031
+ if (ts.debug(c, 'filter')) {
1032
+ console.log('Filter >> Widget initialized');
1033
+ }
1034
+ };
1035
+ if ( $.isEmptyObject( wo.filter_formatter ) ) {
1036
+ completed();
1037
+ } else {
1038
+ len = wo.filter_formatterInit.length;
1039
+ for ( indx = 0; indx < len; indx++ ) {
1040
+ if ( wo.filter_formatterInit[ indx ] === 1 ) {
1041
+ count++;
1042
+ }
1043
+ }
1044
+ clearTimeout( wo.filter_initTimer );
1045
+ if ( !wo.filter_initialized && count === wo.filter_formatterCount ) {
1046
+ // filter widget initialized
1047
+ completed();
1048
+ } else if ( !wo.filter_initialized ) {
1049
+ // fall back in case a filter_formatter doesn't call
1050
+ // $.tablesorter.filter.formatterUpdated( $cell, column ), and the count is off
1051
+ wo.filter_initTimer = setTimeout( function() {
1052
+ completed();
1053
+ }, 500 );
1054
+ }
1055
+ }
1056
+ },
1057
+ // encode or decode filters for storage; see #1026
1058
+ processFilters: function( filters, encode ) {
1059
+ var indx,
1060
+ // fixes #1237; previously returning an encoded "filters" value
1061
+ result = [],
1062
+ mode = encode ? encodeURIComponent : decodeURIComponent,
1063
+ len = filters.length;
1064
+ for ( indx = 0; indx < len; indx++ ) {
1065
+ if ( filters[ indx ] ) {
1066
+ result[ indx ] = mode( filters[ indx ] );
1067
+ }
1068
+ }
1069
+ return result;
1070
+ },
1071
+ setDefaults: function( table, c, wo ) {
1072
+ var isArray, saved, indx, col, $filters,
1073
+ // get current ( default ) filters
1074
+ filters = ts.getFilters( table ) || [];
1075
+ if ( wo.filter_saveFilters && ts.storage ) {
1076
+ saved = ts.storage( table, 'tablesorter-filters' ) || [];
1077
+ isArray = $.isArray( saved );
1078
+ // make sure we're not just getting an empty array
1079
+ if ( !( isArray && saved.join( '' ) === '' || !isArray ) ) {
1080
+ filters = tsf.processFilters( saved );
1081
+ }
1082
+ }
1083
+ // if no filters saved, then check default settings
1084
+ if ( filters.join( '' ) === '' ) {
1085
+ // allow adding default setting to external filters
1086
+ $filters = c.$headers.add( wo.filter_$externalFilters )
1087
+ .filter( '[' + wo.filter_defaultAttrib + ']' );
1088
+ for ( indx = 0; indx <= c.columns; indx++ ) {
1089
+ // include data-column='all' external filters
1090
+ col = indx === c.columns ? 'all' : indx;
1091
+ filters[ indx ] = $filters
1092
+ .filter( '[data-column="' + col + '"]' )
1093
+ .attr( wo.filter_defaultAttrib ) || filters[indx] || '';
1094
+ }
1095
+ }
1096
+ c.$table.data( 'lastSearch', filters );
1097
+ return filters;
1098
+ },
1099
+ parseFilter: function( c, filter, data, parsed ) {
1100
+ return parsed || data.parsed[ data.index ] ?
1101
+ c.parsers[ data.index ].format( filter, c.table, [], data.index ) :
1102
+ filter;
1103
+ },
1104
+ buildRow: function( table, c, wo ) {
1105
+ var $filter, col, column, $header, makeSelect, disabled, name, ffxn, tmp,
1106
+ // c.columns defined in computeThIndexes()
1107
+ cellFilter = wo.filter_cellFilter,
1108
+ columns = c.columns,
1109
+ arry = $.isArray( cellFilter ),
1110
+ buildFilter = '<tr role="search" class="' + tscss.filterRow + ' ' + c.cssIgnoreRow + '">';
1111
+ for ( column = 0; column < columns; column++ ) {
1112
+ if ( c.$headerIndexed[ column ].length ) {
1113
+ // account for entire column set with colspan. See #1047
1114
+ tmp = c.$headerIndexed[ column ] && c.$headerIndexed[ column ][0].colSpan || 0;
1115
+ if ( tmp > 1 ) {
1116
+ buildFilter += '<td data-column="' + column + '-' + ( column + tmp - 1 ) + '" colspan="' + tmp + '"';
1117
+ } else {
1118
+ buildFilter += '<td data-column="' + column + '"';
1119
+ }
1120
+ if ( arry ) {
1121
+ buildFilter += ( cellFilter[ column ] ? ' class="' + cellFilter[ column ] + '"' : '' );
1122
+ } else {
1123
+ buildFilter += ( cellFilter !== '' ? ' class="' + cellFilter + '"' : '' );
1124
+ }
1125
+ buildFilter += '></td>';
1126
+ }
1127
+ }
1128
+ c.$filters = $( buildFilter += '</tr>' )
1129
+ .appendTo( c.$table.children( 'thead' ).eq( 0 ) )
1130
+ .children( 'td' );
1131
+ // build each filter input
1132
+ for ( column = 0; column < columns; column++ ) {
1133
+ disabled = false;
1134
+ // assuming last cell of a column is the main column
1135
+ $header = c.$headerIndexed[ column ];
1136
+ if ( $header && $header.length ) {
1137
+ // $filter = c.$filters.filter( '[data-column="' + column + '"]' );
1138
+ $filter = tsf.getColumnElm( c, c.$filters, column );
1139
+ ffxn = ts.getColumnData( table, wo.filter_functions, column );
1140
+ makeSelect = ( wo.filter_functions && ffxn && typeof ffxn !== 'function' ) ||
1141
+ $header.hasClass( 'filter-select' );
1142
+ // get data from jQuery data, metadata, headers option or header class name
1143
+ col = ts.getColumnData( table, c.headers, column );
1144
+ disabled = ts.getData( $header[0], col, 'filter' ) === 'false' ||
1145
+ ts.getData( $header[0], col, 'parser' ) === 'false';
1146
+
1147
+ if ( makeSelect ) {
1148
+ buildFilter = $( '<select>' ).appendTo( $filter );
1149
+ } else {
1150
+ ffxn = ts.getColumnData( table, wo.filter_formatter, column );
1151
+ if ( ffxn ) {
1152
+ wo.filter_formatterCount++;
1153
+ buildFilter = ffxn( $filter, column );
1154
+ // no element returned, so lets go find it
1155
+ if ( buildFilter && buildFilter.length === 0 ) {
1156
+ buildFilter = $filter.children( 'input' );
1157
+ }
1158
+ // element not in DOM, so lets attach it
1159
+ if ( buildFilter && ( buildFilter.parent().length === 0 ||
1160
+ ( buildFilter.parent().length && buildFilter.parent()[0] !== $filter[0] ) ) ) {
1161
+ $filter.append( buildFilter );
1162
+ }
1163
+ } else {
1164
+ buildFilter = $( '<input type="search">' ).appendTo( $filter );
1165
+ }
1166
+ if ( buildFilter ) {
1167
+ tmp = $header.data( 'placeholder' ) ||
1168
+ $header.attr( 'data-placeholder' ) ||
1169
+ wo.filter_placeholder.search || '';
1170
+ buildFilter.attr( 'placeholder', tmp );
1171
+ }
1172
+ }
1173
+ if ( buildFilter ) {
1174
+ // add filter class name
1175
+ name = ( $.isArray( wo.filter_cssFilter ) ?
1176
+ ( typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '' ) :
1177
+ wo.filter_cssFilter ) || '';
1178
+ // copy data-column from table cell (it will include colspan)
1179
+ buildFilter.addClass( tscss.filter + ' ' + name );
1180
+ name = wo.filter_filterLabel;
1181
+ tmp = name.match(/{{([^}]+?)}}/g);
1182
+ if (!tmp) {
1183
+ tmp = [ '{{label}}' ];
1184
+ }
1185
+ $.each(tmp, function(indx, attr) {
1186
+ var regex = new RegExp(attr, 'g'),
1187
+ data = $header.attr('data-' + attr.replace(/{{|}}/g, '')),
1188
+ text = typeof data === 'undefined' ? $header.text() : data;
1189
+ name = name.replace( regex, $.trim( text ) );
1190
+ });
1191
+ buildFilter.attr({
1192
+ 'data-column': $filter.attr( 'data-column' ),
1193
+ 'aria-label': name
1194
+ });
1195
+ if ( disabled ) {
1196
+ buildFilter.attr( 'placeholder', '' ).addClass( tscss.filterDisabled )[0].disabled = true;
1197
+ }
1198
+ }
1199
+ }
1200
+ }
1201
+ },
1202
+ bindSearch: function( table, $el, internal ) {
1203
+ table = $( table )[0];
1204
+ $el = $( $el ); // allow passing a selector string
1205
+ if ( !$el.length ) { return; }
1206
+ var tmp,
1207
+ c = table.config,
1208
+ wo = c.widgetOptions,
1209
+ namespace = c.namespace + 'filter',
1210
+ $ext = wo.filter_$externalFilters;
1211
+ if ( internal !== true ) {
1212
+ // save anyMatch element
1213
+ tmp = wo.filter_anyColumnSelector + ',' + wo.filter_multipleColumnSelector;
1214
+ wo.filter_$anyMatch = $el.filter( tmp );
1215
+ if ( $ext && $ext.length ) {
1216
+ wo.filter_$externalFilters = wo.filter_$externalFilters.add( $el );
1217
+ } else {
1218
+ wo.filter_$externalFilters = $el;
1219
+ }
1220
+ // update values ( external filters added after table initialization )
1221
+ ts.setFilters( table, c.$table.data( 'lastSearch' ) || [], internal === false );
1222
+ }
1223
+ // unbind events
1224
+ tmp = ( 'keypress keyup keydown search change input '.split( ' ' ).join( namespace + ' ' ) );
1225
+ $el
1226
+ // use data attribute instead of jQuery data since the head is cloned without including
1227
+ // the data/binding
1228
+ .attr( 'data-lastSearchTime', new Date().getTime() )
1229
+ .unbind( tmp.replace( ts.regex.spaces, ' ' ) )
1230
+ .bind( 'keydown' + namespace, function( event ) {
1231
+ if ( event.which === tskeyCodes.escape && !table.config.widgetOptions.filter_resetOnEsc ) {
1232
+ // prevent keypress event
1233
+ return false;
1234
+ }
1235
+ })
1236
+ .bind( 'keyup' + namespace, function( event ) {
1237
+ wo = table.config.widgetOptions; // make sure "wo" isn't cached
1238
+ var column = parseInt( $( this ).attr( 'data-column' ), 10 ),
1239
+ liveSearch = typeof wo.filter_liveSearch === 'boolean' ? wo.filter_liveSearch :
1240
+ ts.getColumnData( table, wo.filter_liveSearch, column );
1241
+ if ( typeof liveSearch === 'undefined' ) {
1242
+ liveSearch = wo.filter_liveSearch.fallback || false;
1243
+ }
1244
+ $( this ).attr( 'data-lastSearchTime', new Date().getTime() );
1245
+ // emulate what webkit does.... escape clears the filter
1246
+ if ( event.which === tskeyCodes.escape ) {
1247
+ // make sure to restore the last value on escape
1248
+ this.value = wo.filter_resetOnEsc ? '' : c.lastSearch[column];
1249
+ // don't return if the search value is empty ( all rows need to be revealed )
1250
+ } else if ( this.value !== '' && (
1251
+ // liveSearch can contain a min value length; ignore arrow and meta keys, but allow backspace
1252
+ ( typeof liveSearch === 'number' && this.value.length < liveSearch ) ||
1253
+ // let return & backspace continue on, but ignore arrows & non-valid characters
1254
+ ( event.which !== tskeyCodes.enter && event.which !== tskeyCodes.backSpace &&
1255
+ ( event.which < tskeyCodes.space || ( event.which >= tskeyCodes.left && event.which <= tskeyCodes.down ) ) ) ) ) {
1256
+ return;
1257
+ // live search
1258
+ } else if ( liveSearch === false ) {
1259
+ if ( this.value !== '' && event.which !== tskeyCodes.enter ) {
1260
+ return;
1261
+ }
1262
+ }
1263
+ // change event = no delay; last true flag tells getFilters to skip newest timed input
1264
+ tsf.searching( table, true, true, column );
1265
+ })
1266
+ // include change for select - fixes #473
1267
+ .bind( 'search change keypress input blur '.split( ' ' ).join( namespace + ' ' ), function( event ) {
1268
+ // don't get cached data, in case data-column changes dynamically
1269
+ var column = parseInt( $( this ).attr( 'data-column' ), 10 ),
1270
+ eventType = event.type,
1271
+ liveSearch = typeof wo.filter_liveSearch === 'boolean' ?
1272
+ wo.filter_liveSearch :
1273
+ ts.getColumnData( table, wo.filter_liveSearch, column );
1274
+ if ( table.config.widgetOptions.filter_initialized &&
1275
+ // immediate search if user presses enter
1276
+ ( event.which === tskeyCodes.enter ||
1277
+ // immediate search if a "search" or "blur" is triggered on the input
1278
+ ( eventType === 'search' || eventType === 'blur' ) ||
1279
+ // change & input events must be ignored if liveSearch !== true
1280
+ ( eventType === 'change' || eventType === 'input' ) &&
1281
+ // prevent search if liveSearch is a number
1282
+ ( liveSearch === true || liveSearch !== true && event.target.nodeName !== 'INPUT' ) &&
1283
+ // don't allow 'change' or 'input' event to process if the input value
1284
+ // is the same - fixes #685
1285
+ this.value !== c.lastSearch[column]
1286
+ )
1287
+ ) {
1288
+ event.preventDefault();
1289
+ // init search with no delay
1290
+ $( this ).attr( 'data-lastSearchTime', new Date().getTime() );
1291
+ tsf.searching( table, eventType !== 'keypress' || event.which === tskeyCodes.enter, true, column );
1292
+ }
1293
+ });
1294
+ },
1295
+ searching: function( table, filter, skipFirst, column ) {
1296
+ var liveSearch,
1297
+ wo = table.config.widgetOptions;
1298
+ if (typeof column === 'undefined') {
1299
+ // no delay
1300
+ liveSearch = false;
1301
+ } else {
1302
+ liveSearch = typeof wo.filter_liveSearch === 'boolean' ?
1303
+ wo.filter_liveSearch :
1304
+ // get column setting, or set to fallback value, or default to false
1305
+ ts.getColumnData( table, wo.filter_liveSearch, column );
1306
+ if ( typeof liveSearch === 'undefined' ) {
1307
+ liveSearch = wo.filter_liveSearch.fallback || false;
1308
+ }
1309
+ }
1310
+ clearTimeout( wo.filter_searchTimer );
1311
+ if ( typeof filter === 'undefined' || filter === true ) {
1312
+ // delay filtering
1313
+ wo.filter_searchTimer = setTimeout( function() {
1314
+ tsf.checkFilters( table, filter, skipFirst );
1315
+ }, liveSearch ? wo.filter_searchDelay : 10 );
1316
+ } else {
1317
+ // skip delay
1318
+ tsf.checkFilters( table, filter, skipFirst );
1319
+ }
1320
+ },
1321
+ equalFilters: function (c, filter1, filter2) {
1322
+ var indx,
1323
+ f1 = [],
1324
+ f2 = [],
1325
+ len = c.columns + 1; // add one to include anyMatch filter
1326
+ filter1 = $.isArray(filter1) ? filter1 : [];
1327
+ filter2 = $.isArray(filter2) ? filter2 : [];
1328
+ for (indx = 0; indx < len; indx++) {
1329
+ f1[indx] = filter1[indx] || '';
1330
+ f2[indx] = filter2[indx] || '';
1331
+ }
1332
+ return f1.join(',') === f2.join(',');
1333
+ },
1334
+ checkFilters: function( table, filter, skipFirst ) {
1335
+ var c = table.config,
1336
+ wo = c.widgetOptions,
1337
+ filterArray = $.isArray( filter ),
1338
+ filters = ( filterArray ) ? filter : ts.getFilters( table, true ),
1339
+ currentFilters = filters || []; // current filter values
1340
+ // prevent errors if delay init is set
1341
+ if ( $.isEmptyObject( c.cache ) ) {
1342
+ // update cache if delayInit set & pager has initialized ( after user initiates a search )
1343
+ if ( c.delayInit && ( !c.pager || c.pager && c.pager.initialized ) ) {
1344
+ ts.updateCache( c, function() {
1345
+ tsf.checkFilters( table, false, skipFirst );
1346
+ });
1347
+ }
1348
+ return;
1349
+ }
1350
+ // add filter array back into inputs
1351
+ if ( filterArray ) {
1352
+ ts.setFilters( table, filters, false, skipFirst !== true );
1353
+ if ( !wo.filter_initialized ) {
1354
+ c.lastSearch = [];
1355
+ c.lastCombinedFilter = '';
1356
+ }
1357
+ }
1358
+ if ( wo.filter_hideFilters ) {
1359
+ // show/hide filter row as needed
1360
+ c.$table
1361
+ .find( '.' + tscss.filterRow )
1362
+ .triggerHandler( tsf.hideFiltersCheck( c ) ? 'mouseleave' : 'mouseenter' );
1363
+ }
1364
+ // return if the last search is the same; but filter === false when updating the search
1365
+ // see example-widget-filter.html filter toggle buttons
1366
+ if ( tsf.equalFilters(c, c.lastSearch, currentFilters) ) {
1367
+ if ( filter !== false ) {
1368
+ return;
1369
+ } else {
1370
+ // force filter refresh
1371
+ c.lastCombinedFilter = '';
1372
+ c.lastSearch = [];
1373
+ }
1374
+ }
1375
+ // define filter inside it is false
1376
+ filters = filters || [];
1377
+ // convert filters to strings - see #1070
1378
+ filters = Array.prototype.map ?
1379
+ filters.map( String ) :
1380
+ // for IE8 & older browsers - maybe not the best method
1381
+ filters.join( '\ufffd' ).split( '\ufffd' );
1382
+
1383
+ if ( wo.filter_initialized ) {
1384
+ c.$table.triggerHandler( 'filterStart', [ filters ] );
1385
+ }
1386
+ if ( c.showProcessing ) {
1387
+ // give it time for the processing icon to kick in
1388
+ setTimeout( function() {
1389
+ tsf.findRows( table, filters, currentFilters );
1390
+ return false;
1391
+ }, 30 );
1392
+ } else {
1393
+ tsf.findRows( table, filters, currentFilters );
1394
+ return false;
1395
+ }
1396
+ },
1397
+ hideFiltersCheck: function( c ) {
1398
+ if (typeof c.widgetOptions.filter_hideFilters === 'function') {
1399
+ var val = c.widgetOptions.filter_hideFilters( c );
1400
+ if (typeof val === 'boolean') {
1401
+ return val;
1402
+ }
1403
+ }
1404
+ return ts.getFilters( c.$table ).join( '' ) === '';
1405
+ },
1406
+ hideFilters: function( c, $table ) {
1407
+ var timer;
1408
+ ( $table || c.$table )
1409
+ .find( '.' + tscss.filterRow )
1410
+ .addClass( tscss.filterRowHide )
1411
+ .bind( 'mouseenter mouseleave', function( e ) {
1412
+ // save event object - http://bugs.jquery.com/ticket/12140
1413
+ var event = e,
1414
+ $row = $( this );
1415
+ clearTimeout( timer );
1416
+ timer = setTimeout( function() {
1417
+ if ( /enter|over/.test( event.type ) ) {
1418
+ $row.removeClass( tscss.filterRowHide );
1419
+ } else {
1420
+ // don't hide if input has focus
1421
+ // $( ':focus' ) needs jQuery 1.6+
1422
+ if ( $( document.activeElement ).closest( 'tr' )[0] !== $row[0] ) {
1423
+ // don't hide row if any filter has a value
1424
+ $row.toggleClass( tscss.filterRowHide, tsf.hideFiltersCheck( c ) );
1425
+ }
1426
+ }
1427
+ }, 200 );
1428
+ })
1429
+ .find( 'input, select' ).bind( 'focus blur', function( e ) {
1430
+ var event = e,
1431
+ $row = $( this ).closest( 'tr' );
1432
+ clearTimeout( timer );
1433
+ timer = setTimeout( function() {
1434
+ clearTimeout( timer );
1435
+ // don't hide row if any filter has a value
1436
+ $row.toggleClass( tscss.filterRowHide, tsf.hideFiltersCheck( c ) && event.type !== 'focus' );
1437
+ }, 200 );
1438
+ });
1439
+ },
1440
+ defaultFilter: function( filter, mask ) {
1441
+ if ( filter === '' ) { return filter; }
1442
+ var regex = tsfRegex.iQuery,
1443
+ maskLen = mask.match( tsfRegex.igQuery ).length,
1444
+ query = maskLen > 1 ? $.trim( filter ).split( /\s/ ) : [ $.trim( filter ) ],
1445
+ len = query.length - 1,
1446
+ indx = 0,
1447
+ val = mask;
1448
+ if ( len < 1 && maskLen > 1 ) {
1449
+ // only one 'word' in query but mask has >1 slots
1450
+ query[1] = query[0];
1451
+ }
1452
+ // replace all {query} with query words...
1453
+ // if query = 'Bob', then convert mask from '!{query}' to '!Bob'
1454
+ // if query = 'Bob Joe Frank', then convert mask '{q} OR {q}' to 'Bob OR Joe OR Frank'
1455
+ while ( regex.test( val ) ) {
1456
+ val = val.replace( regex, query[indx++] || '' );
1457
+ if ( regex.test( val ) && indx < len && ( query[indx] || '' ) !== '' ) {
1458
+ val = mask.replace( regex, val );
1459
+ }
1460
+ }
1461
+ return val;
1462
+ },
1463
+ getLatestSearch: function( $input ) {
1464
+ if ( $input ) {
1465
+ return $input.sort( function( a, b ) {
1466
+ return $( b ).attr( 'data-lastSearchTime' ) - $( a ).attr( 'data-lastSearchTime' );
1467
+ });
1468
+ }
1469
+ return $input || $();
1470
+ },
1471
+ findRange: function( c, val, ignoreRanges ) {
1472
+ // look for multiple columns '1-3,4-6,8' in data-column
1473
+ var temp, ranges, range, start, end, singles, i, indx, len,
1474
+ columns = [];
1475
+ if ( /^[0-9]+$/.test( val ) ) {
1476
+ // always return an array
1477
+ return [ parseInt( val, 10 ) ];
1478
+ }
1479
+ // process column range
1480
+ if ( !ignoreRanges && /-/.test( val ) ) {
1481
+ ranges = val.match( /(\d+)\s*-\s*(\d+)/g );
1482
+ len = ranges ? ranges.length : 0;
1483
+ for ( indx = 0; indx < len; indx++ ) {
1484
+ range = ranges[indx].split( /\s*-\s*/ );
1485
+ start = parseInt( range[0], 10 ) || 0;
1486
+ end = parseInt( range[1], 10 ) || ( c.columns - 1 );
1487
+ if ( start > end ) {
1488
+ temp = start; start = end; end = temp; // swap
1489
+ }
1490
+ if ( end >= c.columns ) {
1491
+ end = c.columns - 1;
1492
+ }
1493
+ for ( ; start <= end; start++ ) {
1494
+ columns[ columns.length ] = start;
1495
+ }
1496
+ // remove processed range from val
1497
+ val = val.replace( ranges[ indx ], '' );
1498
+ }
1499
+ }
1500
+ // process single columns
1501
+ if ( !ignoreRanges && /,/.test( val ) ) {
1502
+ singles = val.split( /\s*,\s*/ );
1503
+ len = singles.length;
1504
+ for ( i = 0; i < len; i++ ) {
1505
+ if ( singles[ i ] !== '' ) {
1506
+ indx = parseInt( singles[ i ], 10 );
1507
+ if ( indx < c.columns ) {
1508
+ columns[ columns.length ] = indx;
1509
+ }
1510
+ }
1511
+ }
1512
+ }
1513
+ // return all columns
1514
+ if ( !columns.length ) {
1515
+ for ( indx = 0; indx < c.columns; indx++ ) {
1516
+ columns[ columns.length ] = indx;
1517
+ }
1518
+ }
1519
+ return columns;
1520
+ },
1521
+ getColumnElm: function( c, $elements, column ) {
1522
+ // data-column may contain multiple columns '1-3,5-6,8'
1523
+ // replaces: c.$filters.filter( '[data-column="' + column + '"]' );
1524
+ return $elements.filter( function() {
1525
+ var cols = tsf.findRange( c, $( this ).attr( 'data-column' ) );
1526
+ return $.inArray( column, cols ) > -1;
1527
+ });
1528
+ },
1529
+ multipleColumns: function( c, $input ) {
1530
+ // look for multiple columns '1-3,4-6,8' in data-column
1531
+ var wo = c.widgetOptions,
1532
+ // only target 'all' column inputs on initialization
1533
+ // & don't target 'all' column inputs if they don't exist
1534
+ targets = wo.filter_initialized || !$input.filter( wo.filter_anyColumnSelector ).length,
1535
+ val = $.trim( tsf.getLatestSearch( $input ).attr( 'data-column' ) || '' );
1536
+ return tsf.findRange( c, val, !targets );
1537
+ },
1538
+ processTypes: function( c, data, vars ) {
1539
+ var ffxn,
1540
+ filterMatched = null,
1541
+ matches = null;
1542
+ for ( ffxn in tsf.types ) {
1543
+ if ( $.inArray( ffxn, vars.excludeMatch ) < 0 && matches === null ) {
1544
+ matches = tsf.types[ffxn]( c, data, vars );
1545
+ if ( matches !== null ) {
1546
+ data.matchedOn = ffxn;
1547
+ filterMatched = matches;
1548
+ }
1549
+ }
1550
+ }
1551
+ return filterMatched;
1552
+ },
1553
+ matchType: function( c, columnIndex ) {
1554
+ var isMatch,
1555
+ wo = c.widgetOptions,
1556
+ $el = c.$headerIndexed[ columnIndex ];
1557
+ // filter-exact > filter-match > filter_matchType for type
1558
+ if ( $el.hasClass( 'filter-exact' ) ) {
1559
+ isMatch = false;
1560
+ } else if ( $el.hasClass( 'filter-match' ) ) {
1561
+ isMatch = true;
1562
+ } else {
1563
+ // filter-select is not applied when filter_functions are used, so look for a select
1564
+ if ( wo.filter_columnFilters ) {
1565
+ $el = c.$filters
1566
+ .find( '.' + tscss.filter )
1567
+ .add( wo.filter_$externalFilters )
1568
+ .filter( '[data-column="' + columnIndex + '"]' );
1569
+ } else if ( wo.filter_$externalFilters ) {
1570
+ $el = wo.filter_$externalFilters.filter( '[data-column="' + columnIndex + '"]' );
1571
+ }
1572
+ isMatch = $el.length ?
1573
+ c.widgetOptions.filter_matchType[ ( $el[ 0 ].nodeName || '' ).toLowerCase() ] === 'match' :
1574
+ // default to exact, if no inputs found
1575
+ false;
1576
+ }
1577
+ return isMatch;
1578
+ },
1579
+ processRow: function( c, data, vars ) {
1580
+ var result, filterMatched,
1581
+ fxn, ffxn, txt,
1582
+ wo = c.widgetOptions,
1583
+ showRow = true,
1584
+ hasAnyMatchInput = wo.filter_$anyMatch && wo.filter_$anyMatch.length,
1585
+
1586
+ // if wo.filter_$anyMatch data-column attribute is changed dynamically
1587
+ // we don't want to do an "anyMatch" search on one column using data
1588
+ // for the entire row - see #998
1589
+ columnIndex = wo.filter_$anyMatch && wo.filter_$anyMatch.length ?
1590
+ // look for multiple columns '1-3,4-6,8'
1591
+ tsf.multipleColumns( c, wo.filter_$anyMatch ) :
1592
+ [];
1593
+ data.$cells = data.$row.children();
1594
+ data.matchedOn = null;
1595
+ if ( data.anyMatchFlag && columnIndex.length > 1 || ( data.anyMatchFilter && !hasAnyMatchInput ) ) {
1596
+ data.anyMatch = true;
1597
+ data.isMatch = true;
1598
+ data.rowArray = data.$cells.map( function( i ) {
1599
+ if ( $.inArray( i, columnIndex ) > -1 || ( data.anyMatchFilter && !hasAnyMatchInput ) ) {
1600
+ if ( data.parsed[ i ] ) {
1601
+ txt = data.cacheArray[ i ];
1602
+ } else {
1603
+ txt = data.rawArray[ i ];
1604
+ txt = $.trim( wo.filter_ignoreCase ? txt.toLowerCase() : txt );
1605
+ if ( c.sortLocaleCompare ) {
1606
+ txt = ts.replaceAccents( txt );
1607
+ }
1608
+ }
1609
+ return txt;
1610
+ }
1611
+ }).get();
1612
+ data.filter = data.anyMatchFilter;
1613
+ data.iFilter = data.iAnyMatchFilter;
1614
+ data.exact = data.rowArray.join( ' ' );
1615
+ data.iExact = wo.filter_ignoreCase ? data.exact.toLowerCase() : data.exact;
1616
+ data.cache = data.cacheArray.slice( 0, -1 ).join( ' ' );
1617
+ vars.excludeMatch = vars.noAnyMatch;
1618
+ filterMatched = tsf.processTypes( c, data, vars );
1619
+ if ( filterMatched !== null ) {
1620
+ showRow = filterMatched;
1621
+ } else {
1622
+ if ( wo.filter_startsWith ) {
1623
+ showRow = false;
1624
+ // data.rowArray may not contain all columns
1625
+ columnIndex = Math.min( c.columns, data.rowArray.length );
1626
+ while ( !showRow && columnIndex > 0 ) {
1627
+ columnIndex--;
1628
+ showRow = showRow || data.rowArray[ columnIndex ].indexOf( data.iFilter ) === 0;
1629
+ }
1630
+ } else {
1631
+ showRow = ( data.iExact + data.childRowText ).indexOf( data.iFilter ) >= 0;
1632
+ }
1633
+ }
1634
+ data.anyMatch = false;
1635
+ // no other filters to process
1636
+ if ( data.filters.join( '' ) === data.filter ) {
1637
+ return showRow;
1638
+ }
1639
+ }
1640
+
1641
+ for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
1642
+ data.filter = data.filters[ columnIndex ];
1643
+ data.index = columnIndex;
1644
+
1645
+ // filter types to exclude, per column
1646
+ vars.excludeMatch = vars.excludeFilter[ columnIndex ];
1647
+
1648
+ // ignore if filter is empty or disabled
1649
+ if ( data.filter ) {
1650
+ data.cache = data.cacheArray[ columnIndex ];
1651
+ result = data.parsed[ columnIndex ] ? data.cache : data.rawArray[ columnIndex ] || '';
1652
+ data.exact = c.sortLocaleCompare ? ts.replaceAccents( result ) : result; // issue #405
1653
+ data.iExact = !tsfRegex.type.test( typeof data.exact ) && wo.filter_ignoreCase ?
1654
+ data.exact.toLowerCase() : data.exact;
1655
+ data.isMatch = tsf.matchType( c, columnIndex );
1656
+
1657
+ result = showRow; // if showRow is true, show that row
1658
+
1659
+ // in case select filter option has a different value vs text 'a - z|A through Z'
1660
+ ffxn = wo.filter_columnFilters ?
1661
+ c.$filters.add( wo.filter_$externalFilters )
1662
+ .filter( '[data-column="' + columnIndex + '"]' )
1663
+ .find( 'select option:selected' )
1664
+ .attr( 'data-function-name' ) || '' : '';
1665
+ // replace accents - see #357
1666
+ if ( c.sortLocaleCompare ) {
1667
+ data.filter = ts.replaceAccents( data.filter );
1668
+ }
1669
+
1670
+ // replace column specific default filters - see #1088
1671
+ if ( wo.filter_defaultFilter && tsfRegex.iQuery.test( vars.defaultColFilter[ columnIndex ] ) ) {
1672
+ data.filter = tsf.defaultFilter( data.filter, vars.defaultColFilter[ columnIndex ] );
1673
+ }
1674
+
1675
+ // data.iFilter = case insensitive ( if wo.filter_ignoreCase is true ),
1676
+ // data.filter = case sensitive
1677
+ data.iFilter = wo.filter_ignoreCase ? ( data.filter || '' ).toLowerCase() : data.filter;
1678
+ fxn = vars.functions[ columnIndex ];
1679
+ filterMatched = null;
1680
+ if ( fxn ) {
1681
+ if ( typeof fxn === 'function' ) {
1682
+ // filter callback( exact cell content, parser normalized content,
1683
+ // filter input value, column index, jQuery row object )
1684
+ filterMatched = fxn( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
1685
+ } else if ( typeof fxn[ ffxn || data.filter ] === 'function' ) {
1686
+ // selector option function
1687
+ txt = ffxn || data.filter;
1688
+ filterMatched =
1689
+ fxn[ txt ]( data.exact, data.cache, data.filter, columnIndex, data.$row, c, data );
1690
+ }
1691
+ }
1692
+ if ( filterMatched === null ) {
1693
+ // cycle through the different filters
1694
+ // filters return a boolean or null if nothing matches
1695
+ filterMatched = tsf.processTypes( c, data, vars );
1696
+ // select with exact match; ignore "and" or "or" within the text; fixes #1486
1697
+ txt = fxn === true && (data.matchedOn === 'and' || data.matchedOn === 'or');
1698
+ if ( filterMatched !== null && !txt) {
1699
+ result = filterMatched;
1700
+ // Look for match, and add child row data for matching
1701
+ } else {
1702
+ // check fxn (filter-select in header) after filter types are checked
1703
+ // without this, the filter + jQuery UI selectmenu demo was breaking
1704
+ if ( fxn === true ) {
1705
+ // default selector uses exact match unless 'filter-match' class is found
1706
+ result = data.isMatch ?
1707
+ // data.iExact may be a number
1708
+ ( '' + data.iExact ).search( data.iFilter ) >= 0 :
1709
+ data.filter === data.exact;
1710
+ } else {
1711
+ txt = ( data.iExact + data.childRowText ).indexOf( tsf.parseFilter( c, data.iFilter, data ) );
1712
+ result = ( ( !wo.filter_startsWith && txt >= 0 ) || ( wo.filter_startsWith && txt === 0 ) );
1713
+ }
1714
+ }
1715
+ } else {
1716
+ result = filterMatched;
1717
+ }
1718
+ showRow = ( result ) ? showRow : false;
1719
+ }
1720
+ }
1721
+ return showRow;
1722
+ },
1723
+ findRows: function( table, filters, currentFilters ) {
1724
+ if (
1725
+ tsf.equalFilters(table.config, table.config.lastSearch, currentFilters) ||
1726
+ !table.config.widgetOptions.filter_initialized
1727
+ ) {
1728
+ return;
1729
+ }
1730
+ var len, norm_rows, rowData, $rows, $row, rowIndex, tbodyIndex, $tbody, columnIndex,
1731
+ isChild, childRow, lastSearch, showRow, showParent, time, val, indx,
1732
+ notFiltered, searchFiltered, query, injected, res, id, txt,
1733
+ storedFilters = $.extend( [], filters ),
1734
+ c = table.config,
1735
+ wo = c.widgetOptions,
1736
+ debug = ts.debug(c, 'filter'),
1737
+ // data object passed to filters; anyMatch is a flag for the filters
1738
+ data = {
1739
+ anyMatch: false,
1740
+ filters: filters,
1741
+ // regex filter type cache
1742
+ filter_regexCache : []
1743
+ },
1744
+ vars = {
1745
+ // anyMatch really screws up with these types of filters
1746
+ noAnyMatch: [ 'range', 'operators' ],
1747
+ // cache filter variables that use ts.getColumnData in the main loop
1748
+ functions : [],
1749
+ excludeFilter : [],
1750
+ defaultColFilter : [],
1751
+ defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
1752
+ };
1753
+ // parse columns after formatter, in case the class is added at that point
1754
+ data.parsed = [];
1755
+ for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
1756
+ data.parsed[ columnIndex ] = wo.filter_useParsedData ||
1757
+ // parser has a "parsed" parameter
1758
+ ( c.parsers && c.parsers[ columnIndex ] && c.parsers[ columnIndex ].parsed ||
1759
+ // getData may not return 'parsed' if other 'filter-' class names exist
1760
+ // ( e.g. <th class="filter-select filter-parsed"> )
1761
+ ts.getData && ts.getData( c.$headerIndexed[ columnIndex ],
1762
+ ts.getColumnData( table, c.headers, columnIndex ), 'filter' ) === 'parsed' ||
1763
+ c.$headerIndexed[ columnIndex ].hasClass( 'filter-parsed' ) );
1764
+
1765
+ vars.functions[ columnIndex ] =
1766
+ ts.getColumnData( table, wo.filter_functions, columnIndex ) ||
1767
+ c.$headerIndexed[ columnIndex ].hasClass( 'filter-select' );
1768
+ vars.defaultColFilter[ columnIndex ] =
1769
+ ts.getColumnData( table, wo.filter_defaultFilter, columnIndex ) || '';
1770
+ vars.excludeFilter[ columnIndex ] =
1771
+ ( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split( /\s+/ );
1772
+ }
1773
+
1774
+ if ( debug ) {
1775
+ console.log( 'Filter >> Starting filter widget search', filters );
1776
+ time = new Date();
1777
+ }
1778
+ // filtered rows count
1779
+ c.filteredRows = 0;
1780
+ c.totalRows = 0;
1781
+ currentFilters = ( storedFilters || [] );
1782
+
1783
+ for ( tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
1784
+ $tbody = ts.processTbody( table, c.$tbodies.eq( tbodyIndex ), true );
1785
+ // skip child rows & widget added ( removable ) rows - fixes #448 thanks to @hempel!
1786
+ // $rows = $tbody.children( 'tr' ).not( c.selectorRemove );
1787
+ columnIndex = c.columns;
1788
+ // convert stored rows into a jQuery object
1789
+ norm_rows = c.cache[ tbodyIndex ].normalized;
1790
+ $rows = $( $.map( norm_rows, function( el ) {
1791
+ return el[ columnIndex ].$row.get();
1792
+ }) );
1793
+
1794
+ if ( currentFilters.join('') === '' || wo.filter_serversideFiltering ) {
1795
+ $rows
1796
+ .removeClass( wo.filter_filteredRow )
1797
+ .not( '.' + c.cssChildRow )
1798
+ .css( 'display', '' );
1799
+ } else {
1800
+ // filter out child rows
1801
+ $rows = $rows.not( '.' + c.cssChildRow );
1802
+ len = $rows.length;
1803
+
1804
+ if ( ( wo.filter_$anyMatch && wo.filter_$anyMatch.length ) ||
1805
+ typeof filters[c.columns] !== 'undefined' ) {
1806
+ data.anyMatchFlag = true;
1807
+ data.anyMatchFilter = '' + (
1808
+ filters[ c.columns ] ||
1809
+ wo.filter_$anyMatch && tsf.getLatestSearch( wo.filter_$anyMatch ).val() ||
1810
+ ''
1811
+ );
1812
+ if ( wo.filter_columnAnyMatch ) {
1813
+ // specific columns search
1814
+ query = data.anyMatchFilter.split( tsfRegex.andSplit );
1815
+ injected = false;
1816
+ for ( indx = 0; indx < query.length; indx++ ) {
1817
+ res = query[ indx ].split( ':' );
1818
+ if ( res.length > 1 ) {
1819
+ // make the column a one-based index ( non-developers start counting from one :P )
1820
+ if ( isNaN( res[0] ) ) {
1821
+ $.each( c.headerContent, function( i, txt ) {
1822
+ // multiple matches are possible
1823
+ if ( txt.toLowerCase().indexOf( res[0] ) > -1 ) {
1824
+ id = i;
1825
+ filters[ id ] = res[1];
1826
+ }
1827
+ });
1828
+ } else {
1829
+ id = parseInt( res[0], 10 ) - 1;
1830
+ }
1831
+ if ( id >= 0 && id < c.columns ) { // if id is an integer
1832
+ filters[ id ] = res[1];
1833
+ query.splice( indx, 1 );
1834
+ indx--;
1835
+ injected = true;
1836
+ }
1837
+ }
1838
+ }
1839
+ if ( injected ) {
1840
+ data.anyMatchFilter = query.join( ' && ' );
1841
+ }
1842
+ }
1843
+ }
1844
+
1845
+ // optimize searching only through already filtered rows - see #313
1846
+ searchFiltered = wo.filter_searchFiltered;
1847
+ lastSearch = c.lastSearch || c.$table.data( 'lastSearch' ) || [];
1848
+ if ( searchFiltered ) {
1849
+ // cycle through all filters; include last ( columnIndex + 1 = match any column ). Fixes #669
1850
+ for ( indx = 0; indx < columnIndex + 1; indx++ ) {
1851
+ val = filters[indx] || '';
1852
+ // break out of loop if we've already determined not to search filtered rows
1853
+ if ( !searchFiltered ) { indx = columnIndex; }
1854
+ // search already filtered rows if...
1855
+ searchFiltered = searchFiltered && lastSearch.length &&
1856
+ // there are no changes from beginning of filter
1857
+ val.indexOf( lastSearch[indx] || '' ) === 0 &&
1858
+ // if there is NOT a logical 'or', or range ( 'to' or '-' ) in the string
1859
+ !tsfRegex.alreadyFiltered.test( val ) &&
1860
+ // if we are not doing exact matches, using '|' ( logical or ) or not '!'
1861
+ !tsfRegex.exactTest.test( val ) &&
1862
+ // don't search only filtered if the value is negative
1863
+ // ( '> -10' => '> -100' will ignore hidden rows )
1864
+ !( tsfRegex.isNeg1.test( val ) || tsfRegex.isNeg2.test( val ) ) &&
1865
+ // if filtering using a select without a 'filter-match' class ( exact match ) - fixes #593
1866
+ !( val !== '' && c.$filters && c.$filters.filter( '[data-column="' + indx + '"]' ).find( 'select' ).length &&
1867
+ !tsf.matchType( c, indx ) );
1868
+ }
1869
+ }
1870
+ notFiltered = $rows.not( '.' + wo.filter_filteredRow ).length;
1871
+ // can't search when all rows are hidden - this happens when looking for exact matches
1872
+ if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
1873
+ if ( debug ) {
1874
+ console.log( 'Filter >> Searching through ' +
1875
+ ( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
1876
+ }
1877
+ if ( data.anyMatchFlag ) {
1878
+ if ( c.sortLocaleCompare ) {
1879
+ // replace accents
1880
+ data.anyMatchFilter = ts.replaceAccents( data.anyMatchFilter );
1881
+ }
1882
+ if ( wo.filter_defaultFilter && tsfRegex.iQuery.test( vars.defaultAnyFilter ) ) {
1883
+ data.anyMatchFilter = tsf.defaultFilter( data.anyMatchFilter, vars.defaultAnyFilter );
1884
+ // clear search filtered flag because default filters are not saved to the last search
1885
+ searchFiltered = false;
1886
+ }
1887
+ // make iAnyMatchFilter lowercase unless both filter widget & core ignoreCase options are true
1888
+ // when c.ignoreCase is true, the cache contains all lower case data
1889
+ data.iAnyMatchFilter = !( wo.filter_ignoreCase && c.ignoreCase ) ?
1890
+ data.anyMatchFilter :
1891
+ data.anyMatchFilter.toLowerCase();
1892
+ }
1893
+
1894
+ // loop through the rows
1895
+ for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
1896
+
1897
+ txt = $rows[ rowIndex ].className;
1898
+ // the first row can never be a child row
1899
+ isChild = rowIndex && tsfRegex.child.test( txt );
1900
+ // skip child rows & already filtered rows
1901
+ if ( isChild || ( searchFiltered && tsfRegex.filtered.test( txt ) ) ) {
1902
+ continue;
1903
+ }
1904
+
1905
+ data.$row = $rows.eq( rowIndex );
1906
+ data.rowIndex = rowIndex;
1907
+ data.cacheArray = norm_rows[ rowIndex ];
1908
+ rowData = data.cacheArray[ c.columns ];
1909
+ data.rawArray = rowData.raw;
1910
+ data.childRowText = '';
1911
+
1912
+ if ( !wo.filter_childByColumn ) {
1913
+ txt = '';
1914
+ // child row cached text
1915
+ childRow = rowData.child;
1916
+ // so, if 'table.config.widgetOptions.filter_childRows' is true and there is
1917
+ // a match anywhere in the child row, then it will make the row visible
1918
+ // checked here so the option can be changed dynamically
1919
+ for ( indx = 0; indx < childRow.length; indx++ ) {
1920
+ txt += ' ' + childRow[indx].join( ' ' ) || '';
1921
+ }
1922
+ data.childRowText = wo.filter_childRows ?
1923
+ ( wo.filter_ignoreCase ? txt.toLowerCase() : txt ) :
1924
+ '';
1925
+ }
1926
+
1927
+ showRow = false;
1928
+ showParent = tsf.processRow( c, data, vars );
1929
+ $row = rowData.$row;
1930
+
1931
+ // don't pass reference to val
1932
+ val = showParent ? true : false;
1933
+ childRow = rowData.$row.filter( ':gt(0)' );
1934
+ if ( wo.filter_childRows && childRow.length ) {
1935
+ if ( wo.filter_childByColumn ) {
1936
+ if ( !wo.filter_childWithSibs ) {
1937
+ // hide all child rows
1938
+ childRow.addClass( wo.filter_filteredRow );
1939
+ // if only showing resulting child row, only include parent
1940
+ $row = $row.eq( 0 );
1941
+ }
1942
+ // cycle through each child row
1943
+ for ( indx = 0; indx < childRow.length; indx++ ) {
1944
+ data.$row = childRow.eq( indx );
1945
+ data.cacheArray = rowData.child[ indx ];
1946
+ data.rawArray = data.cacheArray;
1947
+ val = tsf.processRow( c, data, vars );
1948
+ // use OR comparison on child rows
1949
+ showRow = showRow || val;
1950
+ if ( !wo.filter_childWithSibs && val ) {
1951
+ childRow.eq( indx ).removeClass( wo.filter_filteredRow );
1952
+ }
1953
+ }
1954
+ }
1955
+ // keep parent row match even if no child matches... see #1020
1956
+ showRow = showRow || showParent;
1957
+ } else {
1958
+ showRow = val;
1959
+ }
1960
+ $row
1961
+ .toggleClass( wo.filter_filteredRow, !showRow )[0]
1962
+ .display = showRow ? '' : 'none';
1963
+ }
1964
+ }
1965
+ c.filteredRows += $rows.not( '.' + wo.filter_filteredRow ).length;
1966
+ c.totalRows += $rows.length;
1967
+ ts.processTbody( table, $tbody, false );
1968
+ }
1969
+ // lastCombinedFilter is no longer used internally
1970
+ c.lastCombinedFilter = storedFilters.join(''); // save last search
1971
+ // don't save 'filters' directly since it may have altered ( AnyMatch column searches )
1972
+ c.lastSearch = storedFilters;
1973
+ c.$table.data( 'lastSearch', storedFilters );
1974
+ if ( wo.filter_saveFilters && ts.storage ) {
1975
+ ts.storage( table, 'tablesorter-filters', tsf.processFilters( storedFilters, true ) );
1976
+ }
1977
+ if ( debug ) {
1978
+ console.log( 'Filter >> Completed search' + ts.benchmark(time) );
1979
+ }
1980
+ if ( wo.filter_initialized ) {
1981
+ c.$table.triggerHandler( 'filterBeforeEnd', c );
1982
+ c.$table.triggerHandler( 'filterEnd', c );
1983
+ }
1984
+ setTimeout( function() {
1985
+ ts.applyWidget( c.table ); // make sure zebra widget is applied
1986
+ }, 0 );
1987
+ },
1988
+ getOptionSource: function( table, column, onlyAvail ) {
1989
+ table = $( table )[0];
1990
+ var c = table.config,
1991
+ wo = c.widgetOptions,
1992
+ arry = false,
1993
+ source = wo.filter_selectSource,
1994
+ last = c.$table.data( 'lastSearch' ) || [],
1995
+ fxn = typeof source === 'function' ? true : ts.getColumnData( table, source, column );
1996
+
1997
+ if ( onlyAvail && last[column] !== '' ) {
1998
+ onlyAvail = false;
1999
+ }
2000
+
2001
+ // filter select source option
2002
+ if ( fxn === true ) {
2003
+ // OVERALL source
2004
+ arry = source( table, column, onlyAvail );
2005
+ } else if ( fxn instanceof $ || ( $.type( fxn ) === 'string' && fxn.indexOf( '</option>' ) >= 0 ) ) {
2006
+ // selectSource is a jQuery object or string of options
2007
+ return fxn;
2008
+ } else if ( $.isArray( fxn ) ) {
2009
+ arry = fxn;
2010
+ } else if ( $.type( source ) === 'object' && fxn ) {
2011
+ // custom select source function for a SPECIFIC COLUMN
2012
+ arry = fxn( table, column, onlyAvail );
2013
+ // abort - updating the selects from an external method
2014
+ if (arry === null) {
2015
+ return null;
2016
+ }
2017
+ }
2018
+ if ( arry === false ) {
2019
+ // fall back to original method
2020
+ arry = tsf.getOptions( table, column, onlyAvail );
2021
+ }
2022
+
2023
+ return tsf.processOptions( table, column, arry );
2024
+
2025
+ },
2026
+ processOptions: function( table, column, arry ) {
2027
+ if ( !$.isArray( arry ) ) {
2028
+ return false;
2029
+ }
2030
+ table = $( table )[0];
2031
+ var cts, txt, indx, len, parsedTxt, str,
2032
+ c = table.config,
2033
+ validColumn = typeof column !== 'undefined' && column !== null && column >= 0 && column < c.columns,
2034
+ direction = validColumn ? c.$headerIndexed[ column ].hasClass( 'filter-select-sort-desc' ) : false,
2035
+ parsed = [];
2036
+ // get unique elements and sort the list
2037
+ // if $.tablesorter.sortText exists ( not in the original tablesorter ),
2038
+ // then natural sort the list otherwise use a basic sort
2039
+ arry = $.grep( arry, function( value, indx ) {
2040
+ if ( value.text ) {
2041
+ return true;
2042
+ }
2043
+ return $.inArray( value, arry ) === indx;
2044
+ });
2045
+ if ( validColumn && c.$headerIndexed[ column ].hasClass( 'filter-select-nosort' ) ) {
2046
+ // unsorted select options
2047
+ return arry;
2048
+ } else {
2049
+ len = arry.length;
2050
+ // parse select option values
2051
+ for ( indx = 0; indx < len; indx++ ) {
2052
+ txt = arry[ indx ];
2053
+ // check for object
2054
+ str = txt.text ? txt.text : txt;
2055
+ // sortNatural breaks if you don't pass it strings
2056
+ parsedTxt = ( validColumn && c.parsers && c.parsers.length &&
2057
+ c.parsers[ column ].format( str, table, [], column ) || str ).toString();
2058
+ parsedTxt = c.widgetOptions.filter_ignoreCase ? parsedTxt.toLowerCase() : parsedTxt;
2059
+ // parse array data using set column parser; this DOES NOT pass the original
2060
+ // table cell to the parser format function
2061
+ if ( txt.text ) {
2062
+ txt.parsed = parsedTxt;
2063
+ parsed[ parsed.length ] = txt;
2064
+ } else {
2065
+ parsed[ parsed.length ] = {
2066
+ text : txt,
2067
+ // check parser length - fixes #934
2068
+ parsed : parsedTxt
2069
+ };
2070
+ }
2071
+ }
2072
+ // sort parsed select options
2073
+ cts = c.textSorter || '';
2074
+ parsed.sort( function( a, b ) {
2075
+ var x = direction ? b.parsed : a.parsed,
2076
+ y = direction ? a.parsed : b.parsed;
2077
+ if ( validColumn && typeof cts === 'function' ) {
2078
+ // custom OVERALL text sorter
2079
+ return cts( x, y, true, column, table );
2080
+ } else if ( validColumn && typeof cts === 'object' && cts.hasOwnProperty( column ) ) {
2081
+ // custom text sorter for a SPECIFIC COLUMN
2082
+ return cts[column]( x, y, true, column, table );
2083
+ } else if ( ts.sortNatural ) {
2084
+ // fall back to natural sort
2085
+ return ts.sortNatural( x, y );
2086
+ }
2087
+ // using an older version! do a basic sort
2088
+ return true;
2089
+ });
2090
+ // rebuild arry from sorted parsed data
2091
+ arry = [];
2092
+ len = parsed.length;
2093
+ for ( indx = 0; indx < len; indx++ ) {
2094
+ arry[ arry.length ] = parsed[indx];
2095
+ }
2096
+ return arry;
2097
+ }
2098
+ },
2099
+ getOptions: function( table, column, onlyAvail ) {
2100
+ table = $( table )[0];
2101
+ var rowIndex, tbodyIndex, len, row, cache, indx, child, childLen,
2102
+ c = table.config,
2103
+ wo = c.widgetOptions,
2104
+ arry = [];
2105
+ for ( tbodyIndex = 0; tbodyIndex < c.$tbodies.length; tbodyIndex++ ) {
2106
+ cache = c.cache[tbodyIndex];
2107
+ len = c.cache[tbodyIndex].normalized.length;
2108
+ // loop through the rows
2109
+ for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
2110
+ // get cached row from cache.row ( old ) or row data object
2111
+ // ( new; last item in normalized array )
2112
+ row = cache.row ?
2113
+ cache.row[ rowIndex ] :
2114
+ cache.normalized[ rowIndex ][ c.columns ].$row[0];
2115
+ // check if has class filtered
2116
+ if ( onlyAvail && row.className.match( wo.filter_filteredRow ) ) {
2117
+ continue;
2118
+ }
2119
+ // get non-normalized cell content
2120
+ if ( wo.filter_useParsedData ||
2121
+ c.parsers[column].parsed ||
2122
+ c.$headerIndexed[column].hasClass( 'filter-parsed' ) ) {
2123
+ arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ column ];
2124
+ // child row parsed data
2125
+ if ( wo.filter_childRows && wo.filter_childByColumn ) {
2126
+ childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length - 1;
2127
+ for ( indx = 0; indx < childLen; indx++ ) {
2128
+ arry[ arry.length ] = '' + cache.normalized[ rowIndex ][ c.columns ].child[ indx ][ column ];
2129
+ }
2130
+ }
2131
+ } else {
2132
+ // get raw cached data instead of content directly from the cells
2133
+ arry[ arry.length ] = cache.normalized[ rowIndex ][ c.columns ].raw[ column ];
2134
+ // child row unparsed data
2135
+ if ( wo.filter_childRows && wo.filter_childByColumn ) {
2136
+ childLen = cache.normalized[ rowIndex ][ c.columns ].$row.length;
2137
+ for ( indx = 1; indx < childLen; indx++ ) {
2138
+ child = cache.normalized[ rowIndex ][ c.columns ].$row.eq( indx ).children().eq( column );
2139
+ arry[ arry.length ] = '' + ts.getElementText( c, child, column );
2140
+ }
2141
+ }
2142
+ }
2143
+ }
2144
+ }
2145
+ return arry;
2146
+ },
2147
+ buildSelect: function( table, column, arry, updating, onlyAvail ) {
2148
+ table = $( table )[0];
2149
+ column = parseInt( column, 10 );
2150
+ if ( !table.config.cache || $.isEmptyObject( table.config.cache ) ) {
2151
+ return;
2152
+ }
2153
+
2154
+ var indx, val, txt, t, $filters, $filter, option,
2155
+ c = table.config,
2156
+ wo = c.widgetOptions,
2157
+ node = c.$headerIndexed[ column ],
2158
+ // t.data( 'placeholder' ) won't work in jQuery older than 1.4.3
2159
+ options = '<option value="">' +
2160
+ ( node.data( 'placeholder' ) ||
2161
+ node.attr( 'data-placeholder' ) ||
2162
+ wo.filter_placeholder.select || ''
2163
+ ) + '</option>',
2164
+ // Get curent filter value
2165
+ currentValue = c.$table
2166
+ .find( 'thead' )
2167
+ .find( 'select.' + tscss.filter + '[data-column="' + column + '"]' )
2168
+ .val();
2169
+
2170
+ // nothing included in arry ( external source ), so get the options from
2171
+ // filter_selectSource or column data
2172
+ if ( typeof arry === 'undefined' || arry === '' ) {
2173
+ arry = tsf.getOptionSource( table, column, onlyAvail );
2174
+ // abort, selects are updated by an external method
2175
+ if (arry === null) {
2176
+ return;
2177
+ }
2178
+ }
2179
+
2180
+ if ( $.isArray( arry ) ) {
2181
+ // build option list
2182
+ for ( indx = 0; indx < arry.length; indx++ ) {
2183
+ option = arry[ indx ];
2184
+ if ( option.text ) {
2185
+ // OBJECT!! add data-function-name in case the value is set in filter_functions
2186
+ option['data-function-name'] = typeof option.value === 'undefined' ? option.text : option.value;
2187
+
2188
+ // support jQuery < v1.8, otherwise the below code could be shortened to
2189
+ // options += $( '<option>', option )[ 0 ].outerHTML;
2190
+ options += '<option';
2191
+ for ( val in option ) {
2192
+ if ( option.hasOwnProperty( val ) && val !== 'text' ) {
2193
+ options += ' ' + val + '="' + option[ val ].replace( tsfRegex.quote, '&quot;' ) + '"';
2194
+ }
2195
+ }
2196
+ if ( !option.value ) {
2197
+ options += ' value="' + option.text.replace( tsfRegex.quote, '&quot;' ) + '"';
2198
+ }
2199
+ options += '>' + option.text.replace( tsfRegex.quote, '&quot;' ) + '</option>';
2200
+ // above code is needed in jQuery < v1.8
2201
+
2202
+ // make sure we don't turn an object into a string (objects without a "text" property)
2203
+ } else if ( '' + option !== '[object Object]' ) {
2204
+ txt = option = ( '' + option ).replace( tsfRegex.quote, '&quot;' );
2205
+ val = txt;
2206
+ // allow including a symbol in the selectSource array
2207
+ // 'a-z|A through Z' so that 'a-z' becomes the option value
2208
+ // and 'A through Z' becomes the option text
2209
+ if ( txt.indexOf( wo.filter_selectSourceSeparator ) >= 0 ) {
2210
+ t = txt.split( wo.filter_selectSourceSeparator );
2211
+ val = t[0];
2212
+ txt = t[1];
2213
+ }
2214
+ // replace quotes - fixes #242 & ignore empty strings
2215
+ // see http://stackoverflow.com/q/14990971/145346
2216
+ options += option !== '' ?
2217
+ '<option ' +
2218
+ ( val === txt ? '' : 'data-function-name="' + option + '" ' ) +
2219
+ 'value="' + val + '">' + txt +
2220
+ '</option>' : '';
2221
+ }
2222
+ }
2223
+ // clear arry so it doesn't get appended twice
2224
+ arry = [];
2225
+ }
2226
+
2227
+ // update all selects in the same column ( clone thead in sticky headers &
2228
+ // any external selects ) - fixes 473
2229
+ $filters = ( c.$filters ? c.$filters : c.$table.children( 'thead' ) )
2230
+ .find( '.' + tscss.filter );
2231
+ if ( wo.filter_$externalFilters ) {
2232
+ $filters = $filters && $filters.length ?
2233
+ $filters.add( wo.filter_$externalFilters ) :
2234
+ wo.filter_$externalFilters;
2235
+ }
2236
+ $filter = $filters.filter( 'select[data-column="' + column + '"]' );
2237
+
2238
+ // make sure there is a select there!
2239
+ if ( $filter.length ) {
2240
+ $filter[ updating ? 'html' : 'append' ]( options );
2241
+ if ( !$.isArray( arry ) ) {
2242
+ // append options if arry is provided externally as a string or jQuery object
2243
+ // options ( default value ) was already added
2244
+ $filter.append( arry ).val( currentValue );
2245
+ }
2246
+ $filter.val( currentValue );
2247
+ }
2248
+ },
2249
+ buildDefault: function( table, updating ) {
2250
+ var columnIndex, $header, noSelect,
2251
+ c = table.config,
2252
+ wo = c.widgetOptions,
2253
+ columns = c.columns;
2254
+ // build default select dropdown
2255
+ for ( columnIndex = 0; columnIndex < columns; columnIndex++ ) {
2256
+ $header = c.$headerIndexed[columnIndex];
2257
+ noSelect = !( $header.hasClass( 'filter-false' ) || $header.hasClass( 'parser-false' ) );
2258
+ // look for the filter-select class; build/update it if found
2259
+ if ( ( $header.hasClass( 'filter-select' ) ||
2260
+ ts.getColumnData( table, wo.filter_functions, columnIndex ) === true ) && noSelect ) {
2261
+ tsf.buildSelect( table, columnIndex, '', updating, $header.hasClass( wo.filter_onlyAvail ) );
2262
+ }
2263
+ }
2264
+ }
2265
+ };
2266
+
2267
+ // filter regex variable
2268
+ tsfRegex = tsf.regex;
2269
+
2270
+ ts.getFilters = function( table, getRaw, setFilters, skipFirst ) {
2271
+ var i, $filters, $column, cols,
2272
+ filters = [],
2273
+ c = table ? $( table )[0].config : '',
2274
+ wo = c ? c.widgetOptions : '';
2275
+ if ( ( getRaw !== true && wo && !wo.filter_columnFilters ) ||
2276
+ // setFilters called, but last search is exactly the same as the current
2277
+ // fixes issue #733 & #903 where calling update causes the input values to reset
2278
+ ( $.isArray(setFilters) && tsf.equalFilters(c, setFilters, c.lastSearch) )
2279
+ ) {
2280
+ return $( table ).data( 'lastSearch' ) || [];
2281
+ }
2282
+ if ( c ) {
2283
+ if ( c.$filters ) {
2284
+ $filters = c.$filters.find( '.' + tscss.filter );
2285
+ }
2286
+ if ( wo.filter_$externalFilters ) {
2287
+ $filters = $filters && $filters.length ?
2288
+ $filters.add( wo.filter_$externalFilters ) :
2289
+ wo.filter_$externalFilters;
2290
+ }
2291
+ if ( $filters && $filters.length ) {
2292
+ filters = setFilters || [];
2293
+ for ( i = 0; i < c.columns + 1; i++ ) {
2294
+ cols = ( i === c.columns ?
2295
+ // 'all' columns can now include a range or set of columms ( data-column='0-2,4,6-7' )
2296
+ wo.filter_anyColumnSelector + ',' + wo.filter_multipleColumnSelector :
2297
+ '[data-column="' + i + '"]' );
2298
+ $column = $filters.filter( cols );
2299
+ if ( $column.length ) {
2300
+ // move the latest search to the first slot in the array
2301
+ $column = tsf.getLatestSearch( $column );
2302
+ if ( $.isArray( setFilters ) ) {
2303
+ // skip first ( latest input ) to maintain cursor position while typing
2304
+ if ( skipFirst && $column.length > 1 ) {
2305
+ $column = $column.slice( 1 );
2306
+ }
2307
+ if ( i === c.columns ) {
2308
+ // prevent data-column='all' from filling data-column='0,1' ( etc )
2309
+ cols = $column.filter( wo.filter_anyColumnSelector );
2310
+ $column = cols.length ? cols : $column;
2311
+ }
2312
+ $column
2313
+ .val( setFilters[ i ] )
2314
+ // must include a namespace here; but not c.namespace + 'filter'?
2315
+ .trigger( 'change' + c.namespace );
2316
+ } else {
2317
+ filters[i] = $column.val() || '';
2318
+ // don't change the first... it will move the cursor
2319
+ if ( i === c.columns ) {
2320
+ // don't update range columns from 'all' setting
2321
+ $column
2322
+ .slice( 1 )
2323
+ .filter( '[data-column*="' + $column.attr( 'data-column' ) + '"]' )
2324
+ .val( filters[ i ] );
2325
+ } else {
2326
+ $column
2327
+ .slice( 1 )
2328
+ .val( filters[ i ] );
2329
+ }
2330
+ }
2331
+ // save any match input dynamically
2332
+ if ( i === c.columns && $column.length ) {
2333
+ wo.filter_$anyMatch = $column;
2334
+ }
2335
+ }
2336
+ }
2337
+ }
2338
+ }
2339
+ return filters;
2340
+ };
2341
+
2342
+ ts.setFilters = function( table, filter, apply, skipFirst ) {
2343
+ var c = table ? $( table )[0].config : '',
2344
+ valid = ts.getFilters( table, true, filter, skipFirst );
2345
+ // default apply to "true"
2346
+ if ( typeof apply === 'undefined' ) {
2347
+ apply = true;
2348
+ }
2349
+ if ( c && apply ) {
2350
+ // ensure new set filters are applied, even if the search is the same
2351
+ c.lastCombinedFilter = null;
2352
+ c.lastSearch = [];
2353
+ tsf.searching( c.table, filter, skipFirst );
2354
+ c.$table.triggerHandler( 'filterFomatterUpdate' );
2355
+ }
2356
+ return valid.length !== 0;
2357
+ };
2358
+
2359
+ })( jQuery );
2360
+
2361
+ /*! Widget: stickyHeaders - updated 9/27/2017 (v2.29.0) *//*
2362
+ * Requires tablesorter v2.8+ and jQuery 1.4.3+
2363
+ * by Rob Garrison
2364
+ */
2365
+ ;(function ($, window) {
2366
+ 'use strict';
2367
+ var ts = $.tablesorter || {};
2368
+
2369
+ $.extend(ts.css, {
2370
+ sticky : 'tablesorter-stickyHeader', // stickyHeader
2371
+ stickyVis : 'tablesorter-sticky-visible',
2372
+ stickyHide: 'tablesorter-sticky-hidden',
2373
+ stickyWrap: 'tablesorter-sticky-wrapper'
2374
+ });
2375
+
2376
+ // Add a resize event to table headers
2377
+ ts.addHeaderResizeEvent = function(table, disable, settings) {
2378
+ table = $(table)[0]; // make sure we're using a dom element
2379
+ if ( !table.config ) { return; }
2380
+ var defaults = {
2381
+ timer : 250
2382
+ },
2383
+ options = $.extend({}, defaults, settings),
2384
+ c = table.config,
2385
+ wo = c.widgetOptions,
2386
+ checkSizes = function( triggerEvent ) {
2387
+ var index, headers, $header, sizes, width, height,
2388
+ len = c.$headers.length;
2389
+ wo.resize_flag = true;
2390
+ headers = [];
2391
+ for ( index = 0; index < len; index++ ) {
2392
+ $header = c.$headers.eq( index );
2393
+ sizes = $header.data( 'savedSizes' ) || [ 0, 0 ]; // fixes #394
2394
+ width = $header[0].offsetWidth;
2395
+ height = $header[0].offsetHeight;
2396
+ if ( width !== sizes[0] || height !== sizes[1] ) {
2397
+ $header.data( 'savedSizes', [ width, height ] );
2398
+ headers.push( $header[0] );
2399
+ }
2400
+ }
2401
+ if ( headers.length && triggerEvent !== false ) {
2402
+ c.$table.triggerHandler( 'resize', [ headers ] );
2403
+ }
2404
+ wo.resize_flag = false;
2405
+ };
2406
+ clearInterval(wo.resize_timer);
2407
+ if (disable) {
2408
+ wo.resize_flag = false;
2409
+ return false;
2410
+ }
2411
+ checkSizes( false );
2412
+ wo.resize_timer = setInterval(function() {
2413
+ if (wo.resize_flag) { return; }
2414
+ checkSizes();
2415
+ }, options.timer);
2416
+ };
2417
+
2418
+ function getStickyOffset(c, wo) {
2419
+ var $el = isNaN(wo.stickyHeaders_offset) ? $(wo.stickyHeaders_offset) : [];
2420
+ return $el.length ?
2421
+ $el.height() || 0 :
2422
+ parseInt(wo.stickyHeaders_offset, 10) || 0;
2423
+ }
2424
+
2425
+ // Sticky headers based on this awesome article:
2426
+ // http://css-tricks.com/13465-persistent-headers/
2427
+ // and https://github.com/jmosbech/StickyTableHeaders by Jonas Mosbech
2428
+ // **************************
2429
+ ts.addWidget({
2430
+ id: 'stickyHeaders',
2431
+ priority: 54, // sticky widget must be initialized after the filter & before pager widget!
2432
+ options: {
2433
+ stickyHeaders : '', // extra class name added to the sticky header row
2434
+ stickyHeaders_appendTo : null, // jQuery selector or object to phycially attach the sticky headers
2435
+ stickyHeaders_attachTo : null, // jQuery selector or object to attach scroll listener to (overridden by xScroll & yScroll settings)
2436
+ stickyHeaders_xScroll : null, // jQuery selector or object to monitor horizontal scroll position (defaults: xScroll > attachTo > window)
2437
+ stickyHeaders_yScroll : null, // jQuery selector or object to monitor vertical scroll position (defaults: yScroll > attachTo > window)
2438
+ stickyHeaders_offset : 0, // number or jquery selector targeting the position:fixed element
2439
+ stickyHeaders_filteredToTop: true, // scroll table top into view after filtering
2440
+ stickyHeaders_cloneId : '-sticky', // added to table ID, if it exists
2441
+ stickyHeaders_addResizeEvent : true, // trigger 'resize' event on headers
2442
+ stickyHeaders_includeCaption : true, // if false and a caption exist, it won't be included in the sticky header
2443
+ stickyHeaders_zIndex : 2 // The zIndex of the stickyHeaders, allows the user to adjust this to their needs
2444
+ },
2445
+ format: function(table, c, wo) {
2446
+ // filter widget doesn't initialize on an empty table. Fixes #449
2447
+ if ( c.$table.hasClass('hasStickyHeaders') || ($.inArray('filter', c.widgets) >= 0 && !c.$table.hasClass('hasFilters')) ) {
2448
+ return;
2449
+ }
2450
+ var index, len, $t,
2451
+ $table = c.$table,
2452
+ // add position: relative to attach element, hopefully it won't cause trouble.
2453
+ $attach = $(wo.stickyHeaders_attachTo || wo.stickyHeaders_appendTo),
2454
+ namespace = c.namespace + 'stickyheaders ',
2455
+ // element to watch for the scroll event
2456
+ $yScroll = $(wo.stickyHeaders_yScroll || wo.stickyHeaders_attachTo || window),
2457
+ $xScroll = $(wo.stickyHeaders_xScroll || wo.stickyHeaders_attachTo || window),
2458
+ $thead = $table.children('thead:first'),
2459
+ $header = $thead.children('tr').not('.sticky-false').children(),
2460
+ $tfoot = $table.children('tfoot'),
2461
+ stickyOffset = getStickyOffset(c, wo),
2462
+ // is this table nested? If so, find parent sticky header wrapper (div, not table)
2463
+ $nestedSticky = $table.parent().closest('.' + ts.css.table).hasClass('hasStickyHeaders') ?
2464
+ $table.parent().closest('table.tablesorter')[0].config.widgetOptions.$sticky.parent() : [],
2465
+ nestedStickyTop = $nestedSticky.length ? $nestedSticky.height() : 0,
2466
+ // clone table, then wrap to make sticky header
2467
+ $stickyTable = wo.$sticky = $table.clone()
2468
+ .addClass('containsStickyHeaders ' + ts.css.sticky + ' ' + wo.stickyHeaders + ' ' + c.namespace.slice(1) + '_extra_table' )
2469
+ .wrap('<div class="' + ts.css.stickyWrap + '">'),
2470
+ $stickyWrap = $stickyTable.parent()
2471
+ .addClass(ts.css.stickyHide)
2472
+ .css({
2473
+ position : $attach.length ? 'absolute' : 'fixed',
2474
+ padding : parseInt( $stickyTable.parent().parent().css('padding-left'), 10 ),
2475
+ top : stickyOffset + nestedStickyTop,
2476
+ left : 0,
2477
+ visibility : 'hidden',
2478
+ zIndex : wo.stickyHeaders_zIndex || 2
2479
+ }),
2480
+ $stickyThead = $stickyTable.children('thead:first'),
2481
+ $stickyCells,
2482
+ laststate = '',
2483
+ setWidth = function($orig, $clone) {
2484
+ var index, width, border, $cell, $this,
2485
+ $cells = $orig.filter(':visible'),
2486
+ len = $cells.length;
2487
+ for ( index = 0; index < len; index++ ) {
2488
+ $cell = $clone.filter(':visible').eq(index);
2489
+ $this = $cells.eq(index);
2490
+ // code from https://github.com/jmosbech/StickyTableHeaders
2491
+ if ($this.css('box-sizing') === 'border-box') {
2492
+ width = $this.outerWidth();
2493
+ } else {
2494
+ if ($cell.css('border-collapse') === 'collapse') {
2495
+ if (window.getComputedStyle) {
2496
+ width = parseFloat( window.getComputedStyle($this[0], null).width );
2497
+ } else {
2498
+ // ie8 only
2499
+ border = parseFloat( $this.css('border-width') );
2500
+ width = $this.outerWidth() - parseFloat( $this.css('padding-left') ) - parseFloat( $this.css('padding-right') ) - border;
2501
+ }
2502
+ } else {
2503
+ width = $this.width();
2504
+ }
2505
+ }
2506
+ $cell.css({
2507
+ 'width': width,
2508
+ 'min-width': width,
2509
+ 'max-width': width
2510
+ });
2511
+ }
2512
+ },
2513
+ getLeftPosition = function(yWindow) {
2514
+ if (yWindow === false && $nestedSticky.length) {
2515
+ return $table.position().left;
2516
+ }
2517
+ return $attach.length ?
2518
+ parseInt($attach.css('padding-left'), 10) || 0 :
2519
+ $table.offset().left - parseInt($table.css('margin-left'), 10) - $(window).scrollLeft();
2520
+ },
2521
+ resizeHeader = function() {
2522
+ $stickyWrap.css({
2523
+ left : getLeftPosition(),
2524
+ width: $table.outerWidth()
2525
+ });
2526
+ setWidth( $table, $stickyTable );
2527
+ setWidth( $header, $stickyCells );
2528
+ },
2529
+ scrollSticky = function( resizing ) {
2530
+ if (!$table.is(':visible')) { return; } // fixes #278
2531
+ // Detect nested tables - fixes #724
2532
+ nestedStickyTop = $nestedSticky.length ? $nestedSticky.offset().top - $yScroll.scrollTop() + $nestedSticky.height() : 0;
2533
+ var tmp,
2534
+ offset = $table.offset(),
2535
+ stickyOffset = getStickyOffset(c, wo),
2536
+ yWindow = $.isWindow( $yScroll[0] ), // $.isWindow needs jQuery 1.4.3
2537
+ yScroll = yWindow ?
2538
+ $yScroll.scrollTop() :
2539
+ // use parent sticky position if nested AND inside of a scrollable element - see #1512
2540
+ $nestedSticky.length ? parseInt($nestedSticky[0].style.top, 10) : $yScroll.offset().top,
2541
+ attachTop = $attach.length ? yScroll : $yScroll.scrollTop(),
2542
+ captionHeight = wo.stickyHeaders_includeCaption ? 0 : $table.children( 'caption' ).height() || 0,
2543
+ scrollTop = attachTop + stickyOffset + nestedStickyTop - captionHeight,
2544
+ tableHeight = $table.height() - ($stickyWrap.height() + ($tfoot.height() || 0)) - captionHeight,
2545
+ isVisible = ( scrollTop > offset.top ) && ( scrollTop < offset.top + tableHeight ) ? 'visible' : 'hidden',
2546
+ state = isVisible === 'visible' ? ts.css.stickyVis : ts.css.stickyHide,
2547
+ needsUpdating = !$stickyWrap.hasClass( state ),
2548
+ cssSettings = { visibility : isVisible };
2549
+ if ($attach.length) {
2550
+ // attached sticky headers always need updating
2551
+ needsUpdating = true;
2552
+ cssSettings.top = yWindow ? scrollTop - $attach.offset().top : $attach.scrollTop();
2553
+ }
2554
+ // adjust when scrolling horizontally - fixes issue #143
2555
+ tmp = getLeftPosition(yWindow);
2556
+ if (tmp !== parseInt($stickyWrap.css('left'), 10)) {
2557
+ needsUpdating = true;
2558
+ cssSettings.left = tmp;
2559
+ }
2560
+ cssSettings.top = ( cssSettings.top || 0 ) +
2561
+ // If nested AND inside of a scrollable element, only add parent sticky height
2562
+ (!yWindow && $nestedSticky.length ? $nestedSticky.height() : stickyOffset + nestedStickyTop);
2563
+ if (needsUpdating) {
2564
+ $stickyWrap
2565
+ .removeClass( ts.css.stickyVis + ' ' + ts.css.stickyHide )
2566
+ .addClass( state )
2567
+ .css(cssSettings);
2568
+ }
2569
+ if (isVisible !== laststate || resizing) {
2570
+ // make sure the column widths match
2571
+ resizeHeader();
2572
+ laststate = isVisible;
2573
+ }
2574
+ };
2575
+ // only add a position relative if a position isn't already defined
2576
+ if ($attach.length && !$attach.css('position')) {
2577
+ $attach.css('position', 'relative');
2578
+ }
2579
+ // fix clone ID, if it exists - fixes #271
2580
+ if ($stickyTable.attr('id')) { $stickyTable[0].id += wo.stickyHeaders_cloneId; }
2581
+ // clear out cloned table, except for sticky header
2582
+ // include caption & filter row (fixes #126 & #249) - don't remove cells to get correct cell indexing
2583
+ $stickyTable.find('> thead:gt(0), tr.sticky-false').hide();
2584
+ $stickyTable.find('> tbody, > tfoot').remove();
2585
+ $stickyTable.find('caption').toggle(wo.stickyHeaders_includeCaption);
2586
+ // issue #172 - find td/th in sticky header
2587
+ $stickyCells = $stickyThead.children().children();
2588
+ $stickyTable.css({ height:0, width:0, margin: 0 });
2589
+ // remove resizable block
2590
+ $stickyCells.find('.' + ts.css.resizer).remove();
2591
+ // update sticky header class names to match real header after sorting
2592
+ $table
2593
+ .addClass('hasStickyHeaders')
2594
+ .bind('pagerComplete' + namespace, function() {
2595
+ resizeHeader();
2596
+ });
2597
+
2598
+ ts.bindEvents(table, $stickyThead.children().children('.' + ts.css.header));
2599
+
2600
+ if (wo.stickyHeaders_appendTo) {
2601
+ $(wo.stickyHeaders_appendTo).append( $stickyWrap );
2602
+ } else {
2603
+ // add stickyheaders AFTER the table. If the table is selected by ID, the original one (first) will be returned.
2604
+ $table.after( $stickyWrap );
2605
+ }
2606
+
2607
+ // onRenderHeader is defined, we need to do something about it (fixes #641)
2608
+ if (c.onRenderHeader) {
2609
+ $t = $stickyThead.children('tr').children();
2610
+ len = $t.length;
2611
+ for ( index = 0; index < len; index++ ) {
2612
+ // send second parameter
2613
+ c.onRenderHeader.apply( $t.eq( index ), [ index, c, $stickyTable ] );
2614
+ }
2615
+ }
2616
+ // make it sticky!
2617
+ $xScroll.add($yScroll)
2618
+ .unbind( ('scroll resize '.split(' ').join( namespace )).replace(/\s+/g, ' ') )
2619
+ .bind('scroll resize '.split(' ').join( namespace ), function( event ) {
2620
+ scrollSticky( event.type === 'resize' );
2621
+ });
2622
+ c.$table
2623
+ .unbind('stickyHeadersUpdate' + namespace)
2624
+ .bind('stickyHeadersUpdate' + namespace, function() {
2625
+ scrollSticky( true );
2626
+ });
2627
+
2628
+ if (wo.stickyHeaders_addResizeEvent) {
2629
+ ts.addHeaderResizeEvent(table);
2630
+ }
2631
+
2632
+ // look for filter widget
2633
+ if ($table.hasClass('hasFilters') && wo.filter_columnFilters) {
2634
+ // scroll table into view after filtering, if sticky header is active - #482
2635
+ $table.bind('filterEnd' + namespace, function() {
2636
+ // $(':focus') needs jQuery 1.6+
2637
+ var $td = $(document.activeElement).closest('td'),
2638
+ column = $td.parent().children().index($td);
2639
+ // only scroll if sticky header is active
2640
+ if ($stickyWrap.hasClass(ts.css.stickyVis) && wo.stickyHeaders_filteredToTop) {
2641
+ // scroll to original table (not sticky clone)
2642
+ window.scrollTo(0, $table.position().top);
2643
+ // give same input/select focus; check if c.$filters exists; fixes #594
2644
+ if (column >= 0 && c.$filters) {
2645
+ c.$filters.eq(column).find('a, select, input').filter(':visible').focus();
2646
+ }
2647
+ }
2648
+ });
2649
+ ts.filter.bindSearch( $table, $stickyCells.find('.' + ts.css.filter) );
2650
+ // support hideFilters
2651
+ if (wo.filter_hideFilters) {
2652
+ ts.filter.hideFilters(c, $stickyTable);
2653
+ }
2654
+ }
2655
+
2656
+ // resize table (Firefox)
2657
+ if (wo.stickyHeaders_addResizeEvent) {
2658
+ $table.bind('resize' + c.namespace + 'stickyheaders', function() {
2659
+ resizeHeader();
2660
+ });
2661
+ }
2662
+
2663
+ // make sure sticky is visible if page is partially scrolled
2664
+ scrollSticky( true );
2665
+ $table.triggerHandler('stickyHeadersInit');
2666
+
2667
+ },
2668
+ remove: function(table, c, wo) {
2669
+ var namespace = c.namespace + 'stickyheaders ';
2670
+ c.$table
2671
+ .removeClass('hasStickyHeaders')
2672
+ .unbind( ('pagerComplete resize filterEnd stickyHeadersUpdate '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
2673
+ .next('.' + ts.css.stickyWrap).remove();
2674
+ if (wo.$sticky && wo.$sticky.length) { wo.$sticky.remove(); } // remove cloned table
2675
+ $(window)
2676
+ .add(wo.stickyHeaders_xScroll)
2677
+ .add(wo.stickyHeaders_yScroll)
2678
+ .add(wo.stickyHeaders_attachTo)
2679
+ .unbind( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') );
2680
+ ts.addHeaderResizeEvent(table, true);
2681
+ }
2682
+ });
2683
+
2684
+ })(jQuery, window);
2685
+
2686
+ /*! Widget: resizable - updated 2018-03-26 (v2.30.2) */
2687
+ /*jshint browser:true, jquery:true, unused:false */
2688
+ ;(function ($, window) {
2689
+ 'use strict';
2690
+ var ts = $.tablesorter || {};
2691
+
2692
+ $.extend(ts.css, {
2693
+ resizableContainer : 'tablesorter-resizable-container',
2694
+ resizableHandle : 'tablesorter-resizable-handle',
2695
+ resizableNoSelect : 'tablesorter-disableSelection',
2696
+ resizableStorage : 'tablesorter-resizable'
2697
+ });
2698
+
2699
+ // Add extra scroller css
2700
+ $(function() {
2701
+ var s = '<style>' +
2702
+ 'body.' + ts.css.resizableNoSelect + ' { -ms-user-select: none; -moz-user-select: -moz-none;' +
2703
+ '-khtml-user-select: none; -webkit-user-select: none; user-select: none; }' +
2704
+ '.' + ts.css.resizableContainer + ' { position: relative; height: 1px; }' +
2705
+ // make handle z-index > than stickyHeader z-index, so the handle stays above sticky header
2706
+ '.' + ts.css.resizableHandle + ' { position: absolute; display: inline-block; width: 8px;' +
2707
+ 'top: 1px; cursor: ew-resize; z-index: 3; user-select: none; -moz-user-select: none; }' +
2708
+ '</style>';
2709
+ $('head').append(s);
2710
+ });
2711
+
2712
+ ts.resizable = {
2713
+ init : function( c, wo ) {
2714
+ if ( c.$table.hasClass( 'hasResizable' ) ) { return; }
2715
+ c.$table.addClass( 'hasResizable' );
2716
+
2717
+ var noResize, $header, column, storedSizes, tmp,
2718
+ $table = c.$table,
2719
+ $parent = $table.parent(),
2720
+ marginTop = parseInt( $table.css( 'margin-top' ), 10 ),
2721
+
2722
+ // internal variables
2723
+ vars = wo.resizable_vars = {
2724
+ useStorage : ts.storage && wo.resizable !== false,
2725
+ $wrap : $parent,
2726
+ mouseXPosition : 0,
2727
+ $target : null,
2728
+ $next : null,
2729
+ overflow : $parent.css('overflow') === 'auto' ||
2730
+ $parent.css('overflow') === 'scroll' ||
2731
+ $parent.css('overflow-x') === 'auto' ||
2732
+ $parent.css('overflow-x') === 'scroll',
2733
+ storedSizes : []
2734
+ };
2735
+
2736
+ // set default widths
2737
+ ts.resizableReset( c.table, true );
2738
+
2739
+ // now get measurements!
2740
+ vars.tableWidth = $table.width();
2741
+ // attempt to autodetect
2742
+ vars.fullWidth = Math.abs( $parent.width() - vars.tableWidth ) < 20;
2743
+
2744
+ /*
2745
+ // Hacky method to determine if table width is set to 'auto'
2746
+ // http://stackoverflow.com/a/20892048/145346
2747
+ if ( !vars.fullWidth ) {
2748
+ tmp = $table.width();
2749
+ $header = $table.wrap('<span>').parent(); // temp variable
2750
+ storedSizes = parseInt( $table.css( 'margin-left' ), 10 ) || 0;
2751
+ $table.css( 'margin-left', storedSizes + 50 );
2752
+ vars.tableWidth = $header.width() > tmp ? 'auto' : tmp;
2753
+ $table.css( 'margin-left', storedSizes ? storedSizes : '' );
2754
+ $header = null;
2755
+ $table.unwrap('<span>');
2756
+ }
2757
+ */
2758
+
2759
+ if ( vars.useStorage && vars.overflow ) {
2760
+ // save table width
2761
+ ts.storage( c.table, 'tablesorter-table-original-css-width', vars.tableWidth );
2762
+ tmp = ts.storage( c.table, 'tablesorter-table-resized-width' ) || 'auto';
2763
+ ts.resizable.setWidth( $table, tmp, true );
2764
+ }
2765
+ wo.resizable_vars.storedSizes = storedSizes = ( vars.useStorage ?
2766
+ ts.storage( c.table, ts.css.resizableStorage ) :
2767
+ [] ) || [];
2768
+ ts.resizable.setWidths( c, wo, storedSizes );
2769
+ ts.resizable.updateStoredSizes( c, wo );
2770
+
2771
+ wo.$resizable_container = $( '<div class="' + ts.css.resizableContainer + '">' )
2772
+ .css({ top : marginTop })
2773
+ .insertBefore( $table );
2774
+ // add container
2775
+ for ( column = 0; column < c.columns; column++ ) {
2776
+ $header = c.$headerIndexed[ column ];
2777
+ tmp = ts.getColumnData( c.table, c.headers, column );
2778
+ noResize = ts.getData( $header, tmp, 'resizable' ) === 'false';
2779
+ if ( !noResize ) {
2780
+ $( '<div class="' + ts.css.resizableHandle + '">' )
2781
+ .appendTo( wo.$resizable_container )
2782
+ .attr({
2783
+ 'data-column' : column,
2784
+ 'unselectable' : 'on'
2785
+ })
2786
+ .data( 'header', $header )
2787
+ .bind( 'selectstart', false );
2788
+ }
2789
+ }
2790
+ ts.resizable.bindings( c, wo );
2791
+ },
2792
+
2793
+ updateStoredSizes : function( c, wo ) {
2794
+ var column, $header,
2795
+ len = c.columns,
2796
+ vars = wo.resizable_vars;
2797
+ vars.storedSizes = [];
2798
+ for ( column = 0; column < len; column++ ) {
2799
+ $header = c.$headerIndexed[ column ];
2800
+ vars.storedSizes[ column ] = $header.is(':visible') ? $header.width() : 0;
2801
+ }
2802
+ },
2803
+
2804
+ setWidth : function( $el, width, overflow ) {
2805
+ // overflow tables need min & max width set as well
2806
+ $el.css({
2807
+ 'width' : width,
2808
+ 'min-width' : overflow ? width : '',
2809
+ 'max-width' : overflow ? width : ''
2810
+ });
2811
+ },
2812
+
2813
+ setWidths : function( c, wo, storedSizes ) {
2814
+ var column, $temp,
2815
+ vars = wo.resizable_vars,
2816
+ $extra = $( c.namespace + '_extra_headers' ),
2817
+ $col = c.$table.children( 'colgroup' ).children( 'col' );
2818
+ storedSizes = storedSizes || vars.storedSizes || [];
2819
+ // process only if table ID or url match
2820
+ if ( storedSizes.length ) {
2821
+ for ( column = 0; column < c.columns; column++ ) {
2822
+ // set saved resizable widths
2823
+ ts.resizable.setWidth( c.$headerIndexed[ column ], storedSizes[ column ], vars.overflow );
2824
+ if ( $extra.length ) {
2825
+ // stickyHeaders needs to modify min & max width as well
2826
+ $temp = $extra.eq( column ).add( $col.eq( column ) );
2827
+ ts.resizable.setWidth( $temp, storedSizes[ column ], vars.overflow );
2828
+ }
2829
+ }
2830
+ $temp = $( c.namespace + '_extra_table' );
2831
+ if ( $temp.length && !ts.hasWidget( c.table, 'scroller' ) ) {
2832
+ ts.resizable.setWidth( $temp, c.$table.outerWidth(), vars.overflow );
2833
+ }
2834
+ }
2835
+ },
2836
+
2837
+ setHandlePosition : function( c, wo ) {
2838
+ var startPosition,
2839
+ tableHeight = c.$table.height(),
2840
+ $handles = wo.$resizable_container.children(),
2841
+ handleCenter = Math.floor( $handles.width() / 2 );
2842
+
2843
+ if ( ts.hasWidget( c.table, 'scroller' ) ) {
2844
+ tableHeight = 0;
2845
+ c.$table.closest( '.' + ts.css.scrollerWrap ).children().each(function() {
2846
+ var $this = $(this);
2847
+ // center table has a max-height set
2848
+ tableHeight += $this.filter('[style*="height"]').length ? $this.height() : $this.children('table').height();
2849
+ });
2850
+ }
2851
+
2852
+ if ( !wo.resizable_includeFooter && c.$table.children('tfoot').length ) {
2853
+ tableHeight -= c.$table.children('tfoot').height();
2854
+ }
2855
+ // subtract out table left position from resizable handles. Fixes #864
2856
+ // jQuery v3.3.0+ appears to include the start position with the $header.position().left; see #1544
2857
+ startPosition = parseFloat($.fn.jquery) >= 3.3 ? 0 : c.$table.position().left;
2858
+ $handles.each( function() {
2859
+ var $this = $(this),
2860
+ column = parseInt( $this.attr( 'data-column' ), 10 ),
2861
+ columns = c.columns - 1,
2862
+ $header = $this.data( 'header' );
2863
+ if ( !$header ) { return; } // see #859
2864
+ if (
2865
+ !$header.is(':visible') ||
2866
+ ( !wo.resizable_addLastColumn && ts.resizable.checkVisibleColumns(c, column) )
2867
+ ) {
2868
+ $this.hide();
2869
+ } else if ( column < columns || column === columns && wo.resizable_addLastColumn ) {
2870
+ $this.css({
2871
+ display: 'inline-block',
2872
+ height : tableHeight,
2873
+ left : $header.position().left - startPosition + $header.outerWidth() - handleCenter
2874
+ });
2875
+ }
2876
+ });
2877
+ },
2878
+
2879
+ // Fixes #1485
2880
+ checkVisibleColumns: function( c, column ) {
2881
+ var i,
2882
+ len = 0;
2883
+ for ( i = column + 1; i < c.columns; i++ ) {
2884
+ len += c.$headerIndexed[i].is( ':visible' ) ? 1 : 0;
2885
+ }
2886
+ return len === 0;
2887
+ },
2888
+
2889
+ // prevent text selection while dragging resize bar
2890
+ toggleTextSelection : function( c, wo, toggle ) {
2891
+ var namespace = c.namespace + 'tsresize';
2892
+ wo.resizable_vars.disabled = toggle;
2893
+ $( 'body' ).toggleClass( ts.css.resizableNoSelect, toggle );
2894
+ if ( toggle ) {
2895
+ $( 'body' )
2896
+ .attr( 'unselectable', 'on' )
2897
+ .bind( 'selectstart' + namespace, false );
2898
+ } else {
2899
+ $( 'body' )
2900
+ .removeAttr( 'unselectable' )
2901
+ .unbind( 'selectstart' + namespace );
2902
+ }
2903
+ },
2904
+
2905
+ bindings : function( c, wo ) {
2906
+ var namespace = c.namespace + 'tsresize';
2907
+ wo.$resizable_container.children().bind( 'mousedown', function( event ) {
2908
+ // save header cell and mouse position
2909
+ var column,
2910
+ vars = wo.resizable_vars,
2911
+ $extras = $( c.namespace + '_extra_headers' ),
2912
+ $header = $( event.target ).data( 'header' );
2913
+
2914
+ column = parseInt( $header.attr( 'data-column' ), 10 );
2915
+ vars.$target = $header = $header.add( $extras.filter('[data-column="' + column + '"]') );
2916
+ vars.target = column;
2917
+
2918
+ // if table is not as wide as it's parent, then resize the table
2919
+ vars.$next = event.shiftKey || wo.resizable_targetLast ?
2920
+ $header.parent().children().not( '.resizable-false' ).filter( ':last' ) :
2921
+ $header.nextAll( ':not(.resizable-false)' ).eq( 0 );
2922
+
2923
+ column = parseInt( vars.$next.attr( 'data-column' ), 10 );
2924
+ vars.$next = vars.$next.add( $extras.filter('[data-column="' + column + '"]') );
2925
+ vars.next = column;
2926
+
2927
+ vars.mouseXPosition = event.pageX;
2928
+ ts.resizable.updateStoredSizes( c, wo );
2929
+ ts.resizable.toggleTextSelection(c, wo, true );
2930
+ });
2931
+
2932
+ $( document )
2933
+ .bind( 'mousemove' + namespace, function( event ) {
2934
+ var vars = wo.resizable_vars;
2935
+ // ignore mousemove if no mousedown
2936
+ if ( !vars.disabled || vars.mouseXPosition === 0 || !vars.$target ) { return; }
2937
+ if ( wo.resizable_throttle ) {
2938
+ clearTimeout( vars.timer );
2939
+ vars.timer = setTimeout( function() {
2940
+ ts.resizable.mouseMove( c, wo, event );
2941
+ }, isNaN( wo.resizable_throttle ) ? 5 : wo.resizable_throttle );
2942
+ } else {
2943
+ ts.resizable.mouseMove( c, wo, event );
2944
+ }
2945
+ })
2946
+ .bind( 'mouseup' + namespace, function() {
2947
+ if (!wo.resizable_vars.disabled) { return; }
2948
+ ts.resizable.toggleTextSelection( c, wo, false );
2949
+ ts.resizable.stopResize( c, wo );
2950
+ ts.resizable.setHandlePosition( c, wo );
2951
+ });
2952
+
2953
+ // resizeEnd event triggered by scroller widget
2954
+ $( window ).bind( 'resize' + namespace + ' resizeEnd' + namespace, function() {
2955
+ ts.resizable.setHandlePosition( c, wo );
2956
+ });
2957
+
2958
+ // right click to reset columns to default widths
2959
+ c.$table
2960
+ .bind( 'columnUpdate pagerComplete resizableUpdate '.split( ' ' ).join( namespace + ' ' ), function() {
2961
+ ts.resizable.setHandlePosition( c, wo );
2962
+ })
2963
+ .bind( 'resizableReset' + namespace, function() {
2964
+ ts.resizableReset( c.table );
2965
+ })
2966
+ .find( 'thead:first' )
2967
+ .add( $( c.namespace + '_extra_table' ).find( 'thead:first' ) )
2968
+ .bind( 'contextmenu' + namespace, function() {
2969
+ // $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset
2970
+ var allowClick = wo.resizable_vars.storedSizes.length === 0;
2971
+ ts.resizableReset( c.table );
2972
+ ts.resizable.setHandlePosition( c, wo );
2973
+ wo.resizable_vars.storedSizes = [];
2974
+ return allowClick;
2975
+ });
2976
+
2977
+ },
2978
+
2979
+ mouseMove : function( c, wo, event ) {
2980
+ if ( wo.resizable_vars.mouseXPosition === 0 || !wo.resizable_vars.$target ) { return; }
2981
+ // resize columns
2982
+ var column,
2983
+ total = 0,
2984
+ vars = wo.resizable_vars,
2985
+ $next = vars.$next,
2986
+ tar = vars.storedSizes[ vars.target ],
2987
+ leftEdge = event.pageX - vars.mouseXPosition;
2988
+ if ( vars.overflow ) {
2989
+ if ( tar + leftEdge > 0 ) {
2990
+ vars.storedSizes[ vars.target ] += leftEdge;
2991
+ ts.resizable.setWidth( vars.$target, vars.storedSizes[ vars.target ], true );
2992
+ // update the entire table width
2993
+ for ( column = 0; column < c.columns; column++ ) {
2994
+ total += vars.storedSizes[ column ];
2995
+ }
2996
+ ts.resizable.setWidth( c.$table.add( $( c.namespace + '_extra_table' ) ), total );
2997
+ }
2998
+ if ( !$next.length ) {
2999
+ // if expanding right-most column, scroll the wrapper
3000
+ vars.$wrap[0].scrollLeft = c.$table.width();
3001
+ }
3002
+ } else if ( vars.fullWidth ) {
3003
+ vars.storedSizes[ vars.target ] += leftEdge;
3004
+ vars.storedSizes[ vars.next ] -= leftEdge;
3005
+ ts.resizable.setWidths( c, wo );
3006
+ } else {
3007
+ vars.storedSizes[ vars.target ] += leftEdge;
3008
+ ts.resizable.setWidths( c, wo );
3009
+ }
3010
+ vars.mouseXPosition = event.pageX;
3011
+ // dynamically update sticky header widths
3012
+ c.$table.triggerHandler('stickyHeadersUpdate');
3013
+ },
3014
+
3015
+ stopResize : function( c, wo ) {
3016
+ var vars = wo.resizable_vars;
3017
+ ts.resizable.updateStoredSizes( c, wo );
3018
+ if ( vars.useStorage ) {
3019
+ // save all column widths
3020
+ ts.storage( c.table, ts.css.resizableStorage, vars.storedSizes );
3021
+ ts.storage( c.table, 'tablesorter-table-resized-width', c.$table.width() );
3022
+ }
3023
+ vars.mouseXPosition = 0;
3024
+ vars.$target = vars.$next = null;
3025
+ // will update stickyHeaders, just in case, see #912
3026
+ c.$table.triggerHandler('stickyHeadersUpdate');
3027
+ c.$table.triggerHandler('resizableComplete');
3028
+ }
3029
+ };
3030
+
3031
+ // this widget saves the column widths if
3032
+ // $.tablesorter.storage function is included
3033
+ // **************************
3034
+ ts.addWidget({
3035
+ id: 'resizable',
3036
+ priority: 40,
3037
+ options: {
3038
+ resizable : true, // save column widths to storage
3039
+ resizable_addLastColumn : false,
3040
+ resizable_includeFooter: true,
3041
+ resizable_widths : [],
3042
+ resizable_throttle : false, // set to true (5ms) or any number 0-10 range
3043
+ resizable_targetLast : false
3044
+ },
3045
+ init: function(table, thisWidget, c, wo) {
3046
+ ts.resizable.init( c, wo );
3047
+ },
3048
+ format: function( table, c, wo ) {
3049
+ ts.resizable.setHandlePosition( c, wo );
3050
+ },
3051
+ remove: function( table, c, wo, refreshing ) {
3052
+ if (wo.$resizable_container) {
3053
+ var namespace = c.namespace + 'tsresize';
3054
+ c.$table.add( $( c.namespace + '_extra_table' ) )
3055
+ .removeClass('hasResizable')
3056
+ .children( 'thead' )
3057
+ .unbind( 'contextmenu' + namespace );
3058
+
3059
+ wo.$resizable_container.remove();
3060
+ ts.resizable.toggleTextSelection( c, wo, false );
3061
+ ts.resizableReset( table, refreshing );
3062
+ $( document ).unbind( 'mousemove' + namespace + ' mouseup' + namespace );
3063
+ }
3064
+ }
3065
+ });
3066
+
3067
+ ts.resizableReset = function( table, refreshing ) {
3068
+ $( table ).each(function() {
3069
+ var index, $t,
3070
+ c = this.config,
3071
+ wo = c && c.widgetOptions,
3072
+ vars = wo.resizable_vars;
3073
+ if ( table && c && c.$headerIndexed.length ) {
3074
+ // restore the initial table width
3075
+ if ( vars.overflow && vars.tableWidth ) {
3076
+ ts.resizable.setWidth( c.$table, vars.tableWidth, true );
3077
+ if ( vars.useStorage ) {
3078
+ ts.storage( table, 'tablesorter-table-resized-width', vars.tableWidth );
3079
+ }
3080
+ }
3081
+ for ( index = 0; index < c.columns; index++ ) {
3082
+ $t = c.$headerIndexed[ index ];
3083
+ if ( wo.resizable_widths && wo.resizable_widths[ index ] ) {
3084
+ ts.resizable.setWidth( $t, wo.resizable_widths[ index ], vars.overflow );
3085
+ } else if ( !$t.hasClass( 'resizable-false' ) ) {
3086
+ // don't clear the width of any column that is not resizable
3087
+ ts.resizable.setWidth( $t, '', vars.overflow );
3088
+ }
3089
+ }
3090
+
3091
+ // reset stickyHeader widths
3092
+ c.$table.triggerHandler( 'stickyHeadersUpdate' );
3093
+ if ( ts.storage && !refreshing ) {
3094
+ ts.storage( this, ts.css.resizableStorage, [] );
3095
+ }
3096
+ }
3097
+ });
3098
+ };
3099
+
3100
+ })( jQuery, window );
3101
+
3102
+ /*! Widget: saveSort - updated 2018-03-19 (v2.30.1) *//*
3103
+ * Requires tablesorter v2.16+
3104
+ * by Rob Garrison
3105
+ */
3106
+ ;(function ($) {
3107
+ 'use strict';
3108
+ var ts = $.tablesorter || {};
3109
+
3110
+ function getStoredSortList(c) {
3111
+ var stored = ts.storage( c.table, 'tablesorter-savesort' );
3112
+ return (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : [];
3113
+ }
3114
+
3115
+ function sortListChanged(c, sortList) {
3116
+ return (sortList || getStoredSortList(c)).join(',') !== c.sortList.join(',');
3117
+ }
3118
+
3119
+ // this widget saves the last sort only if the
3120
+ // saveSort widget option is true AND the
3121
+ // $.tablesorter.storage function is included
3122
+ // **************************
3123
+ ts.addWidget({
3124
+ id: 'saveSort',
3125
+ priority: 20,
3126
+ options: {
3127
+ saveSort : true
3128
+ },
3129
+ init: function(table, thisWidget, c, wo) {
3130
+ // run widget format before all other widgets are applied to the table
3131
+ thisWidget.format(table, c, wo, true);
3132
+ },
3133
+ format: function(table, c, wo, init) {
3134
+ var time,
3135
+ $table = c.$table,
3136
+ saveSort = wo.saveSort !== false, // make saveSort active/inactive; default to true
3137
+ sortList = { 'sortList' : c.sortList },
3138
+ debug = ts.debug(c, 'saveSort');
3139
+ if (debug) {
3140
+ time = new Date();
3141
+ }
3142
+ if ($table.hasClass('hasSaveSort')) {
3143
+ if (saveSort && table.hasInitialized && ts.storage && sortListChanged(c)) {
3144
+ ts.storage( table, 'tablesorter-savesort', sortList );
3145
+ if (debug) {
3146
+ console.log('saveSort >> Saving last sort: ' + c.sortList + ts.benchmark(time));
3147
+ }
3148
+ }
3149
+ } else {
3150
+ // set table sort on initial run of the widget
3151
+ $table.addClass('hasSaveSort');
3152
+ sortList = '';
3153
+ // get data
3154
+ if (ts.storage) {
3155
+ sortList = getStoredSortList(c);
3156
+ if (debug) {
3157
+ console.log('saveSort >> Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
3158
+ }
3159
+ $table.bind('saveSortReset', function(event) {
3160
+ event.stopPropagation();
3161
+ ts.storage( table, 'tablesorter-savesort', '' );
3162
+ });
3163
+ }
3164
+ // init is true when widget init is run, this will run this widget before all other widgets have initialized
3165
+ // this method allows using this widget in the original tablesorter plugin; but then it will run all widgets twice.
3166
+ if (init && sortList && sortList.length > 0) {
3167
+ c.sortList = sortList;
3168
+ } else if (table.hasInitialized && sortList && sortList.length > 0) {
3169
+ // update sort change
3170
+ if (sortListChanged(c, sortList)) {
3171
+ ts.sortOn(c, sortList);
3172
+ }
3173
+ }
3174
+ }
3175
+ },
3176
+ remove: function(table, c) {
3177
+ c.$table.removeClass('hasSaveSort');
3178
+ // clear storage
3179
+ if (ts.storage) { ts.storage( table, 'tablesorter-savesort', '' ); }
3180
+ }
3181
+ });
3182
+
3183
+ })(jQuery);
3184
+ return jQuery.tablesorter;}));
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Contact Form Entries ===
2
  Contributors: crmperks, sbazzi
3
- Tags: contact form 7, contact form 7 database, contact form db, save contact form, contact form 7 entries
4
  Requires at least: 3.8
5
  Tested up to: 5.4
6
- Stable tag: 1.1.0
7
- Version: 1.1.0
8
  Requires PHP: 5.3
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -66,7 +66,8 @@ You can add notes to any contact form entry and you can edit old notes. Also you
66
  <p><strong>Premium Version Features.</strong></p>
67
  <p>Following features are available in premium add-ons <a href="https://www.crmperks.com/plugins/contact-form-plugins/crm-forms/?utm_source=wordpress&utm_medium=directory&utm_campaign=readme">Get all add-ons and CRM Perks forms</a>.</p>
68
  <ul>
69
- <li>Compare daily entries, visitors and partial entries in graphical forms.</li>
 
70
  <li>Google Analytics Parameters and Geolocation of a visitor who submitted the form.</li>
71
  <li>Lookup lead's email and phone using email and phone lookup apis.</li>
72
  <li>20+ premium add-ons</li>
@@ -147,6 +148,13 @@ Yes, You can search contact form 7 submissions by a specific field or all fields
147
 
148
  You can select this in plugin settings.
149
 
 
 
 
 
 
 
 
150
  = Contact form advanced database =
151
 
152
  This contact form entries plugin not only saves contact form submissions, it has more advanced features like
@@ -166,6 +174,12 @@ This contact form entries plugin not only saves contact form submissions, it has
166
  * in wordpress go to "CRM Entries" menu then select your form, plugin will show all entries in table form.
167
  * you can star or Un-star any entry.
168
 
 
 
 
 
 
 
169
 
170
  = How can i display contact form entries on front end =
171
 
@@ -175,6 +189,12 @@ You can display entries on front end with a simple shotcode available in setting
175
 
176
  from main wordpress menu select "CRM Entries" then you can view any entry.
177
 
 
 
 
 
 
 
178
  = CRM Entries Plugin =
179
 
180
  When anyone submits a form on your site, plugin saves it in wordpress data. You can send it to CRM of your choice with our 20+ crm extensions.
@@ -197,6 +217,9 @@ Contact form 7 entries plugin allows you to save contact form 7 entries to local
197
 
198
  == Changelog ==
199
 
 
 
 
200
  = 1.1.0 =
201
  * fixed "source and screen fields in csv file".
202
  * fixed "multiple empty tables issue on same page".
1
  === Contact Form Entries ===
2
  Contributors: crmperks, sbazzi
3
+ Tags: contact form 7, contact form 7 database, contact form db, save contact form, wpforms database
4
  Requires at least: 3.8
5
  Tested up to: 5.4
6
+ Stable tag: 1.1.1
7
+ Version: 1.1.1
8
  Requires PHP: 5.3
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
66
  <p><strong>Premium Version Features.</strong></p>
67
  <p>Following features are available in premium add-ons <a href="https://www.crmperks.com/plugins/contact-form-plugins/crm-forms/?utm_source=wordpress&utm_medium=directory&utm_campaign=readme">Get all add-ons and CRM Perks forms</a>.</p>
68
  <ul>
69
+ <li>Don't miss out on any potential leads. Collect data in real time as it is entered on your forms.</li>
70
+ <li>Search field and Download CSV button for front end entries table.</li>
71
  <li>Google Analytics Parameters and Geolocation of a visitor who submitted the form.</li>
72
  <li>Lookup lead's email and phone using email and phone lookup apis.</li>
73
  <li>20+ premium add-ons</li>
148
 
149
  You can select this in plugin settings.
150
 
151
+ = WP Forms database =
152
+
153
+ * Simply install our Contact form entries plugin.
154
+ * Submit any wp form, it will saved in wordpress database.
155
+ * You can view and edit any entry in wordpress.
156
+ * Add Notes and send emails to any entry from wordpress.
157
+
158
  = Contact form advanced database =
159
 
160
  This contact form entries plugin not only saves contact form submissions, it has more advanced features like
174
  * in wordpress go to "CRM Entries" menu then select your form, plugin will show all entries in table form.
175
  * you can star or Un-star any entry.
176
 
177
+ = WPforms database addon =
178
+
179
+ * Save all WPforms submissions in wordpress database.
180
+ * View and edit any entry in wordpress.
181
+ * Display WPforms entries from database to front end on any wordpress page.
182
+
183
 
184
  = How can i display contact form entries on front end =
185
 
189
 
190
  from main wordpress menu select "CRM Entries" then you can view any entry.
191
 
192
+ = WPforms save to database =
193
+
194
+ * Install our entries plugin for saving WPforms submissions to database.
195
+ * Plugin automatically saves all WPforms entries in wordpress database.
196
+ * You can add notes and send emails to WPforms entries.
197
+
198
  = CRM Entries Plugin =
199
 
200
  When anyone submits a form on your site, plugin saves it in wordpress data. You can send it to CRM of your choice with our 20+ crm extensions.
217
 
218
  == Changelog ==
219
 
220
+ = 1.1.1 =
221
+ * fixed "per-page" option in front end entries table.
222
+
223
  = 1.1.0 =
224
  * fixed "source and screen fields in csv file".
225
  * fixed "multiple empty tables issue on same page".
templates/leads-table.php CHANGED
@@ -2,6 +2,15 @@
2
  if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  }
 
 
 
 
 
 
 
 
 
5
  ?>
6
  <table <?php echo $class.' '.$css ?> cellspacing="0" <?php echo $table_id ?>>
7
  <thead>
@@ -137,12 +146,25 @@ $field_label= date('M-d-Y H:i:s',$field_label);
137
  $table=$('.vx_entries_table');
138
 
139
  $table.tablesorter({
140
- //widgets : ['zebra', 'columns'],
141
  // theme : 'blue',
142
- usNumberFormat : false,
 
 
 
 
 
 
 
 
 
 
 
143
  sortReset : true,
144
  sortRestart : true
145
  });
 
 
146
  <?php
147
  if(!empty($atts['pager'])){
148
  ?>
@@ -164,6 +186,7 @@ $field_label= date('M-d-Y H:i:s',$field_label);
164
  <?php
165
  }
166
  ?>
 
167
  //////
168
  });
169
  </script>
@@ -171,11 +194,17 @@ $field_label= date('M-d-Y H:i:s',$field_label);
171
  }
172
  ?>
173
  <style type="text/css">
 
 
 
174
  /* pager wrapper, div */
175
  .vx_pager {
176
  padding: 5px;
177
  }
178
-
 
 
 
179
  /* pager navigation arrows */
180
  .vx_pager img {
181
  vertical-align: middle;
@@ -208,6 +237,9 @@ $field_label= date('M-d-Y H:i:s',$field_label);
208
  margin: 0;
209
  padding: 0;
210
  }
 
 
 
211
  .tablesorter-default .header,
212
  .tablesorter-default .tablesorter-header {
213
  background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
2
  if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  }
5
+ if(!empty($search)){
6
+ ?>
7
+ <p class="vx_table_actions">
8
+ <input type="search" placeholder="<?php _e('Search', 'contact-form-entries'); ?>" data-column="all" class="vx_search">
9
+ <?php
10
+ if(!empty($export)){ ?><a class="vx_export_btn" href="?vx_crm_form_action=download_csv&vx_crm_key=<?php echo $export ?>"><?php _e('Download CSV', 'contact-form-entries'); ?></a> <?php } ?>
11
+ </p>
12
+ <?php
13
+ }
14
  ?>
15
  <table <?php echo $class.' '.$css ?> cellspacing="0" <?php echo $table_id ?>>
16
  <thead>
146
  $table=$('.vx_entries_table');
147
 
148
  $table.tablesorter({
149
+
150
  // theme : 'blue',
151
+ <?php
152
+ if(!empty($search)){
153
+ ?>
154
+ widgets : ['filter'],
155
+ widgetOptions : {
156
+ filter_external : '.vx_search',
157
+ filter_columnFilters: false,
158
+ filter_searchDelay : 100,
159
+ filter_hideEmpty : true,
160
+ },
161
+ <?php } ?>
162
+ usNumberFormat : false,
163
  sortReset : true,
164
  sortRestart : true
165
  });
166
+
167
+ /// $.tablesorter.filter.bindSearch( $table, $('#vx_search') );
168
  <?php
169
  if(!empty($atts['pager'])){
170
  ?>
186
  <?php
187
  }
188
  ?>
189
+
190
  //////
191
  });
192
  </script>
194
  }
195
  ?>
196
  <style type="text/css">
197
+ .vx_export_btn{
198
+ float: right;
199
+ }
200
  /* pager wrapper, div */
201
  .vx_pager {
202
  padding: 5px;
203
  }
204
+ .vx_entries_table{
205
+ display: block;
206
+ overflow: auto;
207
+ }
208
  /* pager navigation arrows */
209
  .vx_pager img {
210
  vertical-align: middle;
237
  margin: 0;
238
  padding: 0;
239
  }
240
+ .tablesorter .filtered {
241
+ display: none;
242
+ }
243
  .tablesorter-default .header,
244
  .tablesorter-default .tablesorter-header {
245
  background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
templates/settings.php CHANGED
@@ -212,6 +212,8 @@ foreach($forms_arr as $k=>$v){
212
 
213
  <li><code>pager</code> - <?php _e('If it is sortable, the table is also able to be paginated (e.g., pager="1")', 'contact-form-entries'); ?></li>
214
  <li><code>user-id</code> - <?php _e('show entries from specific user id , leave empty for logged in user (e.g., user-id="2" , user-id="")', 'contact-form-entries'); ?></li>
 
 
215
 
216
  <li> <p><strong><?php _e('Get ShortCode', 'contact-form-entries'); ?></strong></p>
217
  <p>
212
 
213
  <li><code>pager</code> - <?php _e('If it is sortable, the table is also able to be paginated (e.g., pager="1")', 'contact-form-entries'); ?></li>
214
  <li><code>user-id</code> - <?php _e('show entries from specific user id , leave empty for logged in user (e.g., user-id="2" , user-id="")', 'contact-form-entries'); ?></li>
215
+ <li><code>search</code> - <?php _e('Add search table field - premium feature (e.g., search="1")', 'contact-form-entries'); ?></li>
216
+ <li><code>export</code> - <?php _e('Add search table field - premium feature (e.g., export="1")', 'contact-form-entries'); ?></li>
217
 
218
  <li> <p><strong><?php _e('Get ShortCode', 'contact-form-entries'); ?></strong></p>
219
  <p>
wp/crmperks-notices.php CHANGED
@@ -237,6 +237,7 @@ color: #727f30; font-size: 18px; vertical-align: middle;
237
  <div class="updated below-h2 vx_pro_version" style="border-left-color: #1192C1; margin: 30px 20px 30px 0px">
238
  <h2>Premium Version</h2>
239
  <p><i class="fa fa-check"></i> Don't miss out on any potential leads. Collect data in real time as it is entered on your forms.</p>
 
240
  <p><i class="fa fa-check"></i> Compare daily entries, visitors and partial entries in graphical forms.</p>
241
  <p><i class="fa fa-check"></i> Google Analytics Parameters and Geolocation of a visitor who submitted the form.</p>
242
  <p><i class="fa fa-check"></i> Lead Scoring.</p>
237
  <div class="updated below-h2 vx_pro_version" style="border-left-color: #1192C1; margin: 30px 20px 30px 0px">
238
  <h2>Premium Version</h2>
239
  <p><i class="fa fa-check"></i> Don't miss out on any potential leads. Collect data in real time as it is entered on your forms.</p>
240
+ <p><i class="fa fa-check"></i> Search field and Download CSV button for front end entries table.</p>
241
  <p><i class="fa fa-check"></i> Compare daily entries, visitors and partial entries in graphical forms.</p>
242
  <p><i class="fa fa-check"></i> Google Analytics Parameters and Geolocation of a visitor who submitted the form.</p>
243
  <p><i class="fa fa-check"></i> Lead Scoring.</p>