Page Visit Counter - Version 2.0.0

Version Description

Automatic updates should work great for you. As always, though, we recommend backing up your site prior to making any updates just to be sure nothing goes wrong.

Download this release

Release Info

Developer dots
Plugin Icon 128x128 Page Visit Counter
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.1.3 to 2.0.0

README.txt CHANGED
@@ -4,7 +4,7 @@ Plugin URI: http://multidots.com/
4
  Author: Multidots
5
  Author URI: http://multidots.com/
6
  Contributors: dots
7
- Stable tag: 1.1.3
8
  Tags: page counter,page visit
9
  Requires at least: 2.1
10
  Tested up to: 4.4.2
@@ -19,7 +19,6 @@ This plugin will count the total visits of your sites pages.
19
  This Plugin use for front side post and pages counter. After activation of plugin it will automatically add page counts on bottom of all pages. So, that all visitors can see page counts for entire site pages. Plugin provide search by page title and search by page published date facilities. Settings are required for page counter. Plugin provide to select specific post type to include in post /pages counter. Plugin also provide to exclude specific IP/s and specific register user to exude from post/pages counter.
20
 
21
  = Page Counter Settings: =
22
-
23
  * In these options you can do different setting for page visit counter.
24
  * Short Code: There are two shortcuts that you can use to manually add page view count to any content on admin or post/page template created by your theme or plugin that's creating its own display content in a page / post.
25
  * Post Type: You can select the post type from the drop down menu for which post views will be counted. If you leave blank on post type, then all pages or all past type posts will be counted.
@@ -90,4 +89,9 @@ Automatic updates should work great for you. As always, though, we recommend ba
90
  * Fixes - PHP error notice handled.
91
  * Fixes - SSL issue resolved.
92
  * Fixes - Admin Menu Page issue resolved.
93
- * New - Readme file added instructions.
 
 
 
 
 
4
  Author: Multidots
5
  Author URI: http://multidots.com/
6
  Contributors: dots
7
+ Stable tag: 2.0.0
8
  Tags: page counter,page visit
9
  Requires at least: 2.1
10
  Tested up to: 4.4.2
19
  This Plugin use for front side post and pages counter. After activation of plugin it will automatically add page counts on bottom of all pages. So, that all visitors can see page counts for entire site pages. Plugin provide search by page title and search by page published date facilities. Settings are required for page counter. Plugin provide to select specific post type to include in post /pages counter. Plugin also provide to exclude specific IP/s and specific register user to exude from post/pages counter.
20
 
21
  = Page Counter Settings: =
 
22
  * In these options you can do different setting for page visit counter.
23
  * Short Code: There are two shortcuts that you can use to manually add page view count to any content on admin or post/page template created by your theme or plugin that's creating its own display content in a page / post.
24
  * Post Type: You can select the post type from the drop down menu for which post views will be counted. If you leave blank on post type, then all pages or all past type posts will be counted.
89
  * Fixes - PHP error notice handled.
90
  * Fixes - SSL issue resolved.
91
  * Fixes - Admin Menu Page issue resolved.
92
+ * New - Readme file added instructions.
93
+
94
+ = 2.0.0 - 23.02.2016 =
95
+ * New - Exclude custom post type from Page / Post visit counter.
96
+ * New - Eclude Specific IP and Registered Users from Page / Post visit Counter.
97
+ * New - Display page visit count on bottom of page on entire site.
admin/class-page-visit-counter-admin.php CHANGED
@@ -75,6 +75,7 @@ class page_visit_counter_Admin {
75
  wp_enqueue_style('custom-style', plugin_dir_url( __FILE__ ) . 'css/style.css');
76
  wp_enqueue_style('datatable-style', plugin_dir_url( __FILE__ ) . 'css/jquery.dataTables.css');
77
  wp_enqueue_style('jquery-style', plugin_dir_url( __FILE__ ) . 'css/jquery-ui.css');
 
78
 
79
  }
80
 
@@ -101,8 +102,26 @@ class page_visit_counter_Admin {
101
 
102
  wp_enqueue_script('one', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), $this->version, false );
103
 
 
 
 
104
  wp_localize_script( 'one', 'pagevisit', array('ajaxurl' => admin_url( 'admin-ajax.php')));
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  }
 
 
106
  /**
107
  * admin menu page fnction
108
  * add menu in admin menubar.
@@ -121,6 +140,28 @@ class page_visit_counter_Admin {
121
  $html ='';
122
  $html .='<div class="main-page-visit">';
123
  $html .='<div class="page-title"><h1>Page Visit Counter</h1></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  $html .='<div class="page-input-text">';
125
  $html .='<form method="POST">';
126
  $html .='<input type="text" name="pagesearchtext" id="page-search-text" placeholder="Search by page title"><input type="text" id="MyDate" class="pagedateselect" name="MyDate" value="" placeholder="Search by page date"/><a href="javascript:void(0);" id="search-submit" class="button">Search Page</a>';
@@ -135,29 +176,25 @@ class page_visit_counter_Admin {
135
  <th>Page Title</th>
136
  <th width="20%">Total Count</th>
137
  </tr></thead><tbody>';
138
- $postperpage = -1;
139
- $args = array(
140
- 'post_type' => 'page',
141
- 'post_status' => 'publish',
142
- 'order' => 'ASC',
143
- 'posts_per_page' => $postperpage,
144
- );
145
- $posts_array = get_posts( $args );
146
  $counter = 0;
147
- foreach ($posts_array as $results){
148
- $counter = $counter + 1;
149
- $html .='<tr>';
150
- $html .='<td>'.$counter.'</td>';
151
- $html .='<td>'.$results->ID.'</td>';
152
- $html .='<td><a href="'.get_admin_url().'post.php?post='.$results->ID.'&action=edit">'.$results->post_title.'</a></td>';
153
- $count_visit = $wpdb->get_results("SELECT * from $table_name where page_id ='".$results->ID."'");
154
- $count = 0;
155
- foreach ( $count_visit as $countval){
156
- $count = $count + 1;
157
- }
158
- $html .='<td>'.$count.'</td>';
 
 
159
  $html .='</tr>';
160
- }
 
161
  $html .='</tbody><tfoot>
162
  <tr>
163
  <th width="10%">No</th>
@@ -175,57 +212,85 @@ class page_visit_counter_Admin {
175
  */
176
  function custom_page_visit_settings( $args ) {
177
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  $html ='';
179
  $html .='<div class="main-page-visit-settings">';
180
  $html .='<div class="page-title-settings"><h1>Page Counter Settings</h1></div>';
181
- $html .='<div class="page-title-settings">
182
- <p><strong>Instructions:</strong><br></p>
183
- <p>Page Count Options</p>
184
- <p><span>In this options you can select the specific duration of pages counter for the visitor IP Address.</span></p>
185
- <p><span>Example:</span><br>
186
- <p><span>If you have choose the options as a Day then It will count as per given Day in Counter Duration field. So, If visitor has visit your site page today and you have set Counter Duration field : 1 then it will add +1 visit using visitor IP Address. If visitior regularly visit same page every day then it will add every day +1 visit. So it will work based on Counter Duration you have specified.</span><br>
187
- <p><span>If you have choose the options as a Week then It will count as per given Week in Counter Duration field. So, If visitor has visit your site page today and you have set Counter Duration field : 1 then it will add +1 visit using visitor IP Address. If visitior weekly visit same page every week then it will add every week +1 visit. So it will work based on Counter Duration you have specified.</span><br>
188
- <p><span>If you have choose the options as a Month then It will count as per given Month in Counter Duration field. So, If visitor has visit your site page today and you have set Counter Duration field : 1 then it will add +1 visit using visitor IP Address. If visitior montly visit same page every month then it will add every month +1 visit. So it will work based on Counter Duration you have specified.</span><br>
189
- <p><span>If you have choose the options as a Year then It will count as per given Year in Counter Duration field. So, If visitor has visit your site page today and you have set Counter Duration field : 1 then it will add +1 visit using visitor IP Address. If visitior yearly visit same page every year then it will add every year +1 visit. So it will work based on Counter Duration you have specified.</span><br>
190
- </p>
191
- <p><strong>Counter Duration</strong></p>
192
- <p>
193
- <span>In this option you can specify only numeric value for the calculate page visit of visitors.</span><br>
194
- </p>
195
- <p>If Admin user logged-in into the site and hit any page into the same browser then we are not accepting that page to increase page visit of this particular page. We are increment the page visit based on visitor IP Address.</p>
196
-
197
 
198
- </div>';
199
  $html .='<div class="page-settings-summery">';
200
  $html .='<form method="POST">';
201
  $get_option_value = json_decode(get_option( 'page_count_settings' ));
202
  $input_values = isset( $get_option_value[1] ) ? $get_option_value[1] : array();
203
  $select_values = isset($get_option_value[0] ) ? $get_option_value[0] : array();
204
  $html .='<table border="0" cellpadding="10" cellspacing="0">';
205
- $html .='<tr>';
206
- $html .='<td>Page Count Options : </td>';
207
- $html .='<td>';
208
- $html .='<select id="page-setting-options" name="page-setting-options">
209
- <option value="">Select page Options</option>
210
- <option value="day" '.($get_option_value[0] == 'day' ? 'selected' : '').'>Day</option>
211
- <option value="week" '.($get_option_value[0] == 'week' ? 'selected' : '').'>Week</option>
212
- <option value="month" '.($get_option_value[0] == 'month' ? 'selected' : '').'>Month</option>
213
- <option value="year" '.($get_option_value[0] == 'year' ? 'selected' : '').'>Year</option>
214
- </select>';
215
- $html .='</td>';
216
- $html .='</tr>';
217
- $html .='<tr>';
218
- $html .='<td class="countduration" '.($get_option_value[1] == '' ? 'style="display:none;"' : 'style="display:block;"').'>Counter Duration : </td>';
219
- $html .='<td>';
220
- $html .='<input type="text" name="countduration" id="pagecountduration" '.($get_option_value[1] == '' ? 'style="display:none;"' : 'style="display:block;"').' value="'.($get_option_value[1] == '' ? '' : $get_option_value[1]).'"/>';
221
- $html .='</td>';
222
- $html .='</tr>';
223
- $html .='<tr>';
224
- $html .='<td><input type="button" name="submit" '.($get_option_value[1] == '' ? 'style="display:none;"' : 'style="display:block;"').' class="pagecountsubmit button" value="Save"></td>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  $html .='<td class="record-mesage"></td>';
226
  $html .='</tr>';
227
  $html .='<table>';
228
  $html .='</form>';
 
 
 
 
 
 
229
  $html .='</div>';
230
  $html .="<br>";
231
  $html .='</div>';
@@ -245,7 +310,7 @@ class page_visit_counter_Admin {
245
  global $wpdb;
246
  $table_name = $wpdb->prefix."page_visit";
247
  $html ='';
248
- $count_visit = $wpdb->get_results("SELECT page_id,id,count(page_id) as c from $table_name group by page_id order by c DESC limit 5");
249
  $html .='<div class="main_custom_dashboard_visit_page">';
250
  if (!empty($count_visit) && isset($count_visit)) {
251
  $html .='<table border="0" cellpadding="5" cellspacing="10">';
@@ -279,13 +344,30 @@ class page_visit_counter_Admin {
279
  */
280
  public function add_page_count_option(){
281
  global $wpdb;
282
- if( $_POST['select_option'] != '' && !empty($_POST['select_option']) && $_POST['count_duration'] != '' && !empty($_POST['count_duration']) ){
283
- $page_count_option = array();
284
- $page_count_option[] = isset( $_POST['select_option'] ) ? $_POST['select_option'] : '';
285
- $page_count_option[] = isset( $_POST['count_duration'] ) ? $_POST['count_duration'] : '';
286
- delete_option('page_count_settings');
287
- add_option( 'page_count_settings', json_encode( $page_count_option ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  }
 
 
 
289
  die();
290
  }
291
 
@@ -332,7 +414,12 @@ class page_visit_counter_Admin {
332
  foreach ( $count_visit as $countval){
333
  $count = $count + 1;
334
  }
335
- $html .='<td>'.$count.'</td>';
 
 
 
 
 
336
  $html .='</tr>';
337
  }
338
  $html .='</tbody>
@@ -421,12 +508,16 @@ class page_visit_counter_Admin {
421
  }
422
  }
423
  $remove = rtrim($str," AND ");
424
- $count_visit = $wpdb->get_results("SELECT * from $table_name where page_id ='".$results->ID."' AND $remove");
425
- $count = 0;
426
- foreach ( $count_visit as $countval ){
427
- $count = $count + 1;
 
 
428
  }
429
- $html .='<td>'. $count.'</td>';
 
 
430
  $html .='</tr>';
431
  }
432
  $html .='</tbody><tfoot>
@@ -442,7 +533,64 @@ class page_visit_counter_Admin {
442
  die();
443
  }
444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  }
 
446
  /**
447
  * The Widget functionality for this plugin.
448
  * widget provide Most visited page.
@@ -463,7 +611,7 @@ class My_Widget extends WP_Widget {
463
  $html .= (isset($before_widget)?$before_widget:'');
464
  if (!empty($title))
465
  $html .= $before_title . $title . $after_title;
466
- $count_visit = $wpdb->get_results("SELECT page_id,id,count(page_id) as c from $table_name group by page_id order by c DESC limit 5");
467
  foreach ($count_visit as $visitpage ){
468
  $page = get_post($visitpage->page_id);
469
  $html .='<h6 style="font-size: 14px;font-weight: normal;line-height: 14px;">'.$page->post_title.'</h6>';
75
  wp_enqueue_style('custom-style', plugin_dir_url( __FILE__ ) . 'css/style.css');
76
  wp_enqueue_style('datatable-style', plugin_dir_url( __FILE__ ) . 'css/jquery.dataTables.css');
77
  wp_enqueue_style('jquery-style', plugin_dir_url( __FILE__ ) . 'css/jquery-ui.css');
78
+ wp_enqueue_style('chosen-style', plugin_dir_url( __FILE__ ) . 'css/chosen.css');
79
 
80
  }
81
 
102
 
103
  wp_enqueue_script('one', plugin_dir_url( __FILE__ ) . 'js/custom.js', array( 'jquery' ), $this->version, false );
104
 
105
+ wp_enqueue_script('chosen-jquery', plugin_dir_url( __FILE__ ) . 'js/chosen.jquery.js', array( 'jquery' ), $this->version, false );
106
+ wp_enqueue_script('chosen-proto', plugin_dir_url( __FILE__ ) . 'js/chosen.proto.js', array( 'jquery' ), $this->version, false );
107
+
108
  wp_localize_script( 'one', 'pagevisit', array('ajaxurl' => admin_url( 'admin-ajax.php')));
109
+
110
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
111
+ $options = !empty( $fetchSelecetedPostTypes ) ? $fetchSelecetedPostTypes : json_encode( array() );
112
+ wp_localize_script( 'one', 'get_post_option', array('optionsarray' => $options));
113
+
114
+ $fetchSelecetedIpAddress = get_option('ipaddress_visit');
115
+ $optionsIpAddress = !empty( $fetchSelecetedIpAddress ) ? $fetchSelecetedIpAddress : json_encode( array() );
116
+ wp_localize_script( 'one', 'get_ip_option', array('ipaddressarray' => $optionsIpAddress));
117
+
118
+ $fetchSelecetedUserId = get_option('userlist_visit');
119
+ $optionsUserId = !empty( $fetchSelecetedUserId ) ? $fetchSelecetedUserId : json_encode( array() );
120
+ wp_localize_script( 'one', 'get_user_option', array('usersarray' => $optionsUserId));
121
+
122
  }
123
+
124
+
125
  /**
126
  * admin menu page fnction
127
  * add menu in admin menubar.
140
  $html ='';
141
  $html .='<div class="main-page-visit">';
142
  $html .='<div class="page-title"><h1>Page Visit Counter</h1></div>';
143
+ $temp = array();
144
+
145
+ $postperpage = -1;
146
+
147
+ // Get all the registered post type
148
+ $post_types = get_post_types();
149
+ $posts_array = array();
150
+ if (isset($post_types) && !empty($post_types)) {
151
+ foreach ($post_types as $cpost) {
152
+ if($cpost != "attachment" && $cpost != "revision" && $cpost != "nav_menu_item" && $cpost != "product_variation" && $cpost != "shop_order" && $cpost != "shop_order_refund" && $cpost != "shop_coupon" && $cpost != "shop_webhook" && $cpost != "scheduled-action") {
153
+ $args = array(
154
+ 'post_type' => "$cpost",
155
+ 'post_status' => 'publish',
156
+ 'order' => 'ASC',
157
+ 'posts_per_page' => $postperpage,
158
+ );
159
+ $posts_array[] = get_posts( $args );
160
+ //$temp[] = $posts_array;
161
+ }
162
+ }
163
+ }
164
+
165
  $html .='<div class="page-input-text">';
166
  $html .='<form method="POST">';
167
  $html .='<input type="text" name="pagesearchtext" id="page-search-text" placeholder="Search by page title"><input type="text" id="MyDate" class="pagedateselect" name="MyDate" value="" placeholder="Search by page date"/><a href="javascript:void(0);" id="search-submit" class="button">Search Page</a>';
176
  <th>Page Title</th>
177
  <th width="20%">Total Count</th>
178
  </tr></thead><tbody>';
179
+
 
 
 
 
 
 
 
180
  $counter = 0;
181
+ foreach ($posts_array as $result){
182
+ foreach ($result as $results) {
183
+ $counter = $counter + 1;
184
+ $html .='<tr>';
185
+ $html .='<td>'.$counter.'</td>';
186
+ $html .='<td>'.$results->ID.'</td>';
187
+ $html .='<td><a href="'.get_admin_url().'post.php?post='.$results->ID.'&action=edit">'.$results->post_title.'</a></td>';
188
+
189
+ $pageCount = $wpdb->get_results("SELECT SUM(page_visit) as total FROM $table_name WHERE `page_id` = $results->ID");
190
+
191
+ $total = (int) $pageCount[0]->total;
192
+
193
+
194
+ $html .='<td>'.$total.'</td>';
195
  $html .='</tr>';
196
+ }
197
+ }
198
  $html .='</tbody><tfoot>
199
  <tr>
200
  <th width="10%">No</th>
212
  */
213
  function custom_page_visit_settings( $args ) {
214
 
215
+ global $wpdb;
216
+
217
+ // Get all the registered post type
218
+ $post_types = get_post_types();
219
+
220
+ // Get all the post type selected in settings page
221
+ $post_list = array();
222
+ $post = json_decode(get_option('wfap_post_type'));
223
+ $post_list = $post;
224
+
225
+
226
+
227
  $html ='';
228
  $html .='<div class="main-page-visit-settings">';
229
  $html .='<div class="page-title-settings"><h1>Page Counter Settings</h1></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
 
 
231
  $html .='<div class="page-settings-summery">';
232
  $html .='<form method="POST">';
233
  $get_option_value = json_decode(get_option( 'page_count_settings' ));
234
  $input_values = isset( $get_option_value[1] ) ? $get_option_value[1] : array();
235
  $select_values = isset($get_option_value[0] ) ? $get_option_value[0] : array();
236
  $html .='<table border="0" cellpadding="10" cellspacing="0">';
237
+ $html .='<tr>
238
+ <td>Post Type</td>
239
+ <td>
240
+ <select id="post_type" data-placeholder="Add Page/Post Type" name="post_ty[]" multiple="true" class="chosen-select-post category-select chosen-rtl validate_field1">
241
+ <option value=""></option>';
242
+ if (isset($post_types) && !empty($post_types)) {
243
+ foreach ($post_types as $cpost) {
244
+ if($cpost != "attachment" && $cpost != "revision" && $cpost != "nav_menu_item" && $cpost != "product_variation" && $cpost != "shop_order" && $cpost != "shop_order_refund" && $cpost != "shop_coupon" && $cpost != "shop_webhook" && $cpost != "scheduled-action" && $cpost != "shop_subscription"&& $cpost != "wpcf7_contact_form"&& $cpost != "mc4wp-form") {
245
+ $html .='<option value="'.$cpost.'">'.$cpost.'</option>';
246
+ }
247
+ }
248
+ }
249
+ $html .='</select><span class="information">(Select post types for which post views will be counted.)<br>(<b>Note: If you leave the blank then it will count for all the post/page registered in your theme.</b>)</span>
250
+ </td>';
251
+ $html .='</tr>';
252
+ $html .='<tr class="ipaddress">
253
+ <td>Exclude IPs (Ip Address)</td>
254
+ <td>
255
+ <select id="ip_address" data-placeholder="Add IP Address in comma seprated" name="ip-basic[]" multiple="true" class="chosen-select-ip category-select chosen-rtl validate_field1">
256
+ <option value=""></option>';
257
+ $get_option_value_ip = json_decode(get_option( 'ipaddress_visit' ));
258
+ if (isset($get_option_value_ip) && !empty($get_option_value_ip)) {
259
+ foreach ($get_option_value_ip as $ip) {
260
+ $html .='<option value="'.$ip.'">'.$ip.'</option>';
261
+ }
262
+ }
263
+ $html .='</select><span class="information">(Enter the IP addresses to be excluded from post views count.)</span>
264
+ </td>';
265
+ $html .='</tr>';
266
+ $html .='<tr>';
267
+ $html .='<tr class="users">
268
+ <td>Exclude Users</td>
269
+ <td>
270
+ <select id="users_list" data-placeholder="Select Registerd Users" name="user-basic[]" multiple="true" class="chosen-select category-select chosen-rtl validate_field1">
271
+ <option value=""></option>';
272
+ $query = "SELECT * FROM $wpdb->users";
273
+ $resultSetsArr = $wpdb->get_results($query);
274
+ if (isset($resultSetsArr) && !empty($resultSetsArr)) {
275
+ foreach ($resultSetsArr as $value) {
276
+ $html .='<option value="'.$value->ID.'">'.$value->user_email.'</option>';
277
+ }
278
+ }
279
+ $html .='</select><span class="information">(Select the users to be excluded from post views count.)</span>
280
+ </td>';
281
+ $html .='</tr>';
282
+ $html .='<tr>';
283
+ $html .='<td><input type="button" name="submit" class="pagecountsubmit button" value="Save"></td>';
284
  $html .='<td class="record-mesage"></td>';
285
  $html .='</tr>';
286
  $html .='<table>';
287
  $html .='</form>';
288
+ $html .='<div style="float:left;width:100%">
289
+ <h2>Short Code</h2>
290
+ <p> There are two shortcodes that you can use to manually add page view count to any content on admin or post/page template created by your theme or plugin thats create it\'s own display content in page/post.</p>
291
+ <p style="width: 28%;float: left;">Use this shortcode to add admin side content on page/post:<pre style="margin-top: 14px;float: left;">'.htmlspecialchars('[page_visit_counter_md id="<page_id/post_id>"]').'</pre><br></p>
292
+ <p style="width: 28%;float: left;clear:both;">Use this shortcode to add page/post template (.php) file of your own template:<pre style="margin-top: 14px;float: left;">'.htmlspecialchars('<?php echo do_shortcode("[page_visit_counter_md id="<page_id/post_id>"]"); ?>').'</pre></p>
293
+ </div>';
294
  $html .='</div>';
295
  $html .="<br>";
296
  $html .='</div>';
310
  global $wpdb;
311
  $table_name = $wpdb->prefix."page_visit";
312
  $html ='';
313
+ $count_visit = $wpdb->get_results("SELECT page_id,id,SUM(page_visit) as c from $table_name group by page_id order by c DESC limit 5");
314
  $html .='<div class="main_custom_dashboard_visit_page">';
315
  if (!empty($count_visit) && isset($count_visit)) {
316
  $html .='<table border="0" cellpadding="5" cellspacing="10">';
344
  */
345
  public function add_page_count_option(){
346
  global $wpdb;
347
+
348
+ $page_count_option = array();
349
+
350
+ $type = isset($_POST['selected_posttype']) ? $_POST['selected_posttype'] : '';
351
+ $ipAddress = isset($_POST['ipaddress']) ? $_POST['ipaddress'] : '';
352
+ $userList = isset($_POST['userlist']) ? $_POST['userlist'] : '';
353
+
354
+ delete_option('wfap_post_type');
355
+ if (isset($type) && $type != null) {
356
+ update_option('wfap_post_type',json_encode(array_values($type)));
357
+ }
358
+
359
+ delete_option('ipaddress_visit');
360
+ if (isset($ipAddress) && $ipAddress != null) {
361
+ update_option('ipaddress_visit',json_encode(array_values($ipAddress)));
362
+ }
363
+
364
+ delete_option('userlist_visit');
365
+ if (isset($userList) && $userList != null) {
366
+ update_option('userlist_visit',json_encode(array_values($userList)));
367
  }
368
+
369
+ echo $type;
370
+
371
  die();
372
  }
373
 
414
  foreach ( $count_visit as $countval){
415
  $count = $count + 1;
416
  }
417
+ if ($count_visit[0]->page_visit == '') {
418
+ $countC = 0;
419
+ } else {
420
+ $countC = $count_visit[0]->page_visit;
421
+ }
422
+ $html .='<td>'.$countC.'</td>';
423
  $html .='</tr>';
424
  }
425
  $html .='</tbody>
508
  }
509
  }
510
  $remove = rtrim($str," AND ");
511
+ if($page_date != '' && $page_title != '' ){
512
+ $count_visit = $wpdb->get_results("SELECT * from $table_name where $remove");
513
+ } elseif ($page_title != '' ) {
514
+ $count_visit = $wpdb->get_results("SELECT SUM(page_visit) as page_visit from $table_name where $remove");
515
+ } elseif ($page_date != '' ) {
516
+ $count_visit = $wpdb->get_results("SELECT * from $table_name where page_id=$results->ID AND $remove");
517
  }
518
+
519
+
520
+ $html .='<td>'.$count_visit[0]->page_visit.'</td>';
521
  $html .='</tr>';
522
  }
523
  $html .='</tbody><tfoot>
533
  die();
534
  }
535
 
536
+ public function add_custom_meta_box_page_visit() {
537
+ global $wpdb;
538
+
539
+ $fetchSelecetedPostTypes = json_decode(get_option('wfap_post_type'));
540
+ if (isset($fetchSelecetedPostTypes) && !empty($fetchSelecetedPostTypes)) {
541
+ $i = 0;
542
+ foreach ($fetchSelecetedPostTypes as $postsingle) {
543
+ add_meta_box("header-meta-box-page-visit-$i", "Fetch Page Count", "custom_meta_box_markup_page_visit", "$postsingle", "side", "high", null);
544
+ $i++;
545
+ }
546
+ } else {
547
+ $i = 0;
548
+ // Get all the registered post type
549
+ $post_types = get_post_types();
550
+ foreach ($post_types as $cpost) {
551
+ if($cpost != "attachment" && $cpost != "revision" && $cpost != "nav_menu_item" && $cpost != "product_variation" && $cpost != "shop_order" && $cpost != "shop_order_refund" && $cpost != "shop_coupon" && $cpost != "shop_webhook" && $cpost != "scheduled-action" && $cpost != "shop_subscription"&& $cpost != "wpcf7_contact_form"&& $cpost != "mc4wp-form") {
552
+ add_meta_box("header-meta-box-page-visit-$i", "Fetch Page Count", "custom_meta_box_markup_page_visit", "$cpost", "side", "high", null);
553
+ $i++;
554
+ }
555
+ }
556
+ }
557
+
558
+ function custom_meta_box_markup_page_visit($object) {
559
+ global $wp, $wpdb;
560
+ $post_id = get_the_ID();
561
+ $facebook_auto = get_post_meta($post_id, "get_page_count", true);?>
562
+ <input name="pageidvisit" type="hidden" value="<?php echo $post_id; ?>">
563
+ Fetch Page Count<br>
564
+ <?php if ($facebook_auto == '') { ?>
565
+ <input type="radio" checked ="checked" name="autoupdate_page_visit" id="autoupdate_page1" value="yes"> Yes
566
+ <input type="radio" name="autoupdate_page_visit" id="autoupdate_page2" value="no">No
567
+ <?php } else { ?>
568
+ <input type="radio" <?php if($facebook_auto=='yes'){ ?> checked ="checked" <?php } ?> name="autoupdate_page_visit" id="autoupdate_page1" value="yes"> Yes
569
+ <input type="radio" <?php if($facebook_auto=='no'){ ?> checked ="checked" <?php } ?> name="autoupdate_page_visit" id="autoupdate_page2" value="no">No<?php
570
+ }
571
+ }
572
+ }
573
+
574
+ function save_custom_meta_box_page_visit($post_id) {
575
+ global $wp, $wpdb, $post;
576
+
577
+ if(!current_user_can("edit_post", $post->ID)) {
578
+ return $post->ID;
579
+ }
580
+
581
+ if(defined("DOING_AUTOSAVE") && DOING_AUTOSAVE) {
582
+ return $post->ID;
583
+ }
584
+
585
+ if(isset($_POST["autoupdate_page_visit"]))
586
+ {
587
+ update_post_meta($post->ID, "get_page_count",$_POST["autoupdate_page_visit"]);
588
+ }
589
+
590
+ }
591
+
592
  }
593
+
594
  /**
595
  * The Widget functionality for this plugin.
596
  * widget provide Most visited page.
611
  $html .= (isset($before_widget)?$before_widget:'');
612
  if (!empty($title))
613
  $html .= $before_title . $title . $after_title;
614
+ $count_visit = $wpdb->get_results("SELECT page_id,id,SUM(page_visit) as c from $table_name group by page_id order by c DESC limit 5");
615
  foreach ($count_visit as $visitpage ){
616
  $page = get_post($visitpage->page_id);
617
  $html .='<h6 style="font-size: 14px;font-weight: normal;line-height: 14px;">'.$page->post_title.'</h6>';
admin/css/chosen.css ADDED
@@ -0,0 +1,437 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Chosen, a Select Box Enhancer for jQuery and Prototype
3
+ by Patrick Filler for Harvest, http://getharvest.com
4
+
5
+ Version 1.1.0
6
+ Full source at https://github.com/harvesthq/chosen
7
+ Copyright (c) 2011 Harvest http://getharvest.com
8
+
9
+ MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
10
+ This file is generated by `grunt build`, do not edit it by hand.
11
+ */
12
+
13
+ /* @group Base */
14
+ .chosen-container {
15
+ position: relative;
16
+ display: inline-block;
17
+ vertical-align: middle;
18
+ font-size: 13px;
19
+ zoom: 1;
20
+ *display: inline;
21
+ -webkit-user-select: none;
22
+ -moz-user-select: none;
23
+ user-select: none;
24
+ }
25
+ .chosen-container .chosen-drop {
26
+ position: absolute;
27
+ top: 100%;
28
+ left: -9999px;
29
+ z-index: 1010;
30
+ -webkit-box-sizing: border-box;
31
+ -moz-box-sizing: border-box;
32
+ box-sizing: border-box;
33
+ width: 100%;
34
+ border: 1px solid #aaa;
35
+ border-top: 0;
36
+ background: #fff;
37
+ box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
38
+ }
39
+ .chosen-container.chosen-with-drop .chosen-drop {
40
+ left: 0;
41
+ }
42
+ .chosen-container a {
43
+ cursor: pointer;
44
+ }
45
+
46
+ /* @end */
47
+ /* @group Single Chosen */
48
+ .chosen-container-single .chosen-single {
49
+ position: relative;
50
+ display: block;
51
+ overflow: hidden;
52
+ padding: 0 0 0 8px;
53
+ height: 23px;
54
+ border: 1px solid #aaa;
55
+ border-radius: 5px;
56
+ background-color: #fff;
57
+ background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
58
+ background: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
59
+ background: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
60
+ background: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
61
+ background: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
62
+ background-clip: padding-box;
63
+ box-shadow: 0 0 3px white inset, 0 1px 1px rgba(0, 0, 0, 0.1);
64
+ color: #444;
65
+ text-decoration: none;
66
+ white-space: nowrap;
67
+ line-height: 24px;
68
+ }
69
+ .chosen-container-single .chosen-default {
70
+ color: #999;
71
+ }
72
+ .chosen-container-single .chosen-single span {
73
+ display: block;
74
+ overflow: hidden;
75
+ margin-right: 26px;
76
+ text-overflow: ellipsis;
77
+ white-space: nowrap;
78
+ }
79
+ .chosen-container-single .chosen-single-with-deselect span {
80
+ margin-right: 38px;
81
+ }
82
+ .chosen-container-single .chosen-single abbr {
83
+ position: absolute;
84
+ top: 6px;
85
+ right: 26px;
86
+ display: block;
87
+ width: 12px;
88
+ height: 12px;
89
+ background: url('../images/chosen-sprite.png') -42px 1px no-repeat;
90
+ font-size: 1px;
91
+ }
92
+ .chosen-container-single .chosen-single abbr:hover {
93
+ background-position: -42px -10px;
94
+ }
95
+ .chosen-container-single.chosen-disabled .chosen-single abbr:hover {
96
+ background-position: -42px -10px;
97
+ }
98
+ .chosen-container-single .chosen-single div {
99
+ position: absolute;
100
+ top: 0;
101
+ right: 0;
102
+ display: block;
103
+ width: 18px;
104
+ height: 100%;
105
+ }
106
+ .chosen-container-single .chosen-single div b {
107
+ display: block;
108
+ width: 100%;
109
+ height: 100%;
110
+ background: url('../images/chosen-sprite.png') no-repeat 0px 2px;
111
+ }
112
+ .chosen-container-single .chosen-search {
113
+ position: relative;
114
+ z-index: 1010;
115
+ margin: 0;
116
+ padding: 3px 4px;
117
+ white-space: nowrap;
118
+ }
119
+ .chosen-container-single .chosen-search input[type="text"] {
120
+ -webkit-box-sizing: border-box;
121
+ -moz-box-sizing: border-box;
122
+ box-sizing: border-box;
123
+ margin: 1px 0;
124
+ padding: 4px 20px 4px 5px;
125
+ width: 100%;
126
+ height: auto;
127
+ outline: 0;
128
+ border: 1px solid #aaa;
129
+ background: white url('../images/chosen-sprite.png') no-repeat 100% -20px;
130
+ background: url('../images/chosen-sprite.png') no-repeat 100% -20px;
131
+ font-size: 1em;
132
+ font-family: sans-serif;
133
+ line-height: normal;
134
+ border-radius: 0;
135
+ }
136
+ .chosen-container-single .chosen-drop {
137
+ margin-top: -1px;
138
+ border-radius: 0 0 4px 4px;
139
+ background-clip: padding-box;
140
+ }
141
+ .chosen-container-single.chosen-container-single-nosearch .chosen-search {
142
+ position: absolute;
143
+ left: -9999px;
144
+ }
145
+
146
+ /* @end */
147
+ /* @group Results */
148
+ .chosen-container .chosen-results {
149
+ position: relative;
150
+ overflow-x: hidden;
151
+ overflow-y: auto;
152
+ margin: 0 4px 4px 0;
153
+ padding: 0 0 0 4px;
154
+ max-height: 240px;
155
+ -webkit-overflow-scrolling: touch;
156
+ }
157
+ .chosen-container .chosen-results li {
158
+ display: none;
159
+ margin: 0;
160
+ padding: 5px 6px;
161
+ list-style: none;
162
+ line-height: 15px;
163
+ -webkit-touch-callout: none;
164
+ }
165
+ .chosen-container .chosen-results li.active-result {
166
+ display: list-item;
167
+ cursor: pointer;
168
+ }
169
+ .chosen-container .chosen-results li.disabled-result {
170
+ display: list-item;
171
+ color: #ccc;
172
+ cursor: default;
173
+ }
174
+ .chosen-container .chosen-results li.highlighted {
175
+ background-color: #5D81CB;
176
+ color: #fff;
177
+ }
178
+ .chosen-container .chosen-results li.no-results {
179
+ display: list-item;
180
+ background: #f4f4f4;
181
+ }
182
+ .chosen-container .chosen-results li.group-result {
183
+ display: list-item;
184
+ font-weight: bold;
185
+ cursor: default;
186
+ }
187
+ .chosen-container .chosen-results li.group-option {
188
+ padding-left: 15px;
189
+ }
190
+ .chosen-container .chosen-results li em {
191
+ font-style: normal;
192
+ text-decoration: underline;
193
+ }
194
+
195
+ /* @end */
196
+ /* @group Multi Chosen */
197
+ .chosen-container-multi {
198
+ width: 324px !important;
199
+ }
200
+ .chosen-container-multi .chosen-choices {
201
+ position: relative;
202
+ overflow: hidden;
203
+ -webkit-box-sizing: border-box;
204
+ -moz-box-sizing: border-box;
205
+ box-sizing: border-box;
206
+ margin: 0;
207
+ padding: 0;
208
+ width: 100%;
209
+ height: auto !important;
210
+ height: 1%;
211
+ border: 1px solid #aaa;
212
+ background-color: #fff;
213
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
214
+ background-image: -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
215
+ background-image: -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
216
+ background-image: -o-linear-gradient(#eeeeee 1%, #ffffff 15%);
217
+ background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
218
+ cursor: text;
219
+ }
220
+ .chosen-container-multi .chosen-choices li {
221
+ float: left;
222
+ list-style: none;
223
+ }
224
+ .chosen-container-multi .chosen-choices li.search-field {
225
+ margin: 0;
226
+ padding: 0;
227
+ white-space: nowrap;
228
+ }
229
+ .chosen-container-multi .chosen-choices li.search-field input[type="text"] {
230
+ margin: 1px 0;
231
+ padding: 5px;
232
+ /*height: 15px;*/
233
+ outline: 0;
234
+ border: 0 !important;
235
+ background: transparent !important;
236
+ box-shadow: none;
237
+ color: #666;
238
+ font-size: 100%;
239
+ font-family: sans-serif;
240
+ line-height: normal;
241
+ border-radius: 0;
242
+ }
243
+ .chosen-container-multi .chosen-choices li.search-field .default {
244
+ color: #999;
245
+ }
246
+ .chosen-container-multi .chosen-choices li.search-choice {
247
+ position: relative;
248
+ margin: 3px 0 3px 5px;
249
+ padding: 3px 20px 3px 5px;
250
+ border: 1px solid #678EDA;
251
+ background-color: #678EDA;
252
+ background-clip: padding-box;
253
+ box-shadow: 0 0 2px white inset, 0 1px 0 rgba(168, 193, 251, 0.05);
254
+ color: #fff;
255
+ line-height: 13px;
256
+ cursor: default;
257
+ }
258
+ .chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
259
+ position: absolute;
260
+ top: 5px;
261
+ right: 3px;
262
+ display: block;
263
+ width: 12px;
264
+ height: 12px;
265
+ background: url('../images/chosen-sprite.png') -42px 1px no-repeat;
266
+ font-size: 1px;
267
+ }
268
+ .chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
269
+ background-position: -42px -10px;
270
+ }
271
+ .chosen-container-multi .chosen-choices li.search-choice-disabled {
272
+ padding-right: 5px;
273
+ border: 1px solid #ccc;
274
+ background-color: #e4e4e4;
275
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
276
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
277
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
278
+ background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
279
+ background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
280
+ color: #666;
281
+ }
282
+ .chosen-container-multi .chosen-choices li.search-choice-focus {
283
+ background: #d4d4d4;
284
+ }
285
+ .chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
286
+ background-position: -42px -10px;
287
+ }
288
+ .chosen-container-multi .chosen-results {
289
+ margin: 0;
290
+ padding: 0;
291
+ }
292
+ .chosen-container-multi .chosen-drop .result-selected {
293
+ display: list-item;
294
+ color: #ccc;
295
+ cursor: default;
296
+ }
297
+
298
+ /* @end */
299
+ /* @group Active */
300
+ .chosen-container-active .chosen-single {
301
+ border: 1px solid #5897fb;
302
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
303
+ }
304
+ .chosen-container-active.chosen-with-drop .chosen-single {
305
+ border: 1px solid #aaa;
306
+ -moz-border-radius-bottomright: 0;
307
+ border-bottom-right-radius: 0;
308
+ -moz-border-radius-bottomleft: 0;
309
+ border-bottom-left-radius: 0;
310
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
311
+ background-image: -webkit-linear-gradient(#eeeeee 20%, #ffffff 80%);
312
+ background-image: -moz-linear-gradient(#eeeeee 20%, #ffffff 80%);
313
+ background-image: -o-linear-gradient(#eeeeee 20%, #ffffff 80%);
314
+ background-image: linear-gradient(#eeeeee 20%, #ffffff 80%);
315
+ box-shadow: 0 1px 0 #fff inset;
316
+ }
317
+ .chosen-container-active.chosen-with-drop .chosen-single div {
318
+ border-left: none;
319
+ background: transparent;
320
+ }
321
+ .chosen-container-active.chosen-with-drop .chosen-single div b {
322
+ background-position: -18px 2px;
323
+ }
324
+ .chosen-container-active .chosen-choices {
325
+ border: 1px solid #5897fb;
326
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
327
+ }
328
+ .chosen-container-active .chosen-choices li.search-field input[type="text"] {
329
+ color: #111 !important;
330
+ }
331
+
332
+ /* @end */
333
+ /* @group Disabled Support */
334
+ .chosen-disabled {
335
+ opacity: 0.5 !important;
336
+ cursor: default;
337
+ }
338
+ .chosen-disabled .chosen-single {
339
+ cursor: default;
340
+ }
341
+ .chosen-disabled .chosen-choices .search-choice .search-choice-close {
342
+ cursor: default;
343
+ }
344
+
345
+ /* @end */
346
+ /* @group Right to Left */
347
+ .chosen-rtl {
348
+ text-align: left;
349
+ }
350
+ .chosen-rtl .chosen-single {
351
+ overflow: visible;
352
+ padding: 0 8px 0 0;
353
+ }
354
+ .chosen-rtl .chosen-single span {
355
+ margin-right: 0;
356
+ margin-left: 26px;
357
+ /*direction: rtl;*/
358
+ }
359
+ .chosen-rtl .chosen-single-with-deselect span {
360
+ margin-left: 38px;
361
+ }
362
+ .chosen-rtl .chosen-single div {
363
+ right: auto;
364
+ left: 3px;
365
+ }
366
+ .chosen-rtl .chosen-single abbr {
367
+ right: auto;
368
+ left: 26px;
369
+ }
370
+ .chosen-rtl .chosen-choices li {
371
+ float: left;
372
+ }
373
+ .chosen-rtl .chosen-choices li.search-field input[type="text"] {
374
+ /* direction: rtl;*/
375
+ }
376
+ .chosen-rtl .chosen-choices li.search-choice {
377
+ margin: 3px 5px 3px 3px;
378
+ padding: 5px 5px 5px 19px;
379
+ }
380
+ .chosen-rtl .chosen-choices li.search-choice .search-choice-close {
381
+ right: auto;
382
+ left: 4px;
383
+ }
384
+ .chosen-rtl.chosen-container-single-nosearch .chosen-search,
385
+ .chosen-rtl .chosen-drop {
386
+ /* left: 9999px;*/
387
+ }
388
+ .chosen-rtl.chosen-container-single .chosen-results {
389
+ margin: 0 0 4px 4px;
390
+ padding: 0 4px 0 0;
391
+ }
392
+ .chosen-rtl .chosen-results li.group-option {
393
+ padding-right: 15px;
394
+ padding-left: 0;
395
+ }
396
+ .chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div {
397
+ border-right: none;
398
+ }
399
+ .chosen-rtl .chosen-search input[type="text"] {
400
+ padding: 4px 5px 4px 20px;
401
+ background: white url('../images/chosen-sprite.png') no-repeat -30px -20px;
402
+ background: url('../images/chosen-sprite.png') no-repeat -30px -20px;
403
+ /*direction: rtl;*/
404
+ }
405
+ .chosen-rtl.chosen-container-single .chosen-single div b {
406
+ background-position: 6px 2px;
407
+ }
408
+ .chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b {
409
+ background-position: -12px 2px;
410
+ }
411
+
412
+ /* @end */
413
+ /* @group Retina compatibility */
414
+ @media (max-width: 767px) {
415
+
416
+ }
417
+ @media (max-width: 480px) {
418
+
419
+ .chosen-container-multi,.main-contacts .groups-select{
420
+ width:100% !important;
421
+ }
422
+ }
423
+
424
+ @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
425
+ .chosen-rtl .chosen-search input[type="text"],
426
+ .chosen-container-single .chosen-single abbr,
427
+ .chosen-container-single .chosen-single div b,
428
+ .chosen-container-single .chosen-search input[type="text"],
429
+ .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
430
+ .chosen-container .chosen-results-scroll-down span,
431
+ .chosen-container .chosen-results-scroll-up span {
432
+ background-image: url('../images/chosen-sprite@2x.png') !important;
433
+ background-size: 52px 37px !important;
434
+ background-repeat: no-repeat !important;
435
+ }
436
+ }
437
+ /* @end */
admin/css/style.css CHANGED
@@ -1,4 +1,4 @@
1
- .page-visit-summery table.dataTable{width:100%}
2
  .page-visit-summery table#example thead tr th {background-color: #FFF;color:#000;padding:10px;border-bottom: 1px solid #e1e1e1;}
3
  .page-visit-summery table#example tfoot tr th {background-color: #FFF;color:#000;padding:10px;border-top: 1px solid #e1e1e1;}
4
  .page-visit-summery table#example tbody tr.even {background-color: #FFF;color: #000;}
@@ -7,7 +7,7 @@
7
  .page-visit-summery table#example tbody tr.odd td{background-color: #f9f9f9 ;color: #000;}
8
  .page-visit-summery table.dataTable tr.odd td.sorting_1{background-color:#f9f9f9 !important;color:#0073aa !important; }
9
  .page-visit-summery table.dataTable tr.even td.sorting_1 {background-color:#FFF !important;color:#0073aa !important; }
10
- .page-visit-summery table#example tr td {text-align: center;padding:10px;color:#0073aa !important;border-bottom: none !important}
11
  div.page-visit-summery div#example_paginate {margin-top: 10px;}
12
  div.page-visit-summery div#example_info {margin-top: 5px;}
13
  div.page-visit-summery a#example_first {border-radius: 5px;padding: 5px 10px;background-color: #FFF;color: #000 !important;}
@@ -17,8 +17,8 @@ div.page-visit-summery a#example_next{border-radius: 5px;padding: 5px 10px;backg
17
  .page-title h1 {width: 100%;color: #000;}
18
  .page-input-text form table tr td input#page-search-text {width: 200px;padding-left: 10px;}
19
  .page-input-text form table tr td input#MyDate {width: 200px;padding-left: 10px;}
20
- .page-visit-summery table#example tbody tr.odd td a {text-decoration: none;font-weight: bold;color: #0073aa;font-size: 16px;text-transform: uppercase;}
21
- .page-visit-summery table#example tbody tr.even td a {text-decoration: none;font-weight: bold;color: #0073aa;font-size: 16px;text-transform: uppercase;}
22
  .page-visit-summery table#example tbody tr td a:hover {color:#0073AA;font-weight: bold;}
23
  .main-page-visit-settings .page-title-settings h1{width: 100%;color: #000;margin-top: 32px;}
24
  .page-settings-summery form table tr td select#page-setting-options {width: 200px;color: #000;}
@@ -31,4 +31,6 @@ div.page-visit-summery a#example_next{border-radius: 5px;padding: 5px 10px;backg
31
  .paging_full_numbers a.paginate_active {background-color: #99B3FF;}
32
  .paging_full_numbers a.paginate_button {background-color: #FFF !important;}
33
  .main-page-visit .page-input-text input {width: 200px;height: 30px;line-height: 30px;padding-left: 10px;text-transform: capitalize;}
34
- .main-page-visit .page-input-text a#search-submit {margin-left: 10px;margin-top: 2px;text-transform: uppercase;}
 
 
1
+ .page-visit-summery table.dataTable{width:100%;text-align: left;text-transform: none;}
2
  .page-visit-summery table#example thead tr th {background-color: #FFF;color:#000;padding:10px;border-bottom: 1px solid #e1e1e1;}
3
  .page-visit-summery table#example tfoot tr th {background-color: #FFF;color:#000;padding:10px;border-top: 1px solid #e1e1e1;}
4
  .page-visit-summery table#example tbody tr.even {background-color: #FFF;color: #000;}
7
  .page-visit-summery table#example tbody tr.odd td{background-color: #f9f9f9 ;color: #000;}
8
  .page-visit-summery table.dataTable tr.odd td.sorting_1{background-color:#f9f9f9 !important;color:#0073aa !important; }
9
  .page-visit-summery table.dataTable tr.even td.sorting_1 {background-color:#FFF !important;color:#0073aa !important; }
10
+ .page-visit-summery table#example tr td {text-align: left;padding:10px;color:#0073aa !important;border-bottom: none !important}
11
  div.page-visit-summery div#example_paginate {margin-top: 10px;}
12
  div.page-visit-summery div#example_info {margin-top: 5px;}
13
  div.page-visit-summery a#example_first {border-radius: 5px;padding: 5px 10px;background-color: #FFF;color: #000 !important;}
17
  .page-title h1 {width: 100%;color: #000;}
18
  .page-input-text form table tr td input#page-search-text {width: 200px;padding-left: 10px;}
19
  .page-input-text form table tr td input#MyDate {width: 200px;padding-left: 10px;}
20
+ .page-visit-summery table#example tbody tr.odd td a {text-decoration: none;font-weight: bold;color: #0073aa;font-size: 16px;text-transform: none;}
21
+ .page-visit-summery table#example tbody tr.even td a {text-decoration: none;font-weight: bold;color: #0073aa;font-size: 16px;text-transform: none;}
22
  .page-visit-summery table#example tbody tr td a:hover {color:#0073AA;font-weight: bold;}
23
  .main-page-visit-settings .page-title-settings h1{width: 100%;color: #000;margin-top: 32px;}
24
  .page-settings-summery form table tr td select#page-setting-options {width: 200px;color: #000;}
31
  .paging_full_numbers a.paginate_active {background-color: #99B3FF;}
32
  .paging_full_numbers a.paginate_button {background-color: #FFF !important;}
33
  .main-page-visit .page-input-text input {width: 200px;height: 30px;line-height: 30px;padding-left: 10px;text-transform: capitalize;}
34
+ .main-page-visit .page-input-text a#search-submit {margin-left: 10px;margin-top: 2px;text-transform: uppercase;}
35
+ .page-settings-summery pre {margin: 0;text-transform: initial;font-weight: bold;white-space: inherit;display: initial;}
36
+ .page-settings-summery form table tr td span.information {float: left;width: 100%;font-size: 11px;text-transform: none;}
admin/images/chosen-sprite.png ADDED
Binary file
admin/images/chosen-sprite@2x.png ADDED
Binary file
admin/js/chosen.jquery.js ADDED
@@ -0,0 +1,1211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Chosen, a Select Box Enhancer for jQuery and Prototype
3
+ by Patrick Filler for Harvest, http://getharvest.com
4
+
5
+ Version 1.1.0
6
+ Full source at https://github.com/harvesthq/chosen
7
+ Copyright (c) 2011 Harvest http://getharvest.com
8
+
9
+ MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
10
+ This file is generated by `grunt build`, do not edit it by hand.
11
+ */
12
+
13
+ (function() {
14
+ var $, AbstractChosen, Chosen, SelectParser, _ref,
15
+ __hasProp = {}.hasOwnProperty,
16
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
17
+
18
+ SelectParser = (function() {
19
+ function SelectParser() {
20
+ this.options_index = 0;
21
+ this.parsed = [];
22
+ }
23
+
24
+ SelectParser.prototype.add_node = function(child) {
25
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
26
+ return this.add_group(child);
27
+ } else {
28
+ return this.add_option(child);
29
+ }
30
+ };
31
+
32
+ SelectParser.prototype.add_group = function(group) {
33
+ var group_position, option, _i, _len, _ref, _results;
34
+ group_position = this.parsed.length;
35
+ this.parsed.push({
36
+ array_index: group_position,
37
+ group: true,
38
+ label: this.escapeExpression(group.label),
39
+ children: 0,
40
+ disabled: group.disabled
41
+ });
42
+ _ref = group.childNodes;
43
+ _results = [];
44
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
45
+ option = _ref[_i];
46
+ _results.push(this.add_option(option, group_position, group.disabled));
47
+ }
48
+ return _results;
49
+ };
50
+
51
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
52
+ if (option.nodeName.toUpperCase() === "OPTION") {
53
+ if (option.text !== "") {
54
+ if (group_position != null) {
55
+ this.parsed[group_position].children += 1;
56
+ }
57
+ this.parsed.push({
58
+ array_index: this.parsed.length,
59
+ options_index: this.options_index,
60
+ value: option.value,
61
+ text: option.text,
62
+ html: option.innerHTML,
63
+ selected: option.selected,
64
+ disabled: group_disabled === true ? group_disabled : option.disabled,
65
+ group_array_index: group_position,
66
+ classes: option.className,
67
+ style: option.style.cssText
68
+ });
69
+ } else {
70
+ this.parsed.push({
71
+ array_index: this.parsed.length,
72
+ options_index: this.options_index,
73
+ empty: true
74
+ });
75
+ }
76
+ return this.options_index += 1;
77
+ }
78
+ };
79
+
80
+ SelectParser.prototype.escapeExpression = function(text) {
81
+ var map, unsafe_chars;
82
+ if ((text == null) || text === false) {
83
+ return "";
84
+ }
85
+ if (!/[\&\<\>\"\'\`]/.test(text)) {
86
+ return text;
87
+ }
88
+ map = {
89
+ "<": "&lt;",
90
+ ">": "&gt;",
91
+ '"': "&quot;",
92
+ "'": "&#x27;",
93
+ "`": "&#x60;"
94
+ };
95
+ unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
96
+ return text.replace(unsafe_chars, function(chr) {
97
+ return map[chr] || "&amp;";
98
+ });
99
+ };
100
+
101
+ return SelectParser;
102
+
103
+ })();
104
+
105
+ SelectParser.select_to_array = function(select) {
106
+ var child, parser, _i, _len, _ref;
107
+ parser = new SelectParser();
108
+ _ref = select.childNodes;
109
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
110
+ child = _ref[_i];
111
+ parser.add_node(child);
112
+ }
113
+ return parser.parsed;
114
+ };
115
+
116
+ AbstractChosen = (function() {
117
+ function AbstractChosen(form_field, options) {
118
+ this.form_field = form_field;
119
+ this.options = options != null ? options : {};
120
+ if (!AbstractChosen.browser_is_supported()) {
121
+ return;
122
+ }
123
+ this.is_multiple = this.form_field.multiple;
124
+ this.set_default_text();
125
+ this.set_default_values();
126
+ this.setup();
127
+ this.set_up_html();
128
+ this.register_observers();
129
+ }
130
+
131
+ AbstractChosen.prototype.set_default_values = function() {
132
+ var _this = this;
133
+ this.click_test_action = function(evt) {
134
+ return _this.test_active_click(evt);
135
+ };
136
+ this.activate_action = function(evt) {
137
+ return _this.activate_field(evt);
138
+ };
139
+ this.active_field = false;
140
+ this.mouse_on_container = false;
141
+ this.results_showing = false;
142
+ this.result_highlighted = null;
143
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
144
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
145
+ this.disable_search = this.options.disable_search || false;
146
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
147
+ this.group_search = this.options.group_search != null ? this.options.group_search : true;
148
+ this.search_contains = this.options.search_contains || false;
149
+ this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
150
+ this.max_selected_options = this.options.max_selected_options || Infinity;
151
+ this.inherit_select_classes = this.options.inherit_select_classes || false;
152
+ this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
153
+ return this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
154
+ };
155
+
156
+ AbstractChosen.prototype.set_default_text = function() {
157
+ if (this.form_field.getAttribute("data-placeholder")) {
158
+ this.default_text = this.form_field.getAttribute("data-placeholder");
159
+ } else if (this.is_multiple) {
160
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
161
+ } else {
162
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
163
+ }
164
+ return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
165
+ };
166
+
167
+ AbstractChosen.prototype.mouse_enter = function() {
168
+ return this.mouse_on_container = true;
169
+ };
170
+
171
+ AbstractChosen.prototype.mouse_leave = function() {
172
+ return this.mouse_on_container = false;
173
+ };
174
+
175
+ AbstractChosen.prototype.input_focus = function(evt) {
176
+ var _this = this;
177
+ if (this.is_multiple) {
178
+ if (!this.active_field) {
179
+ return setTimeout((function() {
180
+ return _this.container_mousedown();
181
+ }), 50);
182
+ }
183
+ } else {
184
+ if (!this.active_field) {
185
+ return this.activate_field();
186
+ }
187
+ }
188
+ };
189
+
190
+ AbstractChosen.prototype.input_blur = function(evt) {
191
+ var _this = this;
192
+ if (!this.mouse_on_container) {
193
+ this.active_field = false;
194
+ return setTimeout((function() {
195
+ return _this.blur_test();
196
+ }), 100);
197
+ }
198
+ };
199
+
200
+ AbstractChosen.prototype.results_option_build = function(options) {
201
+ var content, data, _i, _len, _ref;
202
+ content = '';
203
+ _ref = this.results_data;
204
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
205
+ data = _ref[_i];
206
+ if (data.group) {
207
+ content += this.result_add_group(data);
208
+ } else {
209
+ content += this.result_add_option(data);
210
+ }
211
+ if (options != null ? options.first : void 0) {
212
+ if (data.selected && this.is_multiple) {
213
+ this.choice_build(data);
214
+ } else if (data.selected && !this.is_multiple) {
215
+ this.single_set_selected_text(data.text);
216
+ }
217
+ }
218
+ }
219
+ return content;
220
+ };
221
+
222
+ AbstractChosen.prototype.result_add_option = function(option) {
223
+ var classes, option_el;
224
+ if (!option.search_match) {
225
+ return '';
226
+ }
227
+ if (!this.include_option_in_results(option)) {
228
+ return '';
229
+ }
230
+ classes = [];
231
+ if (!option.disabled && !(option.selected && this.is_multiple)) {
232
+ classes.push("active-result");
233
+ }
234
+ if (option.disabled && !(option.selected && this.is_multiple)) {
235
+ classes.push("disabled-result");
236
+ }
237
+ if (option.selected) {
238
+ classes.push("result-selected");
239
+ }
240
+ if (option.group_array_index != null) {
241
+ classes.push("group-option");
242
+ }
243
+ if (option.classes !== "") {
244
+ classes.push(option.classes);
245
+ }
246
+ option_el = document.createElement("li");
247
+ option_el.className = classes.join(" ");
248
+ option_el.style.cssText = option.style;
249
+ option_el.setAttribute("data-option-array-index", option.array_index);
250
+ option_el.innerHTML = option.search_text;
251
+ return this.outerHTML(option_el);
252
+ };
253
+
254
+ AbstractChosen.prototype.result_add_group = function(group) {
255
+ var group_el;
256
+ if (!(group.search_match || group.group_match)) {
257
+ return '';
258
+ }
259
+ if (!(group.active_options > 0)) {
260
+ return '';
261
+ }
262
+ group_el = document.createElement("li");
263
+ group_el.className = "group-result";
264
+ group_el.innerHTML = group.search_text;
265
+ return this.outerHTML(group_el);
266
+ };
267
+
268
+ AbstractChosen.prototype.results_update_field = function() {
269
+ this.set_default_text();
270
+ if (!this.is_multiple) {
271
+ this.results_reset_cleanup();
272
+ }
273
+ this.result_clear_highlight();
274
+ this.results_build();
275
+ if (this.results_showing) {
276
+ return this.winnow_results();
277
+ }
278
+ };
279
+
280
+ AbstractChosen.prototype.reset_single_select_options = function() {
281
+ var result, _i, _len, _ref, _results;
282
+ _ref = this.results_data;
283
+ _results = [];
284
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
285
+ result = _ref[_i];
286
+ if (result.selected) {
287
+ _results.push(result.selected = false);
288
+ } else {
289
+ _results.push(void 0);
290
+ }
291
+ }
292
+ return _results;
293
+ };
294
+
295
+ AbstractChosen.prototype.results_toggle = function() {
296
+ if (this.results_showing) {
297
+ return this.results_hide();
298
+ } else {
299
+ return this.results_show();
300
+ }
301
+ };
302
+
303
+ AbstractChosen.prototype.results_search = function(evt) {
304
+ if (this.results_showing) {
305
+ return this.winnow_results();
306
+ } else {
307
+ return this.results_show();
308
+ }
309
+ };
310
+
311
+ AbstractChosen.prototype.winnow_results = function() {
312
+ var escapedSearchText, option, regex, regexAnchor, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
313
+ this.no_results_clear();
314
+ results = 0;
315
+ searchText = this.get_search_text();
316
+ escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
317
+ regexAnchor = this.search_contains ? "" : "^";
318
+ regex = new RegExp(regexAnchor + escapedSearchText, 'i');
319
+ zregex = new RegExp(escapedSearchText, 'i');
320
+ _ref = this.results_data;
321
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
322
+ option = _ref[_i];
323
+ option.search_match = false;
324
+ results_group = null;
325
+ if (this.include_option_in_results(option)) {
326
+ if (option.group) {
327
+ option.group_match = false;
328
+ option.active_options = 0;
329
+ }
330
+ if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
331
+ results_group = this.results_data[option.group_array_index];
332
+ if (results_group.active_options === 0 && results_group.search_match) {
333
+ results += 1;
334
+ }
335
+ results_group.active_options += 1;
336
+ }
337
+ if (!(option.group && !this.group_search)) {
338
+ option.search_text = option.group ? option.label : option.html;
339
+ option.search_match = this.search_string_match(option.search_text, regex);
340
+ if (option.search_match && !option.group) {
341
+ results += 1;
342
+ }
343
+ if (option.search_match) {
344
+ if (searchText.length) {
345
+ startpos = option.search_text.search(zregex);
346
+ text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
347
+ option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
348
+ }
349
+ if (results_group != null) {
350
+ results_group.group_match = true;
351
+ }
352
+ } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
353
+ option.search_match = true;
354
+ }
355
+ }
356
+ }
357
+ }
358
+ this.result_clear_highlight();
359
+ if (results < 1 && searchText.length) {
360
+ this.update_results_content("");
361
+ return this.no_results(searchText);
362
+ } else {
363
+ this.update_results_content(this.results_option_build());
364
+ return this.winnow_results_set_highlight();
365
+ }
366
+ };
367
+
368
+ AbstractChosen.prototype.search_string_match = function(search_string, regex) {
369
+ var part, parts, _i, _len;
370
+ if (regex.test(search_string)) {
371
+ return true;
372
+ } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
373
+ parts = search_string.replace(/\[|\]/g, "").split(" ");
374
+ if (parts.length) {
375
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
376
+ part = parts[_i];
377
+ if (regex.test(part)) {
378
+ return true;
379
+ }
380
+ }
381
+ }
382
+ }
383
+ };
384
+
385
+ AbstractChosen.prototype.choices_count = function() {
386
+ var option, _i, _len, _ref;
387
+ if (this.selected_option_count != null) {
388
+ return this.selected_option_count;
389
+ }
390
+ this.selected_option_count = 0;
391
+ _ref = this.form_field.options;
392
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
393
+ option = _ref[_i];
394
+ if (option.selected) {
395
+ this.selected_option_count += 1;
396
+ }
397
+ }
398
+ return this.selected_option_count;
399
+ };
400
+
401
+ AbstractChosen.prototype.choices_click = function(evt) {
402
+ evt.preventDefault();
403
+ if (!(this.results_showing || this.is_disabled)) {
404
+ return this.results_show();
405
+ }
406
+ };
407
+
408
+ AbstractChosen.prototype.keyup_checker = function(evt) {
409
+ var stroke, _ref;
410
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
411
+ this.search_field_scale();
412
+ switch (stroke) {
413
+ case 8:
414
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
415
+ return this.keydown_backstroke();
416
+ } else if (!this.pending_backstroke) {
417
+ this.result_clear_highlight();
418
+ return this.results_search();
419
+ }
420
+ break;
421
+ case 13:
422
+ evt.preventDefault();
423
+ if (this.results_showing) {
424
+ return this.result_select(evt);
425
+ }
426
+ break;
427
+ case 27:
428
+ if (this.results_showing) {
429
+ this.results_hide();
430
+ }
431
+ return true;
432
+ case 9:
433
+ case 38:
434
+ case 40:
435
+ case 16:
436
+ case 91:
437
+ case 17:
438
+ break;
439
+ default:
440
+ return this.results_search();
441
+ }
442
+ };
443
+
444
+ AbstractChosen.prototype.clipboard_event_checker = function(evt) {
445
+ var _this = this;
446
+ return setTimeout((function() {
447
+ return _this.results_search();
448
+ }), 50);
449
+ };
450
+
451
+ AbstractChosen.prototype.container_width = function() {
452
+ if (this.options.width != null) {
453
+ return this.options.width;
454
+ } else {
455
+ return "" + this.form_field.offsetWidth + "px";
456
+ }
457
+ };
458
+
459
+ AbstractChosen.prototype.include_option_in_results = function(option) {
460
+ if (this.is_multiple && (!this.display_selected_options && option.selected)) {
461
+ return false;
462
+ }
463
+ if (!this.display_disabled_options && option.disabled) {
464
+ return false;
465
+ }
466
+ if (option.empty) {
467
+ return false;
468
+ }
469
+ return true;
470
+ };
471
+
472
+ AbstractChosen.prototype.search_results_touchstart = function(evt) {
473
+ this.touch_started = true;
474
+ return this.search_results_mouseover(evt);
475
+ };
476
+
477
+ AbstractChosen.prototype.search_results_touchmove = function(evt) {
478
+ this.touch_started = false;
479
+ return this.search_results_mouseout(evt);
480
+ };
481
+
482
+ AbstractChosen.prototype.search_results_touchend = function(evt) {
483
+ if (this.touch_started) {
484
+ return this.search_results_mouseup(evt);
485
+ }
486
+ };
487
+
488
+ AbstractChosen.prototype.outerHTML = function(element) {
489
+ var tmp;
490
+ if (element.outerHTML) {
491
+ return element.outerHTML;
492
+ }
493
+ tmp = document.createElement("div");
494
+ tmp.appendChild(element);
495
+ return tmp.innerHTML;
496
+ };
497
+
498
+ AbstractChosen.browser_is_supported = function() {
499
+ if (window.navigator.appName === "Microsoft Internet Explorer") {
500
+ return document.documentMode >= 8;
501
+ }
502
+ if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
503
+ return true;
504
+ }
505
+ if (/Android/i.test(window.navigator.userAgent)) {
506
+ if (/Mobile/i.test(window.navigator.userAgent)) {
507
+ return true;
508
+ }
509
+ }
510
+ return true;
511
+ };
512
+
513
+ AbstractChosen.default_multiple_text = "Select Some Options";
514
+
515
+ AbstractChosen.default_single_text = "Select an Option";
516
+
517
+ AbstractChosen.default_no_result_text = "No results match";
518
+
519
+ return AbstractChosen;
520
+
521
+ })();
522
+
523
+ $ = jQuery;
524
+
525
+ $.fn.extend({
526
+ chosen: function(options) {
527
+ if (!AbstractChosen.browser_is_supported()) {
528
+ return this;
529
+ }
530
+ return this.each(function(input_field) {
531
+ var $this, chosen;
532
+ $this = $(this);
533
+ chosen = $this.data('chosen');
534
+ if (options === 'destroy' && chosen) {
535
+ chosen.destroy();
536
+ } else if (!chosen) {
537
+ $this.data('chosen', new Chosen(this, options));
538
+ }
539
+ });
540
+ }
541
+ });
542
+
543
+ Chosen = (function(_super) {
544
+ __extends(Chosen, _super);
545
+
546
+ function Chosen() {
547
+ _ref = Chosen.__super__.constructor.apply(this, arguments);
548
+ return _ref;
549
+ }
550
+
551
+ Chosen.prototype.setup = function() {
552
+ this.form_field_jq = $(this.form_field);
553
+ this.current_selectedIndex = this.form_field.selectedIndex;
554
+ return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
555
+ };
556
+
557
+ Chosen.prototype.set_up_html = function() {
558
+ var container_classes, container_props;
559
+ container_classes = ["chosen-container"];
560
+ container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
561
+ if (this.inherit_select_classes && this.form_field.className) {
562
+ container_classes.push(this.form_field.className);
563
+ }
564
+ if (this.is_rtl) {
565
+ container_classes.push("chosen-rtl");
566
+ }
567
+ container_props = {
568
+ 'class': container_classes.join(' '),
569
+ 'style': "width: " + (this.container_width()) + ";",
570
+ 'title': this.form_field.title
571
+ };
572
+ if (this.form_field.id.length) {
573
+ container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
574
+ }
575
+ this.container = $("<div />", container_props);
576
+ if (this.is_multiple) {
577
+ this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
578
+ } else {
579
+ this.container.html('<a class="chosen-single chosen-default" tabindex="-1"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
580
+ }
581
+ this.form_field_jq.hide().after(this.container);
582
+ this.dropdown = this.container.find('div.chosen-drop').first();
583
+ this.search_field = this.container.find('input').first();
584
+ this.search_results = this.container.find('ul.chosen-results').first();
585
+ this.search_field_scale();
586
+ this.search_no_results = this.container.find('li.no-results').first();
587
+ if (this.is_multiple) {
588
+ this.search_choices = this.container.find('ul.chosen-choices').first();
589
+ this.search_container = this.container.find('li.search-field').first();
590
+ } else {
591
+ this.search_container = this.container.find('div.chosen-search').first();
592
+ this.selected_item = this.container.find('.chosen-single').first();
593
+ }
594
+ this.results_build();
595
+ this.set_tab_index();
596
+ this.set_label_behavior();
597
+ return this.form_field_jq.trigger("chosen:ready", {
598
+ chosen: this
599
+ });
600
+ };
601
+
602
+ Chosen.prototype.register_observers = function() {
603
+ var _this = this;
604
+ this.container.bind('mousedown.chosen', function(evt) {
605
+ _this.container_mousedown(evt);
606
+ });
607
+ this.container.bind('mouseup.chosen', function(evt) {
608
+ _this.container_mouseup(evt);
609
+ });
610
+ this.container.bind('mouseenter.chosen', function(evt) {
611
+ _this.mouse_enter(evt);
612
+ });
613
+ this.container.bind('mouseleave.chosen', function(evt) {
614
+ _this.mouse_leave(evt);
615
+ });
616
+ this.search_results.bind('mouseup.chosen', function(evt) {
617
+ _this.search_results_mouseup(evt);
618
+ });
619
+ this.search_results.bind('mouseover.chosen', function(evt) {
620
+ _this.search_results_mouseover(evt);
621
+ });
622
+ this.search_results.bind('mouseout.chosen', function(evt) {
623
+ _this.search_results_mouseout(evt);
624
+ });
625
+ this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
626
+ _this.search_results_mousewheel(evt);
627
+ });
628
+ this.search_results.bind('touchstart.chosen', function(evt) {
629
+ _this.search_results_touchstart(evt);
630
+ });
631
+ this.search_results.bind('touchmove.chosen', function(evt) {
632
+ _this.search_results_touchmove(evt);
633
+ });
634
+ this.search_results.bind('touchend.chosen', function(evt) {
635
+ _this.search_results_touchend(evt);
636
+ });
637
+ this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
638
+ _this.results_update_field(evt);
639
+ });
640
+ this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
641
+ _this.activate_field(evt);
642
+ });
643
+ this.form_field_jq.bind("chosen:open.chosen", function(evt) {
644
+ _this.container_mousedown(evt);
645
+ });
646
+ this.form_field_jq.bind("chosen:close.chosen", function(evt) {
647
+ _this.input_blur(evt);
648
+ });
649
+ this.search_field.bind('blur.chosen', function(evt) {
650
+ _this.input_blur(evt);
651
+ });
652
+ this.search_field.bind('keyup.chosen', function(evt) {
653
+ _this.keyup_checker(evt);
654
+ });
655
+ this.search_field.bind('keydown.chosen', function(evt) {
656
+ _this.keydown_checker(evt);
657
+ });
658
+ this.search_field.bind('focus.chosen', function(evt) {
659
+ _this.input_focus(evt);
660
+ });
661
+ this.search_field.bind('cut.chosen', function(evt) {
662
+ _this.clipboard_event_checker(evt);
663
+ });
664
+ this.search_field.bind('paste.chosen', function(evt) {
665
+ _this.clipboard_event_checker(evt);
666
+ });
667
+ if (this.is_multiple) {
668
+ return this.search_choices.bind('click.chosen', function(evt) {
669
+ _this.choices_click(evt);
670
+ });
671
+ } else {
672
+ return this.container.bind('click.chosen', function(evt) {
673
+ evt.preventDefault();
674
+ });
675
+ }
676
+ };
677
+
678
+ Chosen.prototype.destroy = function() {
679
+ $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
680
+ if (this.search_field[0].tabIndex) {
681
+ this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
682
+ }
683
+ this.container.remove();
684
+ this.form_field_jq.removeData('chosen');
685
+ return this.form_field_jq.show();
686
+ };
687
+
688
+ Chosen.prototype.search_field_disabled = function() {
689
+ this.is_disabled = this.form_field_jq[0].disabled;
690
+ if (this.is_disabled) {
691
+ this.container.addClass('chosen-disabled');
692
+ this.search_field[0].disabled = true;
693
+ if (!this.is_multiple) {
694
+ this.selected_item.unbind("focus.chosen", this.activate_action);
695
+ }
696
+ return this.close_field();
697
+ } else {
698
+ this.container.removeClass('chosen-disabled');
699
+ this.search_field[0].disabled = false;
700
+ if (!this.is_multiple) {
701
+ return this.selected_item.bind("focus.chosen", this.activate_action);
702
+ }
703
+ }
704
+ };
705
+
706
+ Chosen.prototype.container_mousedown = function(evt) {
707
+ if (!this.is_disabled) {
708
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
709
+ evt.preventDefault();
710
+ }
711
+ if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
712
+ if (!this.active_field) {
713
+ if (this.is_multiple) {
714
+ this.search_field.val("");
715
+ }
716
+ $(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
717
+ this.results_show();
718
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
719
+ evt.preventDefault();
720
+ this.results_toggle();
721
+ }
722
+ return this.activate_field();
723
+ }
724
+ }
725
+ };
726
+
727
+ Chosen.prototype.container_mouseup = function(evt) {
728
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
729
+ return this.results_reset(evt);
730
+ }
731
+ };
732
+
733
+ Chosen.prototype.search_results_mousewheel = function(evt) {
734
+ var delta;
735
+ if (evt.originalEvent) {
736
+ delta = -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
737
+ }
738
+ if (delta != null) {
739
+ evt.preventDefault();
740
+ if (evt.type === 'DOMMouseScroll') {
741
+ delta = delta * 40;
742
+ }
743
+ return this.search_results.scrollTop(delta + this.search_results.scrollTop());
744
+ }
745
+ };
746
+
747
+ Chosen.prototype.blur_test = function(evt) {
748
+ if (!this.active_field && this.container.hasClass("chosen-container-active")) {
749
+ return this.close_field();
750
+ }
751
+ };
752
+
753
+ Chosen.prototype.close_field = function() {
754
+ $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
755
+ this.active_field = false;
756
+ this.results_hide();
757
+ this.container.removeClass("chosen-container-active");
758
+ this.clear_backstroke();
759
+ this.show_search_field_default();
760
+ return this.search_field_scale();
761
+ };
762
+
763
+ Chosen.prototype.activate_field = function() {
764
+ this.container.addClass("chosen-container-active");
765
+ this.active_field = true;
766
+ this.search_field.val(this.search_field.val());
767
+ return this.search_field.focus();
768
+ };
769
+
770
+ Chosen.prototype.test_active_click = function(evt) {
771
+ var active_container;
772
+ active_container = $(evt.target).closest('.chosen-container');
773
+ if (active_container.length && this.container[0] === active_container[0]) {
774
+ return this.active_field = true;
775
+ } else {
776
+ return this.close_field();
777
+ }
778
+ };
779
+
780
+ Chosen.prototype.results_build = function() {
781
+ this.parsing = true;
782
+ this.selected_option_count = null;
783
+ this.results_data = SelectParser.select_to_array(this.form_field);
784
+ if (this.is_multiple) {
785
+ this.search_choices.find("li.search-choice").remove();
786
+ } else if (!this.is_multiple) {
787
+ this.single_set_selected_text();
788
+ if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
789
+ this.search_field[0].readOnly = true;
790
+ this.container.addClass("chosen-container-single-nosearch");
791
+ } else {
792
+ this.search_field[0].readOnly = false;
793
+ this.container.removeClass("chosen-container-single-nosearch");
794
+ }
795
+ }
796
+ this.update_results_content(this.results_option_build({
797
+ first: true
798
+ }));
799
+ this.search_field_disabled();
800
+ this.show_search_field_default();
801
+ this.search_field_scale();
802
+ return this.parsing = false;
803
+ };
804
+
805
+ Chosen.prototype.result_do_highlight = function(el) {
806
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
807
+ if (el.length) {
808
+ this.result_clear_highlight();
809
+ this.result_highlight = el;
810
+ this.result_highlight.addClass("highlighted");
811
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
812
+ visible_top = this.search_results.scrollTop();
813
+ visible_bottom = maxHeight + visible_top;
814
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
815
+ high_bottom = high_top + this.result_highlight.outerHeight();
816
+ if (high_bottom >= visible_bottom) {
817
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
818
+ } else if (high_top < visible_top) {
819
+ return this.search_results.scrollTop(high_top);
820
+ }
821
+ }
822
+ };
823
+
824
+ Chosen.prototype.result_clear_highlight = function() {
825
+ if (this.result_highlight) {
826
+ this.result_highlight.removeClass("highlighted");
827
+ }
828
+ return this.result_highlight = null;
829
+ };
830
+
831
+ Chosen.prototype.results_show = function() {
832
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
833
+ this.form_field_jq.trigger("chosen:maxselected", {
834
+ chosen: this
835
+ });
836
+ return false;
837
+ }
838
+ this.container.addClass("chosen-with-drop");
839
+ this.results_showing = true;
840
+ this.search_field.focus();
841
+ this.search_field.val(this.search_field.val());
842
+ this.winnow_results();
843
+ return this.form_field_jq.trigger("chosen:showing_dropdown", {
844
+ chosen: this
845
+ });
846
+ };
847
+
848
+ Chosen.prototype.update_results_content = function(content) {
849
+ return this.search_results.html(content);
850
+ };
851
+
852
+ Chosen.prototype.results_hide = function() {
853
+ if (this.results_showing) {
854
+ this.result_clear_highlight();
855
+ this.container.removeClass("chosen-with-drop");
856
+ this.form_field_jq.trigger("chosen:hiding_dropdown", {
857
+ chosen: this
858
+ });
859
+ }
860
+ return this.results_showing = false;
861
+ };
862
+
863
+ Chosen.prototype.set_tab_index = function(el) {
864
+ var ti;
865
+ if (this.form_field.tabIndex) {
866
+ ti = this.form_field.tabIndex;
867
+ this.form_field.tabIndex = -1;
868
+ return this.search_field[0].tabIndex = ti;
869
+ }
870
+ };
871
+
872
+ Chosen.prototype.set_label_behavior = function() {
873
+ var _this = this;
874
+ this.form_field_label = this.form_field_jq.parents("label");
875
+ if (!this.form_field_label.length && this.form_field.id.length) {
876
+ this.form_field_label = $("label[for='" + this.form_field.id + "']");
877
+ }
878
+ if (this.form_field_label.length > 0) {
879
+ return this.form_field_label.bind('click.chosen', function(evt) {
880
+ if (_this.is_multiple) {
881
+ return _this.container_mousedown(evt);
882
+ } else {
883
+ return _this.activate_field();
884
+ }
885
+ });
886
+ }
887
+ };
888
+
889
+ Chosen.prototype.show_search_field_default = function() {
890
+ if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
891
+ this.search_field.val(this.default_text);
892
+ return this.search_field.addClass("default");
893
+ } else {
894
+ this.search_field.val("");
895
+ return this.search_field.removeClass("default");
896
+ }
897
+ };
898
+
899
+ Chosen.prototype.search_results_mouseup = function(evt) {
900
+ var target;
901
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
902
+ if (target.length) {
903
+ this.result_highlight = target;
904
+ this.result_select(evt);
905
+ return this.search_field.focus();
906
+ }
907
+ };
908
+
909
+ Chosen.prototype.search_results_mouseover = function(evt) {
910
+ var target;
911
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
912
+ if (target) {
913
+ return this.result_do_highlight(target);
914
+ }
915
+ };
916
+
917
+ Chosen.prototype.search_results_mouseout = function(evt) {
918
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
919
+ return this.result_clear_highlight();
920
+ }
921
+ };
922
+
923
+ Chosen.prototype.choice_build = function(item) {
924
+ var choice, close_link,
925
+ _this = this;
926
+ choice = $('<li />', {
927
+ "class": "search-choice"
928
+ }).html("<span>" + item.html + "</span>");
929
+ if (item.disabled) {
930
+ choice.addClass('search-choice-disabled');
931
+ } else {
932
+ close_link = $('<a />', {
933
+ "class": 'search-choice-close',
934
+ 'data-option-array-index': item.array_index
935
+ });
936
+ close_link.bind('click.chosen', function(evt) {
937
+ return _this.choice_destroy_link_click(evt);
938
+ });
939
+ choice.append(close_link);
940
+ }
941
+ return this.search_container.before(choice);
942
+ };
943
+
944
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
945
+ evt.preventDefault();
946
+ evt.stopPropagation();
947
+ if (!this.is_disabled) {
948
+ return this.choice_destroy($(evt.target));
949
+ }
950
+ };
951
+
952
+ Chosen.prototype.choice_destroy = function(link) {
953
+ if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
954
+ this.show_search_field_default();
955
+ if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
956
+ this.results_hide();
957
+ }
958
+ link.parents('li').first().remove();
959
+ return this.search_field_scale();
960
+ }
961
+ };
962
+
963
+ Chosen.prototype.results_reset = function() {
964
+ this.reset_single_select_options();
965
+ this.form_field.options[0].selected = true;
966
+ this.single_set_selected_text();
967
+ this.show_search_field_default();
968
+ this.results_reset_cleanup();
969
+ this.form_field_jq.trigger("change");
970
+ if (this.active_field) {
971
+ return this.results_hide();
972
+ }
973
+ };
974
+
975
+ Chosen.prototype.results_reset_cleanup = function() {
976
+ this.current_selectedIndex = this.form_field.selectedIndex;
977
+ return this.selected_item.find("abbr").remove();
978
+ };
979
+
980
+ Chosen.prototype.result_select = function(evt) {
981
+ var high, item;
982
+ if (this.result_highlight) {
983
+ high = this.result_highlight;
984
+ this.result_clear_highlight();
985
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
986
+ this.form_field_jq.trigger("chosen:maxselected", {
987
+ chosen: this
988
+ });
989
+ return false;
990
+ }
991
+ if (this.is_multiple) {
992
+ high.removeClass("active-result");
993
+ } else {
994
+ this.reset_single_select_options();
995
+ }
996
+ item = this.results_data[high[0].getAttribute("data-option-array-index")];
997
+ item.selected = true;
998
+ this.form_field.options[item.options_index].selected = true;
999
+ this.selected_option_count = null;
1000
+ if (this.is_multiple) {
1001
+ this.choice_build(item);
1002
+ } else {
1003
+ this.single_set_selected_text(item.text);
1004
+ }
1005
+ if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
1006
+ this.results_hide();
1007
+ }
1008
+ this.search_field.val("");
1009
+ if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
1010
+ this.form_field_jq.trigger("change", {
1011
+ 'selected': this.form_field.options[item.options_index].value
1012
+ });
1013
+ }
1014
+ this.current_selectedIndex = this.form_field.selectedIndex;
1015
+ return this.search_field_scale();
1016
+ }
1017
+ };
1018
+
1019
+ Chosen.prototype.single_set_selected_text = function(text) {
1020
+ if (text == null) {
1021
+ text = this.default_text;
1022
+ }
1023
+ if (text === this.default_text) {
1024
+ this.selected_item.addClass("chosen-default");
1025
+ } else {
1026
+ this.single_deselect_control_build();
1027
+ this.selected_item.removeClass("chosen-default");
1028
+ }
1029
+ return this.selected_item.find("span").text(text);
1030
+ };
1031
+
1032
+ Chosen.prototype.result_deselect = function(pos) {
1033
+ var result_data;
1034
+ result_data = this.results_data[pos];
1035
+ if (!this.form_field.options[result_data.options_index].disabled) {
1036
+ result_data.selected = false;
1037
+ this.form_field.options[result_data.options_index].selected = false;
1038
+ this.selected_option_count = null;
1039
+ this.result_clear_highlight();
1040
+ if (this.results_showing) {
1041
+ this.winnow_results();
1042
+ }
1043
+ this.form_field_jq.trigger("change", {
1044
+ deselected: this.form_field.options[result_data.options_index].value
1045
+ });
1046
+ this.search_field_scale();
1047
+ return true;
1048
+ } else {
1049
+ return false;
1050
+ }
1051
+ };
1052
+
1053
+ Chosen.prototype.single_deselect_control_build = function() {
1054
+ if (!this.allow_single_deselect) {
1055
+ return;
1056
+ }
1057
+ if (!this.selected_item.find("abbr").length) {
1058
+ this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1059
+ }
1060
+ return this.selected_item.addClass("chosen-single-with-deselect");
1061
+ };
1062
+
1063
+ Chosen.prototype.get_search_text = function() {
1064
+ if (this.search_field.val() === this.default_text) {
1065
+ return "";
1066
+ } else {
1067
+ return $('<div/>').text($.trim(this.search_field.val())).html();
1068
+ }
1069
+ };
1070
+
1071
+ Chosen.prototype.winnow_results_set_highlight = function() {
1072
+ var do_high, selected_results;
1073
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1074
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
1075
+ if (do_high != null) {
1076
+ return this.result_do_highlight(do_high);
1077
+ }
1078
+ };
1079
+
1080
+ Chosen.prototype.no_results = function(terms) {
1081
+ var no_results_html;
1082
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1083
+ no_results_html.find("span").first().html(terms);
1084
+ this.search_results.append(no_results_html);
1085
+ return this.form_field_jq.trigger("chosen:no_results", {
1086
+ chosen: this
1087
+ });
1088
+ };
1089
+
1090
+ Chosen.prototype.no_results_clear = function() {
1091
+ return this.search_results.find(".no-results").remove();
1092
+ };
1093
+
1094
+ Chosen.prototype.keydown_arrow = function() {
1095
+ var next_sib;
1096
+ if (this.results_showing && this.result_highlight) {
1097
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
1098
+ if (next_sib) {
1099
+ return this.result_do_highlight(next_sib);
1100
+ }
1101
+ } else {
1102
+ return this.results_show();
1103
+ }
1104
+ };
1105
+
1106
+ Chosen.prototype.keyup_arrow = function() {
1107
+ var prev_sibs;
1108
+ if (!this.results_showing && !this.is_multiple) {
1109
+ return this.results_show();
1110
+ } else if (this.result_highlight) {
1111
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
1112
+ if (prev_sibs.length) {
1113
+ return this.result_do_highlight(prev_sibs.first());
1114
+ } else {
1115
+ if (this.choices_count() > 0) {
1116
+ this.results_hide();
1117
+ }
1118
+ return this.result_clear_highlight();
1119
+ }
1120
+ }
1121
+ };
1122
+
1123
+ Chosen.prototype.keydown_backstroke = function() {
1124
+ var next_available_destroy;
1125
+ if (this.pending_backstroke) {
1126
+ this.choice_destroy(this.pending_backstroke.find("a").first());
1127
+ return this.clear_backstroke();
1128
+ } else {
1129
+ next_available_destroy = this.search_container.siblings("li.search-choice").last();
1130
+ if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
1131
+ this.pending_backstroke = next_available_destroy;
1132
+ if (this.single_backstroke_delete) {
1133
+ return this.keydown_backstroke();
1134
+ } else {
1135
+ return this.pending_backstroke.addClass("search-choice-focus");
1136
+ }
1137
+ }
1138
+ }
1139
+ };
1140
+
1141
+ Chosen.prototype.clear_backstroke = function() {
1142
+ if (this.pending_backstroke) {
1143
+ this.pending_backstroke.removeClass("search-choice-focus");
1144
+ }
1145
+ return this.pending_backstroke = null;
1146
+ };
1147
+
1148
+ Chosen.prototype.keydown_checker = function(evt) {
1149
+ var stroke, _ref1;
1150
+ stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1151
+ this.search_field_scale();
1152
+ if (stroke !== 8 && this.pending_backstroke) {
1153
+ this.clear_backstroke();
1154
+ }
1155
+ switch (stroke) {
1156
+ case 8:
1157
+ this.backstroke_length = this.search_field.val().length;
1158
+ break;
1159
+ case 9:
1160
+ if (this.results_showing && !this.is_multiple) {
1161
+ this.result_select(evt);
1162
+ }
1163
+ this.mouse_on_container = false;
1164
+ break;
1165
+ case 13:
1166
+ evt.preventDefault();
1167
+ break;
1168
+ case 38:
1169
+ evt.preventDefault();
1170
+ this.keyup_arrow();
1171
+ break;
1172
+ case 40:
1173
+ evt.preventDefault();
1174
+ this.keydown_arrow();
1175
+ break;
1176
+ }
1177
+ };
1178
+
1179
+ Chosen.prototype.search_field_scale = function() {
1180
+ var div, f_width, h, style, style_block, styles, w, _i, _len;
1181
+ if (this.is_multiple) {
1182
+ h = 0;
1183
+ w = 0;
1184
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
1185
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
1186
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
1187
+ style = styles[_i];
1188
+ style_block += style + ":" + this.search_field.css(style) + ";";
1189
+ }
1190
+ div = $('<div />', {
1191
+ 'style': style_block
1192
+ });
1193
+ div.text(this.search_field.val());
1194
+ $('body').append(div);
1195
+ w = div.width() + 25;
1196
+ div.remove();
1197
+ f_width = this.container.outerWidth();
1198
+ if (w > f_width - 10) {
1199
+ w = f_width - 10;
1200
+ }
1201
+ return this.search_field.css({
1202
+ 'width': w + 'px'
1203
+ });
1204
+ }
1205
+ };
1206
+
1207
+ return Chosen;
1208
+
1209
+ })(AbstractChosen);
1210
+
1211
+ }).call(this);
admin/js/chosen.proto.js ADDED
@@ -0,0 +1,1231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Chosen, a Select Box Enhancer for jQuery and Prototype
3
+ by Patrick Filler for Harvest, http://getharvest.com
4
+
5
+ Version 1.1.0
6
+ Full source at https://github.com/harvesthq/chosen
7
+ Copyright (c) 2011 Harvest http://getharvest.com
8
+
9
+ MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
10
+ This file is generated by `grunt build`, do not edit it by hand.
11
+ */
12
+
13
+ (function() {
14
+ var AbstractChosen, SelectParser, _ref,
15
+ __hasProp = {}.hasOwnProperty,
16
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
17
+
18
+ SelectParser = (function() {
19
+ function SelectParser() {
20
+ this.options_index = 0;
21
+ this.parsed = [];
22
+ }
23
+
24
+ SelectParser.prototype.add_node = function(child) {
25
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
26
+ return this.add_group(child);
27
+ } else {
28
+ return this.add_option(child);
29
+ }
30
+ };
31
+
32
+ SelectParser.prototype.add_group = function(group) {
33
+ var group_position, option, _i, _len, _ref, _results;
34
+ group_position = this.parsed.length;
35
+ this.parsed.push({
36
+ array_index: group_position,
37
+ group: true,
38
+ label: this.escapeExpression(group.label),
39
+ children: 0,
40
+ disabled: group.disabled
41
+ });
42
+ _ref = group.childNodes;
43
+ _results = [];
44
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
45
+ option = _ref[_i];
46
+ _results.push(this.add_option(option, group_position, group.disabled));
47
+ }
48
+ return _results;
49
+ };
50
+
51
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
52
+ if (option.nodeName.toUpperCase() === "OPTION") {
53
+ if (option.text !== "") {
54
+ if (group_position != null) {
55
+ this.parsed[group_position].children += 1;
56
+ }
57
+ this.parsed.push({
58
+ array_index: this.parsed.length,
59
+ options_index: this.options_index,
60
+ value: option.value,
61
+ text: option.text,
62
+ html: option.innerHTML,
63
+ selected: option.selected,
64
+ disabled: group_disabled === true ? group_disabled : option.disabled,
65
+ group_array_index: group_position,
66
+ classes: option.className,
67
+ style: option.style.cssText
68
+ });
69
+ } else {
70
+ this.parsed.push({
71
+ array_index: this.parsed.length,
72
+ options_index: this.options_index,
73
+ empty: true
74
+ });
75
+ }
76
+ return this.options_index += 1;
77
+ }
78
+ };
79
+
80
+ SelectParser.prototype.escapeExpression = function(text) {
81
+ var map, unsafe_chars;
82
+ if ((text == null) || text === false) {
83
+ return "";
84
+ }
85
+ if (!/[\&\<\>\"\'\`]/.test(text)) {
86
+ return text;
87
+ }
88
+ map = {
89
+ "<": "&lt;",
90
+ ">": "&gt;",
91
+ '"': "&quot;",
92
+ "'": "&#x27;",
93
+ "`": "&#x60;"
94
+ };
95
+ unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
96
+ return text.replace(unsafe_chars, function(chr) {
97
+ return map[chr] || "&amp;";
98
+ });
99
+ };
100
+
101
+ return SelectParser;
102
+
103
+ })();
104
+
105
+ SelectParser.select_to_array = function(select) {
106
+ var child, parser, _i, _len, _ref;
107
+ parser = new SelectParser();
108
+ _ref = select.childNodes;
109
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
110
+ child = _ref[_i];
111
+ parser.add_node(child);
112
+ }
113
+ return parser.parsed;
114
+ };
115
+
116
+ AbstractChosen = (function() {
117
+ function AbstractChosen(form_field, options) {
118
+ this.form_field = form_field;
119
+ this.options = options != null ? options : {};
120
+ if (!AbstractChosen.browser_is_supported()) {
121
+ return;
122
+ }
123
+ this.is_multiple = this.form_field.multiple;
124
+ this.set_default_text();
125
+ this.set_default_values();
126
+ this.setup();
127
+ this.set_up_html();
128
+ this.register_observers();
129
+ }
130
+
131
+ AbstractChosen.prototype.set_default_values = function() {
132
+ var _this = this;
133
+ this.click_test_action = function(evt) {
134
+ return _this.test_active_click(evt);
135
+ };
136
+ this.activate_action = function(evt) {
137
+ return _this.activate_field(evt);
138
+ };
139
+ this.active_field = false;
140
+ this.mouse_on_container = false;
141
+ this.results_showing = false;
142
+ this.result_highlighted = null;
143
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
144
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
145
+ this.disable_search = this.options.disable_search || false;
146
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
147
+ this.group_search = this.options.group_search != null ? this.options.group_search : true;
148
+ this.search_contains = this.options.search_contains || false;
149
+ this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
150
+ this.max_selected_options = this.options.max_selected_options || Infinity;
151
+ this.inherit_select_classes = this.options.inherit_select_classes || false;
152
+ this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
153
+ return this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
154
+ };
155
+
156
+ AbstractChosen.prototype.set_default_text = function() {
157
+ if (this.form_field.getAttribute("data-placeholder")) {
158
+ this.default_text = this.form_field.getAttribute("data-placeholder");
159
+ } else if (this.is_multiple) {
160
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
161
+ } else {
162
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
163
+ }
164
+ return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
165
+ };
166
+
167
+ AbstractChosen.prototype.mouse_enter = function() {
168
+ return this.mouse_on_container = true;
169
+ };
170
+
171
+ AbstractChosen.prototype.mouse_leave = function() {
172
+ return this.mouse_on_container = false;
173
+ };
174
+
175
+ AbstractChosen.prototype.input_focus = function(evt) {
176
+ var _this = this;
177
+ if (this.is_multiple) {
178
+ if (!this.active_field) {
179
+ return setTimeout((function() {
180
+ return _this.container_mousedown();
181
+ }), 50);
182
+ }
183
+ } else {
184
+ if (!this.active_field) {
185
+ return this.activate_field();
186
+ }
187
+ }
188
+ };
189
+
190
+ AbstractChosen.prototype.input_blur = function(evt) {
191
+ var _this = this;
192
+ if (!this.mouse_on_container) {
193
+ this.active_field = false;
194
+ return setTimeout((function() {
195
+ return _this.blur_test();
196
+ }), 100);
197
+ }
198
+ };
199
+
200
+ AbstractChosen.prototype.results_option_build = function(options) {
201
+ var content, data, _i, _len, _ref;
202
+ content = '';
203
+ _ref = this.results_data;
204
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
205
+ data = _ref[_i];
206
+ if (data.group) {
207
+ content += this.result_add_group(data);
208
+ } else {
209
+ content += this.result_add_option(data);
210
+ }
211
+ if (options != null ? options.first : void 0) {
212
+ if (data.selected && this.is_multiple) {
213
+ this.choice_build(data);
214
+ } else if (data.selected && !this.is_multiple) {
215
+ this.single_set_selected_text(data.text);
216
+ }
217
+ }
218
+ }
219
+ return content;
220
+ };
221
+
222
+ AbstractChosen.prototype.result_add_option = function(option) {
223
+ var classes, option_el;
224
+ if (!option.search_match) {
225
+ return '';
226
+ }
227
+ if (!this.include_option_in_results(option)) {
228
+ return '';
229
+ }
230
+ classes = [];
231
+ if (!option.disabled && !(option.selected && this.is_multiple)) {
232
+ classes.push("active-result");
233
+ }
234
+ if (option.disabled && !(option.selected && this.is_multiple)) {
235
+ classes.push("disabled-result");
236
+ }
237
+ if (option.selected) {
238
+ classes.push("result-selected");
239
+ }
240
+ if (option.group_array_index != null) {
241
+ classes.push("group-option");
242
+ }
243
+ if (option.classes !== "") {
244
+ classes.push(option.classes);
245
+ }
246
+ option_el = document.createElement("li");
247
+ option_el.className = classes.join(" ");
248
+ option_el.style.cssText = option.style;
249
+ option_el.setAttribute("data-option-array-index", option.array_index);
250
+ option_el.innerHTML = option.search_text;
251
+ return this.outerHTML(option_el);
252
+ };
253
+
254
+ AbstractChosen.prototype.result_add_group = function(group) {
255
+ var group_el;
256
+ if (!(group.search_match || group.group_match)) {
257
+ return '';
258
+ }
259
+ if (!(group.active_options > 0)) {
260
+ return '';
261
+ }
262
+ group_el = document.createElement("li");
263
+ group_el.className = "group-result";
264
+ group_el.innerHTML = group.search_text;
265
+ return this.outerHTML(group_el);
266
+ };
267
+
268
+ AbstractChosen.prototype.results_update_field = function() {
269
+ this.set_default_text();
270
+ if (!this.is_multiple) {
271
+ this.results_reset_cleanup();
272
+ }
273
+ this.result_clear_highlight();
274
+ this.results_build();
275
+ if (this.results_showing) {
276
+ return this.winnow_results();
277
+ }
278
+ };
279
+
280
+ AbstractChosen.prototype.reset_single_select_options = function() {
281
+ var result, _i, _len, _ref, _results;
282
+ _ref = this.results_data;
283
+ _results = [];
284
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
285
+ result = _ref[_i];
286
+ if (result.selected) {
287
+ _results.push(result.selected = false);
288
+ } else {
289
+ _results.push(void 0);
290
+ }
291
+ }
292
+ return _results;
293
+ };
294
+
295
+ AbstractChosen.prototype.results_toggle = function() {
296
+ if (this.results_showing) {
297
+ return this.results_hide();
298
+ } else {
299
+ return this.results_show();
300
+ }
301
+ };
302
+
303
+ AbstractChosen.prototype.results_search = function(evt) {
304
+ if (this.results_showing) {
305
+ return this.winnow_results();
306
+ } else {
307
+ return this.results_show();
308
+ }
309
+ };
310
+
311
+ AbstractChosen.prototype.winnow_results = function() {
312
+ var escapedSearchText, option, regex, regexAnchor, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
313
+ this.no_results_clear();
314
+ results = 0;
315
+ searchText = this.get_search_text();
316
+ escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
317
+ regexAnchor = this.search_contains ? "" : "^";
318
+ regex = new RegExp(regexAnchor + escapedSearchText, 'i');
319
+ zregex = new RegExp(escapedSearchText, 'i');
320
+ _ref = this.results_data;
321
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
322
+ option = _ref[_i];
323
+ option.search_match = false;
324
+ results_group = null;
325
+ if (this.include_option_in_results(option)) {
326
+ if (option.group) {
327
+ option.group_match = false;
328
+ option.active_options = 0;
329
+ }
330
+ if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
331
+ results_group = this.results_data[option.group_array_index];
332
+ if (results_group.active_options === 0 && results_group.search_match) {
333
+ results += 1;
334
+ }
335
+ results_group.active_options += 1;
336
+ }
337
+ if (!(option.group && !this.group_search)) {
338
+ option.search_text = option.group ? option.label : option.html;
339
+ option.search_match = this.search_string_match(option.search_text, regex);
340
+ if (option.search_match && !option.group) {
341
+ results += 1;
342
+ }
343
+ if (option.search_match) {
344
+ if (searchText.length) {
345
+ startpos = option.search_text.search(zregex);
346
+ text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
347
+ option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
348
+ }
349
+ if (results_group != null) {
350
+ results_group.group_match = true;
351
+ }
352
+ } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
353
+ option.search_match = true;
354
+ }
355
+ }
356
+ }
357
+ }
358
+ this.result_clear_highlight();
359
+ if (results < 1 && searchText.length) {
360
+ this.update_results_content("");
361
+ return this.no_results(searchText);
362
+ } else {
363
+ this.update_results_content(this.results_option_build());
364
+ return this.winnow_results_set_highlight();
365
+ }
366
+ };
367
+
368
+ AbstractChosen.prototype.search_string_match = function(search_string, regex) {
369
+ var part, parts, _i, _len;
370
+ if (regex.test(search_string)) {
371
+ return true;
372
+ } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
373
+ parts = search_string.replace(/\[|\]/g, "").split(" ");
374
+ if (parts.length) {
375
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
376
+ part = parts[_i];
377
+ if (regex.test(part)) {
378
+ return true;
379
+ }
380
+ }
381
+ }
382
+ }
383
+ };
384
+
385
+ AbstractChosen.prototype.choices_count = function() {
386
+ var option, _i, _len, _ref;
387
+ if (this.selected_option_count != null) {
388
+ return this.selected_option_count;
389
+ }
390
+ this.selected_option_count = 0;
391
+ _ref = this.form_field.options;
392
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
393
+ option = _ref[_i];
394
+ if (option.selected) {
395
+ this.selected_option_count += 1;
396
+ }
397
+ }
398
+ return this.selected_option_count;
399
+ };
400
+
401
+ AbstractChosen.prototype.choices_click = function(evt) {
402
+ evt.preventDefault();
403
+ if (!(this.results_showing || this.is_disabled)) {
404
+ return this.results_show();
405
+ }
406
+ };
407
+
408
+ AbstractChosen.prototype.keyup_checker = function(evt) {
409
+ var stroke, _ref;
410
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
411
+ this.search_field_scale();
412
+ switch (stroke) {
413
+ case 8:
414
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
415
+ return this.keydown_backstroke();
416
+ } else if (!this.pending_backstroke) {
417
+ this.result_clear_highlight();
418
+ return this.results_search();
419
+ }
420
+ break;
421
+ case 13:
422
+ evt.preventDefault();
423
+ if (this.results_showing) {
424
+ return this.result_select(evt);
425
+ }
426
+ break;
427
+ case 27:
428
+ if (this.results_showing) {
429
+ this.results_hide();
430
+ }
431
+ return true;
432
+ case 9:
433
+ case 38:
434
+ case 40:
435
+ case 16:
436
+ case 91:
437
+ case 17:
438
+ break;
439
+ default:
440
+ return this.results_search();
441
+ }
442
+ };
443
+
444
+ AbstractChosen.prototype.clipboard_event_checker = function(evt) {
445
+ var _this = this;
446
+ return setTimeout((function() {
447
+ return _this.results_search();
448
+ }), 50);
449
+ };
450
+
451
+ AbstractChosen.prototype.container_width = function() {
452
+ if (this.options.width != null) {
453
+ return this.options.width;
454
+ } else {
455
+ return "" + this.form_field.offsetWidth + "px";
456
+ }
457
+ };
458
+
459
+ AbstractChosen.prototype.include_option_in_results = function(option) {
460
+ if (this.is_multiple && (!this.display_selected_options && option.selected)) {
461
+ return false;
462
+ }
463
+ if (!this.display_disabled_options && option.disabled) {
464
+ return false;
465
+ }
466
+ if (option.empty) {
467
+ return false;
468
+ }
469
+ return true;
470
+ };
471
+
472
+ AbstractChosen.prototype.search_results_touchstart = function(evt) {
473
+ this.touch_started = true;
474
+ return this.search_results_mouseover(evt);
475
+ };
476
+
477
+ AbstractChosen.prototype.search_results_touchmove = function(evt) {
478
+ this.touch_started = false;
479
+ return this.search_results_mouseout(evt);
480
+ };
481
+
482
+ AbstractChosen.prototype.search_results_touchend = function(evt) {
483
+ if (this.touch_started) {
484
+ return this.search_results_mouseup(evt);
485
+ }
486
+ };
487
+
488
+ AbstractChosen.prototype.outerHTML = function(element) {
489
+ var tmp;
490
+ if (element.outerHTML) {
491
+ return element.outerHTML;
492
+ }
493
+ tmp = document.createElement("div");
494
+ tmp.appendChild(element);
495
+ return tmp.innerHTML;
496
+ };
497
+
498
+ AbstractChosen.browser_is_supported = function() {
499
+ if (window.navigator.appName === "Microsoft Internet Explorer") {
500
+ return document.documentMode >= 8;
501
+ }
502
+ if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
503
+ return true;
504
+ }
505
+ if (/Android/i.test(window.navigator.userAgent)) {
506
+ if (/Mobile/i.test(window.navigator.userAgent)) {
507
+ return true;
508
+ }
509
+ }
510
+ return true;
511
+ };
512
+
513
+ AbstractChosen.default_multiple_text = "Select Some Options";
514
+
515
+ AbstractChosen.default_single_text = "Select an Option";
516
+
517
+ AbstractChosen.default_no_result_text = "No results match";
518
+
519
+ return AbstractChosen;
520
+
521
+ })();
522
+
523
+ this.Chosen = (function(_super) {
524
+ __extends(Chosen, _super);
525
+
526
+ function Chosen() {
527
+ _ref = Chosen.__super__.constructor.apply(this, arguments);
528
+ return _ref;
529
+ }
530
+
531
+ Chosen.prototype.setup = function() {
532
+ this.current_selectedIndex = this.form_field.selectedIndex;
533
+ return this.is_rtl = this.form_field.hasClassName("chosen-rtl");
534
+ };
535
+
536
+ Chosen.prototype.set_default_values = function() {
537
+ Chosen.__super__.set_default_values.call(this);
538
+ this.single_temp = new Template('<a class="chosen-single chosen-default" tabindex="-1"><span>#{default}</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
539
+ this.multi_temp = new Template('<ul class="chosen-choices"><li class="search-field"><input type="text" value="#{default}" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
540
+ return this.no_results_temp = new Template('<li class="no-results">' + this.results_none_found + ' "<span>#{terms}</span>"</li>');
541
+ };
542
+
543
+ Chosen.prototype.set_up_html = function() {
544
+ var container_classes, container_props;
545
+ container_classes = ["chosen-container"];
546
+ container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
547
+ if (this.inherit_select_classes && this.form_field.className) {
548
+ container_classes.push(this.form_field.className);
549
+ }
550
+ if (this.is_rtl) {
551
+ container_classes.push("chosen-rtl");
552
+ }
553
+ container_props = {
554
+ 'class': container_classes.join(' '),
555
+ 'style': "width: " + (this.container_width()) + ";",
556
+ 'title': this.form_field.title
557
+ };
558
+ if (this.form_field.id.length) {
559
+ container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
560
+ }
561
+ this.container = this.is_multiple ? new Element('div', container_props).update(this.multi_temp.evaluate({
562
+ "default": this.default_text
563
+ })) : new Element('div', container_props).update(this.single_temp.evaluate({
564
+ "default": this.default_text
565
+ }));
566
+ this.form_field.hide().insert({
567
+ after: this.container
568
+ });
569
+ this.dropdown = this.container.down('div.chosen-drop');
570
+ this.search_field = this.container.down('input');
571
+ this.search_results = this.container.down('ul.chosen-results');
572
+ this.search_field_scale();
573
+ this.search_no_results = this.container.down('li.no-results');
574
+ if (this.is_multiple) {
575
+ this.search_choices = this.container.down('ul.chosen-choices');
576
+ this.search_container = this.container.down('li.search-field');
577
+ } else {
578
+ this.search_container = this.container.down('div.chosen-search');
579
+ this.selected_item = this.container.down('.chosen-single');
580
+ }
581
+ this.results_build();
582
+ this.set_tab_index();
583
+ this.set_label_behavior();
584
+ return this.form_field.fire("chosen:ready", {
585
+ chosen: this
586
+ });
587
+ };
588
+
589
+ Chosen.prototype.register_observers = function() {
590
+ var _this = this;
591
+ this.container.observe("mousedown", function(evt) {
592
+ return _this.container_mousedown(evt);
593
+ });
594
+ this.container.observe("mouseup", function(evt) {
595
+ return _this.container_mouseup(evt);
596
+ });
597
+ this.container.observe("mouseenter", function(evt) {
598
+ return _this.mouse_enter(evt);
599
+ });
600
+ this.container.observe("mouseleave", function(evt) {
601
+ return _this.mouse_leave(evt);
602
+ });
603
+ this.search_results.observe("mouseup", function(evt) {
604
+ return _this.search_results_mouseup(evt);
605
+ });
606
+ this.search_results.observe("mouseover", function(evt) {
607
+ return _this.search_results_mouseover(evt);
608
+ });
609
+ this.search_results.observe("mouseout", function(evt) {
610
+ return _this.search_results_mouseout(evt);
611
+ });
612
+ this.search_results.observe("mousewheel", function(evt) {
613
+ return _this.search_results_mousewheel(evt);
614
+ });
615
+ this.search_results.observe("DOMMouseScroll", function(evt) {
616
+ return _this.search_results_mousewheel(evt);
617
+ });
618
+ this.search_results.observe("touchstart", function(evt) {
619
+ return _this.search_results_touchstart(evt);
620
+ });
621
+ this.search_results.observe("touchmove", function(evt) {
622
+ return _this.search_results_touchmove(evt);
623
+ });
624
+ this.search_results.observe("touchend", function(evt) {
625
+ return _this.search_results_touchend(evt);
626
+ });
627
+ this.form_field.observe("chosen:updated", function(evt) {
628
+ return _this.results_update_field(evt);
629
+ });
630
+ this.form_field.observe("chosen:activate", function(evt) {
631
+ return _this.activate_field(evt);
632
+ });
633
+ this.form_field.observe("chosen:open", function(evt) {
634
+ return _this.container_mousedown(evt);
635
+ });
636
+ this.form_field.observe("chosen:close", function(evt) {
637
+ return _this.input_blur(evt);
638
+ });
639
+ this.search_field.observe("blur", function(evt) {
640
+ return _this.input_blur(evt);
641
+ });
642
+ this.search_field.observe("keyup", function(evt) {
643
+ return _this.keyup_checker(evt);
644
+ });
645
+ this.search_field.observe("keydown", function(evt) {
646
+ return _this.keydown_checker(evt);
647
+ });
648
+ this.search_field.observe("focus", function(evt) {
649
+ return _this.input_focus(evt);
650
+ });
651
+ this.search_field.observe("cut", function(evt) {
652
+ return _this.clipboard_event_checker(evt);
653
+ });
654
+ this.search_field.observe("paste", function(evt) {
655
+ return _this.clipboard_event_checker(evt);
656
+ });
657
+ if (this.is_multiple) {
658
+ return this.search_choices.observe("click", function(evt) {
659
+ return _this.choices_click(evt);
660
+ });
661
+ } else {
662
+ return this.container.observe("click", function(evt) {
663
+ return evt.preventDefault();
664
+ });
665
+ }
666
+ };
667
+
668
+ Chosen.prototype.destroy = function() {
669
+ this.container.ownerDocument.stopObserving("click", this.click_test_action);
670
+ this.form_field.stopObserving();
671
+ this.container.stopObserving();
672
+ this.search_results.stopObserving();
673
+ this.search_field.stopObserving();
674
+ if (this.form_field_label != null) {
675
+ this.form_field_label.stopObserving();
676
+ }
677
+ if (this.is_multiple) {
678
+ this.search_choices.stopObserving();
679
+ this.container.select(".search-choice-close").each(function(choice) {
680
+ return choice.stopObserving();
681
+ });
682
+ } else {
683
+ this.selected_item.stopObserving();
684
+ }
685
+ if (this.search_field.tabIndex) {
686
+ this.form_field.tabIndex = this.search_field.tabIndex;
687
+ }
688
+ this.container.remove();
689
+ return this.form_field.show();
690
+ };
691
+
692
+ Chosen.prototype.search_field_disabled = function() {
693
+ this.is_disabled = this.form_field.disabled;
694
+ if (this.is_disabled) {
695
+ this.container.addClassName('chosen-disabled');
696
+ this.search_field.disabled = true;
697
+ if (!this.is_multiple) {
698
+ this.selected_item.stopObserving("focus", this.activate_action);
699
+ }
700
+ return this.close_field();
701
+ } else {
702
+ this.container.removeClassName('chosen-disabled');
703
+ this.search_field.disabled = false;
704
+ if (!this.is_multiple) {
705
+ return this.selected_item.observe("focus", this.activate_action);
706
+ }
707
+ }
708
+ };
709
+
710
+ Chosen.prototype.container_mousedown = function(evt) {
711
+ if (!this.is_disabled) {
712
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
713
+ evt.stop();
714
+ }
715
+ if (!((evt != null) && evt.target.hasClassName("search-choice-close"))) {
716
+ if (!this.active_field) {
717
+ if (this.is_multiple) {
718
+ this.search_field.clear();
719
+ }
720
+ this.container.ownerDocument.observe("click", this.click_test_action);
721
+ this.results_show();
722
+ } else if (!this.is_multiple && evt && (evt.target === this.selected_item || evt.target.up("a.chosen-single"))) {
723
+ this.results_toggle();
724
+ }
725
+ return this.activate_field();
726
+ }
727
+ }
728
+ };
729
+
730
+ Chosen.prototype.container_mouseup = function(evt) {
731
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
732
+ return this.results_reset(evt);
733
+ }
734
+ };
735
+
736
+ Chosen.prototype.search_results_mousewheel = function(evt) {
737
+ var delta;
738
+ delta = -evt.wheelDelta || evt.detail;
739
+ if (delta != null) {
740
+ evt.preventDefault();
741
+ if (evt.type === 'DOMMouseScroll') {
742
+ delta = delta * 40;
743
+ }
744
+ return this.search_results.scrollTop = delta + this.search_results.scrollTop;
745
+ }
746
+ };
747
+
748
+ Chosen.prototype.blur_test = function(evt) {
749
+ if (!this.active_field && this.container.hasClassName("chosen-container-active")) {
750
+ return this.close_field();
751
+ }
752
+ };
753
+
754
+ Chosen.prototype.close_field = function() {
755
+ this.container.ownerDocument.stopObserving("click", this.click_test_action);
756
+ this.active_field = false;
757
+ this.results_hide();
758
+ this.container.removeClassName("chosen-container-active");
759
+ this.clear_backstroke();
760
+ this.show_search_field_default();
761
+ return this.search_field_scale();
762
+ };
763
+
764
+ Chosen.prototype.activate_field = function() {
765
+ this.container.addClassName("chosen-container-active");
766
+ this.active_field = true;
767
+ this.search_field.value = this.search_field.value;
768
+ return this.search_field.focus();
769
+ };
770
+
771
+ Chosen.prototype.test_active_click = function(evt) {
772
+ if (evt.target.up('.chosen-container') === this.container) {
773
+ return this.active_field = true;
774
+ } else {
775
+ return this.close_field();
776
+ }
777
+ };
778
+
779
+ Chosen.prototype.results_build = function() {
780
+ this.parsing = true;
781
+ this.selected_option_count = null;
782
+ this.results_data = SelectParser.select_to_array(this.form_field);
783
+ if (this.is_multiple) {
784
+ this.search_choices.select("li.search-choice").invoke("remove");
785
+ } else if (!this.is_multiple) {
786
+ this.single_set_selected_text();
787
+ if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
788
+ this.search_field.readOnly = true;
789
+ this.container.addClassName("chosen-container-single-nosearch");
790
+ } else {
791
+ this.search_field.readOnly = false;
792
+ this.container.removeClassName("chosen-container-single-nosearch");
793
+ }
794
+ }
795
+ this.update_results_content(this.results_option_build({
796
+ first: true
797
+ }));
798
+ this.search_field_disabled();
799
+ this.show_search_field_default();
800
+ this.search_field_scale();
801
+ return this.parsing = false;
802
+ };
803
+
804
+ Chosen.prototype.result_do_highlight = function(el) {
805
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
806
+ this.result_clear_highlight();
807
+ this.result_highlight = el;
808
+ this.result_highlight.addClassName("highlighted");
809
+ maxHeight = parseInt(this.search_results.getStyle('maxHeight'), 10);
810
+ visible_top = this.search_results.scrollTop;
811
+ visible_bottom = maxHeight + visible_top;
812
+ high_top = this.result_highlight.positionedOffset().top;
813
+ high_bottom = high_top + this.result_highlight.getHeight();
814
+ if (high_bottom >= visible_bottom) {
815
+ return this.search_results.scrollTop = (high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0;
816
+ } else if (high_top < visible_top) {
817
+ return this.search_results.scrollTop = high_top;
818
+ }
819
+ };
820
+
821
+ Chosen.prototype.result_clear_highlight = function() {
822
+ if (this.result_highlight) {
823
+ this.result_highlight.removeClassName('highlighted');
824
+ }
825
+ return this.result_highlight = null;
826
+ };
827
+
828
+ Chosen.prototype.results_show = function() {
829
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
830
+ this.form_field.fire("chosen:maxselected", {
831
+ chosen: this
832
+ });
833
+ return false;
834
+ }
835
+ this.container.addClassName("chosen-with-drop");
836
+ this.results_showing = true;
837
+ this.search_field.focus();
838
+ this.search_field.value = this.search_field.value;
839
+ this.winnow_results();
840
+ return this.form_field.fire("chosen:showing_dropdown", {
841
+ chosen: this
842
+ });
843
+ };
844
+
845
+ Chosen.prototype.update_results_content = function(content) {
846
+ return this.search_results.update(content);
847
+ };
848
+
849
+ Chosen.prototype.results_hide = function() {
850
+ if (this.results_showing) {
851
+ this.result_clear_highlight();
852
+ this.container.removeClassName("chosen-with-drop");
853
+ this.form_field.fire("chosen:hiding_dropdown", {
854
+ chosen: this
855
+ });
856
+ }
857
+ return this.results_showing = false;
858
+ };
859
+
860
+ Chosen.prototype.set_tab_index = function(el) {
861
+ var ti;
862
+ if (this.form_field.tabIndex) {
863
+ ti = this.form_field.tabIndex;
864
+ this.form_field.tabIndex = -1;
865
+ return this.search_field.tabIndex = ti;
866
+ }
867
+ };
868
+
869
+ Chosen.prototype.set_label_behavior = function() {
870
+ var _this = this;
871
+ this.form_field_label = this.form_field.up("label");
872
+ if (this.form_field_label == null) {
873
+ this.form_field_label = $$("label[for='" + this.form_field.id + "']").first();
874
+ }
875
+ if (this.form_field_label != null) {
876
+ return this.form_field_label.observe("click", function(evt) {
877
+ if (_this.is_multiple) {
878
+ return _this.container_mousedown(evt);
879
+ } else {
880
+ return _this.activate_field();
881
+ }
882
+ });
883
+ }
884
+ };
885
+
886
+ Chosen.prototype.show_search_field_default = function() {
887
+ if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
888
+ this.search_field.value = this.default_text;
889
+ return this.search_field.addClassName("default");
890
+ } else {
891
+ this.search_field.value = "";
892
+ return this.search_field.removeClassName("default");
893
+ }
894
+ };
895
+
896
+ Chosen.prototype.search_results_mouseup = function(evt) {
897
+ var target;
898
+ target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
899
+ if (target) {
900
+ this.result_highlight = target;
901
+ this.result_select(evt);
902
+ return this.search_field.focus();
903
+ }
904
+ };
905
+
906
+ Chosen.prototype.search_results_mouseover = function(evt) {
907
+ var target;
908
+ target = evt.target.hasClassName("active-result") ? evt.target : evt.target.up(".active-result");
909
+ if (target) {
910
+ return this.result_do_highlight(target);
911
+ }
912
+ };
913
+
914
+ Chosen.prototype.search_results_mouseout = function(evt) {
915
+ if (evt.target.hasClassName('active-result') || evt.target.up('.active-result')) {
916
+ return this.result_clear_highlight();
917
+ }
918
+ };
919
+
920
+ Chosen.prototype.choice_build = function(item) {
921
+ var choice, close_link,
922
+ _this = this;
923
+ choice = new Element('li', {
924
+ "class": "search-choice"
925
+ }).update("<span>" + item.html + "</span>");
926
+ if (item.disabled) {
927
+ choice.addClassName('search-choice-disabled');
928
+ } else {
929
+ close_link = new Element('a', {
930
+ href: '#',
931
+ "class": 'search-choice-close',
932
+ rel: item.array_index
933
+ });
934
+ close_link.observe("click", function(evt) {
935
+ return _this.choice_destroy_link_click(evt);
936
+ });
937
+ choice.insert(close_link);
938
+ }
939
+ return this.search_container.insert({
940
+ before: choice
941
+ });
942
+ };
943
+
944
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
945
+ evt.preventDefault();
946
+ evt.stopPropagation();
947
+ if (!this.is_disabled) {
948
+ return this.choice_destroy(evt.target);
949
+ }
950
+ };
951
+
952
+ Chosen.prototype.choice_destroy = function(link) {
953
+ if (this.result_deselect(link.readAttribute("rel"))) {
954
+ this.show_search_field_default();
955
+ if (this.is_multiple && this.choices_count() > 0 && this.search_field.value.length < 1) {
956
+ this.results_hide();
957
+ }
958
+ link.up('li').remove();
959
+ return this.search_field_scale();
960
+ }
961
+ };
962
+
963
+ Chosen.prototype.results_reset = function() {
964
+ this.reset_single_select_options();
965
+ this.form_field.options[0].selected = true;
966
+ this.single_set_selected_text();
967
+ this.show_search_field_default();
968
+ this.results_reset_cleanup();
969
+ if (typeof Event.simulate === 'function') {
970
+ this.form_field.simulate("change");
971
+ }
972
+ if (this.active_field) {
973
+ return this.results_hide();
974
+ }
975
+ };
976
+
977
+ Chosen.prototype.results_reset_cleanup = function() {
978
+ var deselect_trigger;
979
+ this.current_selectedIndex = this.form_field.selectedIndex;
980
+ deselect_trigger = this.selected_item.down("abbr");
981
+ if (deselect_trigger) {
982
+ return deselect_trigger.remove();
983
+ }
984
+ };
985
+
986
+ Chosen.prototype.result_select = function(evt) {
987
+ var high, item;
988
+ if (this.result_highlight) {
989
+ high = this.result_highlight;
990
+ this.result_clear_highlight();
991
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
992
+ this.form_field.fire("chosen:maxselected", {
993
+ chosen: this
994
+ });
995
+ return false;
996
+ }
997
+ if (this.is_multiple) {
998
+ high.removeClassName("active-result");
999
+ } else {
1000
+ this.reset_single_select_options();
1001
+ }
1002
+ high.addClassName("result-selected");
1003
+ item = this.results_data[high.getAttribute("data-option-array-index")];
1004
+ item.selected = true;
1005
+ this.form_field.options[item.options_index].selected = true;
1006
+ this.selected_option_count = null;
1007
+ if (this.is_multiple) {
1008
+ this.choice_build(item);
1009
+ } else {
1010
+ this.single_set_selected_text(item.text);
1011
+ }
1012
+ if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
1013
+ this.results_hide();
1014
+ }
1015
+ this.search_field.value = "";
1016
+ if (typeof Event.simulate === 'function' && (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex)) {
1017
+ this.form_field.simulate("change");
1018
+ }
1019
+ this.current_selectedIndex = this.form_field.selectedIndex;
1020
+ return this.search_field_scale();
1021
+ }
1022
+ };
1023
+
1024
+ Chosen.prototype.single_set_selected_text = function(text) {
1025
+ if (text == null) {
1026
+ text = this.default_text;
1027
+ }
1028
+ if (text === this.default_text) {
1029
+ this.selected_item.addClassName("chosen-default");
1030
+ } else {
1031
+ this.single_deselect_control_build();
1032
+ this.selected_item.removeClassName("chosen-default");
1033
+ }
1034
+ return this.selected_item.down("span").update(text);
1035
+ };
1036
+
1037
+ Chosen.prototype.result_deselect = function(pos) {
1038
+ var result_data;
1039
+ result_data = this.results_data[pos];
1040
+ if (!this.form_field.options[result_data.options_index].disabled) {
1041
+ result_data.selected = false;
1042
+ this.form_field.options[result_data.options_index].selected = false;
1043
+ this.selected_option_count = null;
1044
+ this.result_clear_highlight();
1045
+ if (this.results_showing) {
1046
+ this.winnow_results();
1047
+ }
1048
+ if (typeof Event.simulate === 'function') {
1049
+ this.form_field.simulate("change");
1050
+ }
1051
+ this.search_field_scale();
1052
+ return true;
1053
+ } else {
1054
+ return false;
1055
+ }
1056
+ };
1057
+
1058
+ Chosen.prototype.single_deselect_control_build = function() {
1059
+ if (!this.allow_single_deselect) {
1060
+ return;
1061
+ }
1062
+ if (!this.selected_item.down("abbr")) {
1063
+ this.selected_item.down("span").insert({
1064
+ after: "<abbr class=\"search-choice-close\"></abbr>"
1065
+ });
1066
+ }
1067
+ return this.selected_item.addClassName("chosen-single-with-deselect");
1068
+ };
1069
+
1070
+ Chosen.prototype.get_search_text = function() {
1071
+ if (this.search_field.value === this.default_text) {
1072
+ return "";
1073
+ } else {
1074
+ return this.search_field.value.strip().escapeHTML();
1075
+ }
1076
+ };
1077
+
1078
+ Chosen.prototype.winnow_results_set_highlight = function() {
1079
+ var do_high;
1080
+ if (!this.is_multiple) {
1081
+ do_high = this.search_results.down(".result-selected.active-result");
1082
+ }
1083
+ if (do_high == null) {
1084
+ do_high = this.search_results.down(".active-result");
1085
+ }
1086
+ if (do_high != null) {
1087
+ return this.result_do_highlight(do_high);
1088
+ }
1089
+ };
1090
+
1091
+ Chosen.prototype.no_results = function(terms) {
1092
+ this.search_results.insert(this.no_results_temp.evaluate({
1093
+ terms: terms
1094
+ }));
1095
+ return this.form_field.fire("chosen:no_results", {
1096
+ chosen: this
1097
+ });
1098
+ };
1099
+
1100
+ Chosen.prototype.no_results_clear = function() {
1101
+ var nr, _results;
1102
+ nr = null;
1103
+ _results = [];
1104
+ while (nr = this.search_results.down(".no-results")) {
1105
+ _results.push(nr.remove());
1106
+ }
1107
+ return _results;
1108
+ };
1109
+
1110
+ Chosen.prototype.keydown_arrow = function() {
1111
+ var next_sib;
1112
+ if (this.results_showing && this.result_highlight) {
1113
+ next_sib = this.result_highlight.next('.active-result');
1114
+ if (next_sib) {
1115
+ return this.result_do_highlight(next_sib);
1116
+ }
1117
+ } else {
1118
+ return this.results_show();
1119
+ }
1120
+ };
1121
+
1122
+ Chosen.prototype.keyup_arrow = function() {
1123
+ var actives, prevs, sibs;
1124
+ if (!this.results_showing && !this.is_multiple) {
1125
+ return this.results_show();
1126
+ } else if (this.result_highlight) {
1127
+ sibs = this.result_highlight.previousSiblings();
1128
+ actives = this.search_results.select("li.active-result");
1129
+ prevs = sibs.intersect(actives);
1130
+ if (prevs.length) {
1131
+ return this.result_do_highlight(prevs.first());
1132
+ } else {
1133
+ if (this.choices_count() > 0) {
1134
+ this.results_hide();
1135
+ }
1136
+ return this.result_clear_highlight();
1137
+ }
1138
+ }
1139
+ };
1140
+
1141
+ Chosen.prototype.keydown_backstroke = function() {
1142
+ var next_available_destroy;
1143
+ if (this.pending_backstroke) {
1144
+ this.choice_destroy(this.pending_backstroke.down("a"));
1145
+ return this.clear_backstroke();
1146
+ } else {
1147
+ next_available_destroy = this.search_container.siblings().last();
1148
+ if (next_available_destroy && next_available_destroy.hasClassName("search-choice") && !next_available_destroy.hasClassName("search-choice-disabled")) {
1149
+ this.pending_backstroke = next_available_destroy;
1150
+ if (this.pending_backstroke) {
1151
+ this.pending_backstroke.addClassName("search-choice-focus");
1152
+ }
1153
+ if (this.single_backstroke_delete) {
1154
+ return this.keydown_backstroke();
1155
+ } else {
1156
+ return this.pending_backstroke.addClassName("search-choice-focus");
1157
+ }
1158
+ }
1159
+ }
1160
+ };
1161
+
1162
+ Chosen.prototype.clear_backstroke = function() {
1163
+ if (this.pending_backstroke) {
1164
+ this.pending_backstroke.removeClassName("search-choice-focus");
1165
+ }
1166
+ return this.pending_backstroke = null;
1167
+ };
1168
+
1169
+ Chosen.prototype.keydown_checker = function(evt) {
1170
+ var stroke, _ref1;
1171
+ stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1172
+ this.search_field_scale();
1173
+ if (stroke !== 8 && this.pending_backstroke) {
1174
+ this.clear_backstroke();
1175
+ }
1176
+ switch (stroke) {
1177
+ case 8:
1178
+ this.backstroke_length = this.search_field.value.length;
1179
+ break;
1180
+ case 9:
1181
+ if (this.results_showing && !this.is_multiple) {
1182
+ this.result_select(evt);
1183
+ }
1184
+ this.mouse_on_container = false;
1185
+ break;
1186
+ case 13:
1187
+ evt.preventDefault();
1188
+ break;
1189
+ case 38:
1190
+ evt.preventDefault();
1191
+ this.keyup_arrow();
1192
+ break;
1193
+ case 40:
1194
+ evt.preventDefault();
1195
+ this.keydown_arrow();
1196
+ break;
1197
+ }
1198
+ };
1199
+
1200
+ Chosen.prototype.search_field_scale = function() {
1201
+ var div, f_width, h, style, style_block, styles, w, _i, _len;
1202
+ if (this.is_multiple) {
1203
+ h = 0;
1204
+ w = 0;
1205
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
1206
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
1207
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
1208
+ style = styles[_i];
1209
+ style_block += style + ":" + this.search_field.getStyle(style) + ";";
1210
+ }
1211
+ div = new Element('div', {
1212
+ 'style': style_block
1213
+ }).update(this.search_field.value.escapeHTML());
1214
+ document.body.appendChild(div);
1215
+ w = Element.measure(div, 'width') + 25;
1216
+ div.remove();
1217
+ f_width = this.container.getWidth();
1218
+ if (w > f_width - 10) {
1219
+ w = f_width - 10;
1220
+ }
1221
+ return this.search_field.setStyle({
1222
+ 'width': w + 'px'
1223
+ });
1224
+ }
1225
+ };
1226
+
1227
+ return Chosen;
1228
+
1229
+ })(AbstractChosen);
1230
+
1231
+ }).call(this);
admin/js/custom.js CHANGED
@@ -1,6 +1,5 @@
1
  (function( $ ) {
2
- $( document ).ready(function() {
3
-
4
  $('#MyDate').datepicker({dateFormat : 'yy-mm-dd'});
5
  $('#example').DataTable({"iDisplayLength" : 10,"sPaginationType": "full_numbers","oLanguage": {"sEmptyTable": "No Page Found."}});
6
  $('#example_filter').css("display","none");
@@ -33,57 +32,197 @@
33
 
34
  $("#ui-datepicker-div").css("display","none");
35
 
 
 
 
 
 
36
 
37
- $('body').on('change',"#page-setting-options",function() {
38
- $('td.countduration').css('display', 'block');
39
- $('#pagecountduration').css('display', 'block');
40
- $('.pagecountsubmit').css('display', 'block');
41
- });
 
 
 
 
 
 
 
 
 
 
 
 
42
 
 
 
43
 
44
- $('body').on('click',"#pagevisibleset",function() {
45
- var checkeoption= $("input[name='visiblesetting']:checked").val();
46
- if( checkeoption == 'disable' ){
47
- $('#pagecountduration').attr('readonly', 'true');
48
- $('#page-setting-options').prop('disabled', 'disabled');
49
-
50
- }else if( checkeoption == 'enable' ) {
51
- $('#pagecountduration').removeAttr("readonly");
52
- $('#page-setting-options').removeAttr("disabled");
 
53
  }
 
54
  });
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  $('body').on('click',".pagecountsubmit",function() {
58
- var selectoption= $("#page-setting-options").val();
59
- var countduration = $("#pagecountduration").val();
60
- var checkeoption= $("input[name='visiblesetting']:checked").val();
61
- if( checkeoption == 'disable' ){
62
- return false;
63
- }else{
64
- $.ajax({
65
- type: "POST",
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  url: pagevisit.ajaxurl,
67
  async:false,
68
  data: ({
69
- action:'add_page_count_option',
70
- select_option:selectoption,
71
- count_duration:countduration
 
72
  }),
73
  success: function(data) {
74
  $("td.record-mesage").empty();
75
  $("td.record-mesage").html("<h4 style='color:#075F0E;'>Settings saved Sucessfully.</h4>");
76
  }
77
  });
78
- }
 
79
  });
80
 
81
- // check textbox value only numeric
82
- $("#pagecountduration").keypress(function (e) {
83
- if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
84
- $("#errmsg").html("Digits Only").show().fadeOut("slow");
85
- return false;
 
 
 
 
 
 
 
 
 
 
86
  }
87
- });
88
- });
89
  })( jQuery );
1
  (function( $ ) {
2
+ $(window).load(function() {
 
3
  $('#MyDate').datepicker({dateFormat : 'yy-mm-dd'});
4
  $('#example').DataTable({"iDisplayLength" : 10,"sPaginationType": "full_numbers","oLanguage": {"sEmptyTable": "No Page Found."}});
5
  $('#example_filter').css("display","none");
32
 
33
  $("#ui-datepicker-div").css("display","none");
34
 
35
+ var selectedPostArray = JSON.parse(get_post_option.optionsarray);
36
+ var selectedPostglobalarr = [];
37
+ for( var p in selectedPostArray ){
38
+ selectedPostglobalarr.push( selectedPostArray[p] );
39
+ }
40
 
41
+ var selecteduserArray = JSON.parse(get_user_option.usersarray);
42
+ var selectedUserglobalarr = [];
43
+ for( var u in selecteduserArray ){
44
+ selectedUserglobalarr.push( selecteduserArray[u] );
45
+ }
46
+
47
+ var selectedIpArray = JSON.parse(get_ip_option.ipaddressarray);
48
+ var selectedIpglobalarr = [];
49
+ for( var i in selectedIpArray ){
50
+ selectedIpglobalarr.push( selectedIpArray[i] );
51
+ }
52
+
53
+ var userString = '';
54
+ userString = selectedUserglobalarr.join(",");
55
+
56
+ var ipString = '';
57
+ ipString = selectedIpglobalarr.join(",");
58
 
59
+ var postString = '';
60
+ postString = selectedPostglobalarr.join(",");
61
 
62
+ $('body').on('change','.posttype',function() {
63
+ var page_id = this.id
64
+ if ( $('#'+page_id).is(":checked") ) {
65
+ selectedPostglobalarr.push(page_id);
66
+ } else {
67
+ selectedPostglobalarr.indexOf(page_id);
68
+ var index = selectedPostglobalarr.indexOf(page_id);
69
+ if (index > -1) {
70
+ selectedPostglobalarr.splice(index, 1);
71
+ }
72
  }
73
+
74
  });
75
 
76
+ var config = {
77
+ '.chosen-select' : {},
78
+ '.chosen-select-deselect' : {allow_single_deselect:true},
79
+ '.chosen-select-no-single' : {disable_search_threshold:10},
80
+ '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
81
+ '.chosen-select-width' : {width:"95%"}
82
+ }
83
+ for (var selector in config) {
84
+ $(selector).chosen(config[selector]);
85
+ }
86
+
87
+
88
+ var configip = {
89
+ '.chosen-select-ip' : {},
90
+ '.chosen-select-deselect' : {allow_single_deselect:true},
91
+ '.chosen-select-no-single' : {disable_search_threshold:10},
92
+ '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
93
+ '.chosen-select-width' : {width:"95%"}
94
+ }
95
+ for (var selectorip in configip) {
96
+ $(selectorip).chosen(configip[selectorip]);
97
+ }
98
+
99
+ var configpost = {
100
+ '.chosen-select-post' : {},
101
+ '.chosen-select-deselect' : {allow_single_deselect:true},
102
+ '.chosen-select-no-single' : {disable_search_threshold:10},
103
+ '.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
104
+ '.chosen-select-width' : {width:"95%"}
105
+ }
106
+ for (var selectorpost in configpost) {
107
+ $(selectorpost).chosen(configpost[selectorpost]);
108
+ }
109
+
110
+ if(postString != '') {
111
+ $.each(postString.split(","), function(p,r){
112
+ $("#post_type option[value='" + r + "']").prop("selected", true);
113
+ $('#post_type').trigger('chosen:updated');
114
+ });
115
+ }
116
+
117
+ if(ipString != '') {
118
+ $.each(ipString.split(","), function(i,e){
119
+ $("#ip_address option[value='" + e + "']").prop("selected", true);
120
+ $('#ip_address').trigger('chosen:updated');
121
+ });
122
+ }
123
+
124
+ if(userString != '') {
125
+ $.each(userString.split(","), function(j,k){
126
+ $("#users_list option[value='" + k + "']").prop("selected", true);
127
+ $('#users_list').trigger('chosen:updated');
128
+ });
129
+ }
130
+
131
+
132
 
133
+ $('body').on('keyup','#ip_address_chosen ul.chosen-choices li.search-field input',function(evt) {
134
+ var c = evt.keyCode;
135
+
136
+ if(c == 188 || c == 13 || c == 59 || c == 186) {
137
+ if(c == 13) {
138
+ var ip = $(this).val();
139
+ }
140
+ if(c == 186) {
141
+ var ip = $(this).val().replace(";","");
142
+ }
143
+ if(c == 59) {
144
+ var ip = $(this).val().replace(";","");
145
+ }
146
+ if(c == 188) {
147
+ var ip = $(this).val().replace(",","");
148
+ }
149
+ var valid = ValidateIPaddress(ip);
150
+ if (valid == 'yes') {
151
+ $('#ip_address').append('<option value="'+ip+'">'+ip+'</option>');
152
+ $("#ip_address option[value='"+ip+"']").prop("selected", true);
153
+ $('#ip_address').trigger('chosen:updated');
154
+ }
155
+ }
156
+ });
157
+
158
+ $('body').on('blur','#ip_address_chosen ul.chosen-choices li.search-field input',function() {
159
+ var id = $(this).val().replace(",","");
160
+
161
+ var valid = ValidateIPaddress(id);
162
+ if (valid == 'yes') {
163
+ $('#ip_address').append('<option value="'+id+'">'+id+'</option>');
164
+ $("#ip_address option[value='" + id + "']").prop("selected", true);
165
+ $('#ip_address').trigger('chosen:updated');
166
+ }
167
+ });
168
+
169
+ var ipaddress = [];
170
+ var userlist = [];
171
+ var postlist = [];
172
  $('body').on('click',".pagecountsubmit",function() {
173
+
174
+ if($("#ip_address").val()) {
175
+ ipaddress = $("#ip_address").val();
176
+ } else {
177
+ ipaddress = [];
178
+ }
179
+
180
+ if($("#users_list").val()) {
181
+ userlist = $("#users_list").val();
182
+ } else {
183
+ userlist = [];
184
+ }
185
+
186
+ if($("#post_type").val()) {
187
+ postlist = $("#post_type").val();
188
+ } else {
189
+ postlist = [];
190
+ }
191
+
192
+ $.ajax({
193
+ type: "POST",
194
  url: pagevisit.ajaxurl,
195
  async:false,
196
  data: ({
197
+ action:'add_page_count_option',
198
+ selected_posttype:unique(postlist),
199
+ ipaddress:unique(ipaddress),
200
+ userlist:unique(userlist)
201
  }),
202
  success: function(data) {
203
  $("td.record-mesage").empty();
204
  $("td.record-mesage").html("<h4 style='color:#075F0E;'>Settings saved Sucessfully.</h4>");
205
  }
206
  });
207
+ });
208
+
209
  });
210
 
211
+ function unique(globalarr) {
212
+ var result = [];
213
+ $.each(globalarr, function(i, e) {
214
+ if ($.inArray(e, result) == -1) result.push(e);
215
+ });
216
+ return result;
217
+ }
218
+
219
+ function ValidateIPaddress(ipaddress) {
220
+
221
+ var ipformat = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
222
+ if (ipaddress.match(ipformat)) {
223
+ return 'yes';
224
+ } else {
225
+ return 'no';
226
  }
227
+ }
 
228
  })( jQuery );
images/1456175371_vector_65_14.png ADDED
Binary file
images/chosen-sprite.png ADDED
Binary file
images/chosen-sprite@2x.png ADDED
Binary file
includes/class-page-visit-counter-activator.php CHANGED
@@ -43,16 +43,23 @@ class class_Page_Visit_Activator {
43
  dbDelta( $sql );
44
  //add_option( 'contact_db_version', $contact_db_version );
45
  }
 
 
 
 
 
 
46
 
47
- global $current_user;
48
- get_currentuserinfo();
49
- $useremail = $current_user->user_email;
50
-
51
- $log_url = $_SERVER['HTTP_HOST'];
52
- $log_plugin_id = 6;
53
- $log_activation_status = 1;
54
- $cur_dt = date('Y-m-d');
55
- wp_remote_request('http://mdstore.projectsmd.in/webservice.php?log_url='.$log_url.'&plugin_id='.$log_plugin_id.'&activation_status='.$log_activation_status.'&activation_date='.$cur_dt.'&user_email='.$useremail.'');
 
56
 
57
  }
58
  }
43
  dbDelta( $sql );
44
  //add_option( 'contact_db_version', $contact_db_version );
45
  }
46
+
47
+ if( in_array( 'woocommerce/woocommerce.php',apply_filters('active_plugins',get_option('active_plugins'))) && !is_plugin_active_for_network( 'woocommerce/woocommerce.php' ) ) {
48
+ $flag = '1';
49
+ } else {
50
+ $flag = '0';
51
+ }
52
 
53
+ global $current_user;
54
+ get_currentuserinfo();
55
+ $useremail = $current_user->user_email;
56
+
57
+ $log_url = $_SERVER['HTTP_HOST'];
58
+ $log_plugin_id = 6;
59
+ $log_activation_status = 1;
60
+ $cur_dt = date('Y-m-d');
61
+
62
+ wp_remote_request('http://mdstore.projectsmd.in/webservice.php?log_url='.$log_url.'&plugin_id='.$log_plugin_id.'&activation_status='.$log_activation_status.'&activation_date='.$cur_dt.'&user_email='.$useremail.'&flag='.$flag);
63
 
64
  }
65
  }
includes/class-page-visit-counter.php CHANGED
@@ -118,6 +118,9 @@ class page_visit_counter {
118
  $this->loader->add_action( 'wp_ajax_select_input_page_value', $plugin_admin, 'select_input_page_value' );
119
  $this->loader->add_action( 'wp_ajax_nopriv_select_input_page_value', $plugin_admin, 'select_input_page_value' );
120
 
 
 
 
121
  }
122
 
123
  /**
@@ -134,8 +137,10 @@ class page_visit_counter {
134
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
135
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
136
 
137
- $this->loader->add_action( 'wp_ajax_insert_page_visit_counter', $plugin_public, 'insert_page_visit_counter' );
138
- $this->loader->add_action( 'wp_ajax_nopriv_insert_page_visit_counter', $plugin_public, 'insert_page_visit_counter' );
 
 
139
 
140
  if (in_array( 'woocommerce/woocommerce.php',apply_filters('active_plugins',get_option('active_plugins')))) {
141
  $this->loader->add_filter( 'woocommerce_paypal_args', $plugin_public, 'paypal_bn_code_filter',99,1 );
118
  $this->loader->add_action( 'wp_ajax_select_input_page_value', $plugin_admin, 'select_input_page_value' );
119
  $this->loader->add_action( 'wp_ajax_nopriv_select_input_page_value', $plugin_admin, 'select_input_page_value' );
120
 
121
+ $this->loader->add_action( 'admin_init', $plugin_admin, 'add_custom_meta_box_page_visit' );
122
+ $this->loader->add_action( 'save_post', $plugin_admin, 'save_custom_meta_box_page_visit' );
123
+
124
  }
125
 
126
  /**
137
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
138
  $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
139
 
140
+ //$this->loader->add_action( 'wp_ajax_insert_page_visit_counter', $plugin_public, 'insert_page_visit_counter' );
141
+ $this->loader->add_action( 'wp', $plugin_public, 'insert_page_visit_counter' );
142
+
143
+ $this->loader->add_filter( 'the_content', $plugin_public, 'insert_page_visit_counter_total_block',99 );
144
 
145
  if (in_array( 'woocommerce/woocommerce.php',apply_filters('active_plugins',get_option('active_plugins')))) {
146
  $this->loader->add_filter( 'woocommerce_paypal_args', $plugin_public, 'paypal_bn_code_filter',99,1 );
page_visit_counter.php CHANGED
@@ -7,7 +7,7 @@
7
  * Plugin URI: http://www.multidots.com/
8
  * Description: Plugin for show visited page
9
  * Author: Multidots
10
- * Version: 1.1.3
11
  * Author URI: http://www.multidots.com/
12
  */
13
  // If this file is called directly, abort.
@@ -58,4 +58,74 @@ function run_page_visit_counter() {
58
  $plugin->run();
59
 
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  run_page_visit_counter();
7
  * Plugin URI: http://www.multidots.com/
8
  * Description: Plugin for show visited page
9
  * Author: Multidots
10
+ * Version: 2.0.0
11
  * Author URI: http://www.multidots.com/
12
  */
13
  // If this file is called directly, abort.
58
  $plugin->run();
59
 
60
  }
61
+
62
+ function display_page_total_count($atts) {
63
+ global $wpdb, $wp, $post;
64
+
65
+
66
+ $pageID = $atts['id'];
67
+
68
+ if ($pageID == '' || $pageID == null) {
69
+
70
+ $pageID = get_the_ID();
71
+
72
+ if ($pageID == 0) {
73
+ $pageID = (int) get_option('page_on_front',true);
74
+ if (empty($pageID) && !isset($pageID)) {
75
+ $pageID = (int) get_option('page_for_posts',true);
76
+ }
77
+ }
78
+
79
+ if ($pageID == 0) {
80
+ $page = get_option('show_on_front',true);
81
+ if ($page == 'posts') {
82
+ $args = array(
83
+ 'numberposts' => 1,
84
+ 'orderby' => 'post_date',
85
+ 'order' => 'DESC',
86
+ 'post_type' => 'post',
87
+ 'post_status' => 'publish',
88
+ 'suppress_filters' => true );
89
+
90
+ $recent_posts = wp_get_recent_posts( $args, ARRAY_A );
91
+ foreach( $recent_posts as $recent ){
92
+ $pageID = (int) $recent["ID"];
93
+ }
94
+ }
95
+
96
+ }
97
+ }
98
+
99
+ $post = get_post($pageID);
100
+
101
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
102
+
103
+ $table_name = $wpdb->prefix."page_visit";
104
+
105
+ $pageCount = $wpdb->get_results("SELECT SUM(page_visit) as total FROM $table_name WHERE `page_id` = $pageID");
106
+
107
+ $total = (int) $pageCount[0]->total;
108
+
109
+ $html = '';
110
+
111
+ if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
112
+ $html .= '<p class="page-visit-counter-block"><img src="'.site_url().'/wp-content/plugins/page-visit-counter/images/1456175371_vector_65_14.png" /> '.$total.' total views.</p>';
113
+ } else {
114
+ $postTypeSelectedEncodeArr = json_decode($fetchSelecetedPostTypes);
115
+ if (in_array($post->post_type,$postTypeSelectedEncodeArr)) {
116
+ $innerSettings = get_post_meta($pageID,'get_page_count',true);
117
+ if ($innerSettings == '' || $innerSettings == 'yes') {
118
+ $html .= '<p class="page-visit-counter-block"><img src="'.site_url().'/wp-content/plugins/page-visit-counter/images/1456175371_vector_65_14.png" /> '.$total.' total views.</p>';
119
+ }
120
+ }
121
+ }
122
+
123
+ echo $html;
124
+ //echo $pageID;
125
+
126
+
127
+ }
128
+ add_shortcode('page_visit_counter_md','display_page_total_count');
129
+
130
+
131
  run_page_visit_counter();
public/class-page-visit-counter-public.php CHANGED
@@ -58,7 +58,10 @@ class page_visit_counter_Public {
58
  * @since 1.0.0
59
  */
60
  public function enqueue_styles() {
61
-
 
 
 
62
  }
63
  /**
64
  * Register the JavaScript for the admin area.
@@ -88,128 +91,277 @@ class page_visit_counter_Public {
88
 
89
  // Check the site running on HTTPS. If the site running on HTTPS then we are removing S from HTTPS
90
  if (is_ssl()) {
91
- $page = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$pageurl));
 
92
  } else {
93
- $page = url_to_postid( $pageurl );
 
94
  }
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  $table_name = $wpdb->prefix."page_visit";
97
  $last_date = '';
98
  $page_contet = get_post( $page );
99
- $check_page_content = isset( $page_contet->post_type)? $page_contet->post_type :'';
100
- $get_option_value = json_decode(get_option( 'page_count_settings' ));
101
- $option_value = $get_option_value[0];
102
- $count_value = $get_option_value[1];
103
- /**
104
- * check condition for
105
- * day,week,month,year
106
- * check lastdate for page
107
- */
108
- //check option value is day
109
- if( $option_value == 'day' ) {
110
- $day = $count_value;
111
- $get_last_date = date('Y-m-d', strtotime("+".$day." days"));
112
- //if( $page_contet->post_type == 'page' ){
113
- if( $check_page_content == 'page' ){
114
- $last_date = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' ORDER BY date DESC LIMIT 1");
115
- $last_date = isset($last_date[0]->lastdate) ? $last_date[0]->lastdate : '';
116
- $currentdate= date("Y-m-d");
117
- $ipaddress = $_SERVER['REMOTE_ADDR'];
118
- if( $last_date != $currentdate ){
119
- if ( !current_user_can('administrator') ) {
120
- $select_Query = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' AND ipaddress='$ipaddress' AND date between '".$currentdate."' AND '".$last_date."'");
121
- $size_data = sizeof($select_Query);
122
- if( $size_data == 1 ){
123
- $update_Query = $wpdb->query("UPDATE $table_name SET lastdate = '".$get_last_date."' WHERE page_id='".$page."' AND ipaddress='$ipaddress'");
124
- }
125
- if( $size_data == 0 ){
126
- if( $page != 0 ) {
127
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,'$currentdate','$get_last_date','$ipaddress')");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
  }
130
  }
131
- }
132
- }
133
- //check option value is week
134
- } else if( $option_value == 'week' ) {
135
- $day = $count_value;
136
- $get_last_date = date('Y-m-d', strtotime("+".$day." week"));
137
- //if( $page_contet->post_type == 'page' ){
138
- if( $check_page_content == 'page' ){
139
- $last_date = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' ORDER BY date DESC LIMIT 1");
140
- $last_date = isset($last_date[0]->lastdate) ? $last_date[0]->lastdate : '';
141
- $currentdate= date("Y-m-d");
142
- $ipaddress = $_SERVER['REMOTE_ADDR'];
143
- if( $last_date != $currentdate ){
144
- if ( !current_user_can('administrator') ) {
145
- $select_Query = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' AND ipaddress='$ipaddress' AND date between '".$currentdate."' AND '".$last_date."'");
146
- $size_data = sizeof($select_Query);
147
- if( $size_data == 1 ){
148
- $update_Query = $wpdb->query("UPDATE $table_name SET lastdate = '".$get_last_date."' WHERE page_id='".$page."' AND ipaddress='$ipaddress'");
149
- }
150
- if( $size_data == 0 ){
151
- if( $page != 0 ) {
152
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,'$currentdate','$get_last_date','$ipaddress')");
153
 
 
 
 
 
 
 
 
 
 
154
  }
155
  }
 
 
 
 
 
 
 
 
156
  }
157
  }
158
  }
159
- //check option value is month
160
- } else if( $option_value == 'month' ){
161
- $day = $count_value;
162
- $get_last_date = date('Y-m-d', strtotime("+".$day." month"));
163
- //if( $page_contet->post_type == 'page' ){
164
- if( $check_page_content == 'page' ){
165
- $last_date = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' ORDER BY date DESC LIMIT 1");
166
- $last_date = isset($last_date[0]->lastdate) ? $last_date[0]->lastdate : '';
167
- $currentdate= date("Y-m-d");
168
- $ipaddress = $_SERVER['REMOTE_ADDR'];
169
- if( $last_date != $currentdate ){
170
- if ( !current_user_can('administrator') ) {
171
- $select_Query = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' AND ipaddress='$ipaddress' AND date between '".$currentdate."' AND '".$last_date."'");
172
- $size_data = sizeof($select_Query);
173
- if( $size_data == 1 ){
174
- $update_Query = $wpdb->query("UPDATE $table_name SET lastdate = '".$get_last_date."' WHERE page_id='".$page."' AND ipaddress='$ipaddress'");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
- if( $size_data == 0 ){
177
- if( $page != 0 ) {
178
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,'$currentdate','$get_last_date','$ipaddress')");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  }
180
  }
181
  }
182
  }
183
  }
184
- //check option value is year
185
- } else if( $option_value == 'year' ){
186
- $day = $count_value;
187
- $get_last_date = date('Y-m-d', strtotime("+".$day." year"));
188
- //if( $page_contet->post_type == 'page' ){
189
- if( $check_page_content == 'page' ){
190
- $last_date = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' ORDER BY date DESC LIMIT 1");
191
- $last_date = isset($last_date[0]->lastdate) ? $last_date[0]->lastdate : '';
192
- $currentdate= date("Y-m-d");
193
- $ipaddress = $_SERVER['REMOTE_ADDR'];
194
- if( $last_date != $currentdate ){
195
- if ( !current_user_can('administrator') ) {
196
- $select_Query = $wpdb->get_results("SELECT * from $table_name where page_id='".$page."' AND ipaddress='$ipaddress' AND date between '".$currentdate."' AND '".$last_date."'");
197
- $size_data = sizeof($select_Query);
198
- if( $size_data == 1 ){
199
- $update_Query = $wpdb->query("UPDATE $table_name SET lastdate = '".$get_last_date."' WHERE page_id='".$page."' AND ipaddress='$ipaddress'");
200
- }
201
- if( $size_data == 0 ){
202
- if( $page != 0 ) {
203
- $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,'$currentdate','$get_last_date','$ipaddress')");
204
-
205
- }
206
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
  }
210
  }
 
 
 
211
  }
212
-
213
  /**
214
  * BN code added
215
  */
58
  * @since 1.0.0
59
  */
60
  public function enqueue_styles() {
61
+ global $wp;
62
+
63
+ wp_enqueue_style('counter-style', plugin_dir_url( __FILE__ ) . 'css/counter-style.css');
64
+
65
  }
66
  /**
67
  * Register the JavaScript for the admin area.
91
 
92
  // Check the site running on HTTPS. If the site running on HTTPS then we are removing S from HTTPS
93
  if (is_ssl()) {
94
+ $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
95
+ $page = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$actual_link));
96
  } else {
97
+ $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
98
+ $page = url_to_postid( $actual_link );
99
  }
100
 
101
+
102
+ if ($page == 0) {
103
+ $page = (int) get_option('page_on_front',true);
104
+ if (empty($page) && !isset($page)) {
105
+ $page = (int) get_option('page_for_posts',true);
106
+ }
107
+ }
108
+
109
+ if ($page == 0) {
110
+ $page = get_option('show_on_front',true);
111
+ if ($page == 'posts') {
112
+ $args = array(
113
+ 'numberposts' => 1,
114
+ 'orderby' => 'post_date',
115
+ 'order' => 'DESC',
116
+ 'post_type' => 'post',
117
+ 'post_status' => 'publish',
118
+ 'suppress_filters' => true );
119
+
120
+ $recent_posts = wp_get_recent_posts( $args, ARRAY_A );
121
+ foreach( $recent_posts as $recent ){
122
+ $page = (int) $recent["ID"];
123
+ }
124
+ }
125
+
126
+ }
127
+
128
+
129
  $table_name = $wpdb->prefix."page_visit";
130
  $last_date = '';
131
  $page_contet = get_post( $page );
132
+
133
+ $currentdate= date("Y-m-d");
134
+ $ipaddress = $_SERVER['REMOTE_ADDR'];
135
+
136
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
137
+ $postTypeSelectedDecodeArr = !empty( $fetchSelecetedPostTypes ) ? $fetchSelecetedPostTypes : json_encode( array() );
138
+
139
+
140
+ $fetchSelecetedIpAddress = get_option('ipaddress_visit');
141
+ $optionsIpAddressDecodedArr = !empty( $fetchSelecetedIpAddress ) ? $fetchSelecetedIpAddress : json_encode( array() );
142
+
143
+
144
+ $fetchSelecetedUserId = get_option('userlist_visit');
145
+ $optionsUserIdDecodedArr = !empty( $fetchSelecetedUserId ) ? $fetchSelecetedUserId : json_encode( array() );
146
+
147
+
148
+ $pageCount = $wpdb->get_results("SELECT * from $table_name where page_id=$page AND ipaddress = '$ipaddress' AND date = '$currentdate' LIMIT 1");
149
+
150
+ $getPageSetting = get_post_meta($page,'get_page_count',true);
151
+
152
+ // old version plugin
153
+ if ($fetchSelecetedPostTypes == '') {
154
+
155
+ // Check current page/post metabox settings is blank OR selected value is yes
156
+ if ($getPageSetting == '' || $getPageSetting == 'yes') {
157
+
158
+ // Check IP Address set in settings page if yes
159
+ if (isset($fetchSelecetedIpAddress) && !empty($fetchSelecetedIpAddress)) {
160
+ $optionsIpAddressEncodeArr = json_decode($optionsIpAddressDecodedArr);
161
+ // Check IP Address not listed in settings page then go ahed
162
+ if (!in_array($ipaddress,$optionsIpAddressEncodeArr)) {
163
+
164
+ // Check users set in settings page if yes
165
+ if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
166
+
167
+ $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
168
+ $user_id = get_current_user_id();
169
+
170
+ // Check user not listed in settings page then go ahed
171
+ if (!in_array($user_id,$optionsUserIdEncodeArr)) {
172
+
173
+ if (isset($pageCount) && !empty($pageCount)) {
174
+ $existingtotal = (int) $pageCount[0]->page_visit;
175
+ $totalFinal = $existingtotal + 1;
176
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
177
+ } else {
178
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
179
+ }
180
+ }
181
+ } else {
182
+ if (isset($pageCount) && !empty($pageCount)) {
183
+ $existingtotal = (int) $pageCount[0]->page_visit;
184
+ $totalFinal = $existingtotal + 1;
185
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
186
+ } else {
187
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
188
  }
189
  }
190
  }
191
+ } else {
192
+ if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
193
+
194
+ $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
195
+ $user_id = get_current_user_id();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
+ // Check user not listed in settings page then go ahed
198
+ if (!in_array($user_id,$optionsUserIdEncodeArr)) {
199
+
200
+ if (isset($pageCount) && !empty($pageCount)) {
201
+ $existingtotal = (int) $pageCount[0]->page_visit;
202
+ $totalFinal = $existingtotal + 1;
203
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
204
+ } else {
205
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
206
  }
207
  }
208
+ } else {
209
+ if (isset($pageCount) && !empty($pageCount)) {
210
+ $existingtotal = (int) $pageCount[0]->page_visit;
211
+ $totalFinal = $existingtotal + 1;
212
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
213
+ } else {
214
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
215
+ }
216
  }
217
  }
218
  }
219
+
220
+ } else {
221
+
222
+ $postTypeSelectedEncodeArr = json_decode($postTypeSelectedDecodeArr);
223
+ $getPageSetting = get_post_meta($page,'get_page_count',true);
224
+
225
+ // Check current page/post type exist in settings page array
226
+ if (in_array($page_contet->post_type,$postTypeSelectedEncodeArr)) {
227
+
228
+ // Check current page/post metabox settings is blank OR selected value is yes
229
+ if ($getPageSetting == '' || $getPageSetting == 'yes') {
230
+
231
+ // Check IP Address set in settings page if yes
232
+ if (isset($fetchSelecetedIpAddress) && !empty($fetchSelecetedIpAddress)) {
233
+
234
+ $optionsIpAddressEncodeArr = json_decode($optionsIpAddressDecodedArr);
235
+ // Check IP Address not listed in settings page then go ahed
236
+ if (!in_array($ipaddress,$optionsIpAddressEncodeArr)) {
237
+
238
+ // Check users set in settings page if yes
239
+ if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
240
+
241
+ $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
242
+ $user_id = get_current_user_id();
243
+
244
+ // Check user not listed in settings page then go ahed
245
+ if (!in_array($user_id,$optionsUserIdEncodeArr)) {
246
+
247
+ if (isset($pageCount) && !empty($pageCount)) {
248
+ $existingtotal = (int) $pageCount[0]->page_visit;
249
+ $totalFinal = $existingtotal + 1;
250
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
251
+ } else {
252
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
253
+ }
254
+ }
255
+ } else {
256
+ if (isset($pageCount) && !empty($pageCount)) {
257
+ $existingtotal = (int) $pageCount[0]->page_visit;
258
+ $totalFinal = $existingtotal + 1;
259
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
260
+ } else {
261
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
262
+ }
263
+ }
264
  }
265
+ } else {
266
+ // Check users set in settings page if yes
267
+ if (isset($fetchSelecetedUserId) && !empty($fetchSelecetedUserId)) {
268
+
269
+ $optionsUserIdEncodeArr = json_decode($optionsUserIdDecodedArr);
270
+ $user_id = get_current_user_id();
271
+
272
+ // Check user not listed in settings page then go ahed
273
+ if (!in_array($user_id,$optionsUserIdEncodeArr)) {
274
+
275
+ if (isset($pageCount) && !empty($pageCount)) {
276
+ $existingtotal = (int) $pageCount[0]->page_visit;
277
+ $totalFinal = $existingtotal + 1;
278
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
279
+ } else {
280
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
281
+ }
282
+ }
283
+ } else {
284
+ if (isset($pageCount) && !empty($pageCount)) {
285
+ $existingtotal = (int) $pageCount[0]->page_visit;
286
+ $totalFinal = $existingtotal + 1;
287
+ $update_Query = $wpdb->query("UPDATE $table_name SET page_visit = $totalFinal WHERE page_id='".$page."' AND ipaddress='$ipaddress' AND date = '$currentdate'");
288
+ } else {
289
+ $insert_Query = $wpdb->query("INSERT into $table_name (`page_id`,`page_visit`,`date`,`lastdate`,`ipaddress`) VALUES($page,1,NOW(),NOW(),'$ipaddress')");
290
  }
291
  }
292
  }
293
  }
294
  }
295
+ }
296
+ }
297
+
298
+
299
+
300
+ public function insert_page_visit_counter_total_block($content) {
301
+ global $wpdb, $wp, $post;
302
+
303
+ if (is_ssl()) {
304
+ $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
305
+ $pageID = url_to_postid(preg_replace('/^https(?=:\/\/)/i','http',$actual_link));
306
+ } else {
307
+ $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
308
+ $pageID = url_to_postid( $actual_link );
309
+ }
310
+
311
+ if ($pageID == 0) {
312
+ $pageID = (int) get_option('page_on_front',true);
313
+ if (empty($pageID) && !isset($pageID)) {
314
+ $pageID = (int) get_option('page_for_posts',true);
315
+ }
316
+ }
317
+
318
+ if ($pageID == 0) {
319
+ $page = get_option('show_on_front',true);
320
+ if ($page == 'posts') {
321
+ $args = array(
322
+ 'numberposts' => 1,
323
+ 'orderby' => 'post_date',
324
+ 'order' => 'DESC',
325
+ 'post_type' => 'post',
326
+ 'post_status' => 'publish',
327
+ 'suppress_filters' => true );
328
+
329
+ $recent_posts = wp_get_recent_posts( $args, ARRAY_A );
330
+ foreach( $recent_posts as $recent ){
331
+ $pageID = (int) $recent["ID"];
332
  }
333
+ }
334
+
335
+ }
336
+
337
+ $post = get_post($pageID);
338
+
339
+ $fetchSelecetedPostTypes = get_option('wfap_post_type');
340
+
341
+ $table_name = $wpdb->prefix."page_visit";
342
+
343
+ $pageCount = $wpdb->get_results("SELECT SUM(page_visit) as total FROM $table_name WHERE `page_id` = $pageID");
344
+
345
+ $total = (int) $pageCount[0]->total;
346
+
347
+ $html = '';
348
+
349
+ if ($fetchSelecetedPostTypes == '' || $fetchSelecetedPostTypes == null) {
350
+ $html .= '<p class="page-visit-counter-block"><img src="'.site_url().'/wp-content/plugins/page-visit-counter/images/1456175371_vector_65_14.png" /> '.$total.' total views.</p>';
351
+ } else {
352
+ $postTypeSelectedEncodeArr = json_decode($fetchSelecetedPostTypes);
353
+ if (in_array($post->post_type,$postTypeSelectedEncodeArr)) {
354
+ $innerSettings = get_post_meta($pageID,'get_page_count',true);
355
+ if ($innerSettings == '' || $innerSettings == 'yes') {
356
+ $html .= '<p class="page-visit-counter-block"><img src="'.site_url().'/wp-content/plugins/page-visit-counter/images/1456175371_vector_65_14.png" /> '.$total.' total views.</p>';
357
  }
358
  }
359
  }
360
+
361
+ return $content.' '.$html;
362
+
363
  }
364
+
365
  /**
366
  * BN code added
367
  */
public/css/counter-style.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ .counter-block {padding: 5px;border: 1px solid #656945;width: 40%;float: right;text-align: center;}
2
+ .counter-block h3 {margin: 0 !important;}
3
+ .counter-block p {margin: 0;}
4
+ .counter-block span {font-size: 10px;}