Version Description
Fixed: User guide links
Fixed: Bug on datepicker
Fixed: Error when deleting the web property
Added: Validation on the form for adding goals
Download this release
Release Info
Developer | webdorado |
Plugin | WD Google Analytics |
Version | 1.0.6 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 1.0.6
- admin/gawd_google_class.php +1 -1
- admin/pages/custom_reports.php +2 -2
- admin/pages/dashboard.php +4 -4
- admin/pages/goals.php +33 -3
- admin/pages/overview.php +2 -2
- admin/pages/settings.php +6 -6
- admin/pages/tracking.php +3 -3
- assets/freePages/alerts.png +0 -0
- assets/freePages/custom_dimensions.png +0 -0
- assets/freePages/custom_reports.png +0 -0
- assets/freePages/exclude_tracking.png +0 -0
- assets/freePages/pushovers.png +0 -0
- gawd_class.php +28 -4
- google-analytics-wd.php +3 -3
- inc/css/bootstrap.css +1 -1
- inc/css/gawd_admin.css +28 -5
- inc/css/notices.css +89 -0
- inc/js/daterangepicker.js +1560 -1544
- inc/js/gawd_admin.js +2 -2
- inc/js/gawd_front.js +276 -276
- include/gawd-notices-class.php +232 -0
- readme.txt +7 -1
admin/gawd_google_class.php
CHANGED
@@ -30,7 +30,7 @@ class GAWD_google_client {
|
|
30 |
*/
|
31 |
private function set_google_client() {
|
32 |
|
33 |
-
$access_token = $this->gawd_user_data['access_token'];
|
34 |
$this->google_client->setAccessToken($access_token);
|
35 |
|
36 |
if ($this->google_client->isAccessTokenExpired()) {
|
30 |
*/
|
31 |
private function set_google_client() {
|
32 |
|
33 |
+
$access_token = isset($this->gawd_user_data['access_token']) ? $this->gawd_user_data['access_token'] : '' ;
|
34 |
$this->google_client->setAccessToken($access_token);
|
35 |
|
36 |
if ($this->google_client->isAccessTokenExpired()) {
|
admin/pages/custom_reports.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
2 |
-
This section lets add and manage custom reports.
|
3 |
-
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/custom-reports.html">Read
|
4 |
</div>
|
5 |
<img style="margin-top:10px" src="<?php echo GAWD_URL . '/assets/freePages/custom_reports.png';?>"/>
|
6 |
|
1 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
2 |
+
This section lets add and manage custom reports.
|
3 |
+
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/custom-reports.html">Read more in User Guide.</a>
|
4 |
</div>
|
5 |
<img style="margin-top:10px" src="<?php echo GAWD_URL . '/assets/freePages/custom_reports.png';?>"/>
|
6 |
|
admin/pages/dashboard.php
CHANGED
@@ -16,8 +16,8 @@ if($current_user != 1 && isset($saved_user_menues[$current_user])){
|
|
16 |
}
|
17 |
?>
|
18 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
19 |
-
Keep track of all Google Analytics reports on this page.
|
20 |
-
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/reports.html">Read
|
21 |
</div>
|
22 |
<form method="post" id="gawd_view">
|
23 |
|
@@ -542,8 +542,8 @@ if($current_user != 1 && isset($saved_user_menues[$current_user])){
|
|
542 |
<div id="gawd_buttons">
|
543 |
<span id="country_filter_reset" class="button_gawd">Back</span>
|
544 |
<span class='clear'></span>
|
545 |
-
<input class="button_gawd" type="button" id="gawd_export_buttons" value="
|
546 |
-
<input class="button_gawd load_tooltip" type="button" id="gawd_email_button" data-hint="Click to forward this report to selected email recipients, or schedule emails to be sent out periodically." value="
|
547 |
<div class="gawd_exports">
|
548 |
<a class='button gawd_export_button_csv' href="">CSV</a>
|
549 |
<a class='button gawd_export_button_pdf' href="#">PDF</a>
|
16 |
}
|
17 |
?>
|
18 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
19 |
+
Keep track of all Google Analytics reports on this page.
|
20 |
+
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/reports.html">Read more in User Guide.</a>
|
21 |
</div>
|
22 |
<form method="post" id="gawd_view">
|
23 |
|
542 |
<div id="gawd_buttons">
|
543 |
<span id="country_filter_reset" class="button_gawd">Back</span>
|
544 |
<span class='clear'></span>
|
545 |
+
<input class="button_gawd" type="button" id="gawd_export_buttons" value="Export"/>
|
546 |
+
<input class="button_gawd load_tooltip" type="button" id="gawd_email_button" data-hint="Click to forward this report to selected email recipients, or schedule emails to be sent out periodically." value="Email"/>
|
547 |
<div class="gawd_exports">
|
548 |
<a class='button gawd_export_button_csv' href="">CSV</a>
|
549 |
<a class='button gawd_export_button_pdf' href="#">PDF</a>
|
admin/pages/goals.php
CHANGED
@@ -17,8 +17,8 @@ if (!is_array($goals)) {
|
|
17 |
?>
|
18 |
<div class="goal_wrap">
|
19 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
20 |
-
This section allows you to add Google Analytics goals for current domain.
|
21 |
-
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/goal-management.html">Read
|
22 |
</div>
|
23 |
<h3 class="gawd_page_titles">Goal Management</h3>
|
24 |
|
@@ -260,12 +260,42 @@ if (!is_array($goals)) {
|
|
260 |
}
|
261 |
});
|
262 |
jQuery('.button_gawd').on('click',function(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
if(jQuery('.gawd_table tr').length -1 >= 20){
|
264 |
alert('You have reached the maximum number of goals.')
|
265 |
return;
|
266 |
}
|
267 |
jQuery('#goal_max_id').val(jQuery('.gawd_rows').length);
|
268 |
-
|
|
|
|
|
|
|
269 |
});
|
270 |
jQuery('.gawd_goal_profile').on('change', function(){
|
271 |
jQuery('.gawd_table').each(function(){
|
17 |
?>
|
18 |
<div class="goal_wrap">
|
19 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
20 |
+
This section allows you to add Google Analytics goals for current domain.
|
21 |
+
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/goal-management.html">Read more in User Guide.</a>
|
22 |
</div>
|
23 |
<h3 class="gawd_page_titles">Goal Management</h3>
|
24 |
|
260 |
}
|
261 |
});
|
262 |
jQuery('.button_gawd').on('click',function(){
|
263 |
+
var submit_form = true;
|
264 |
+
var gawd_goal_name = jQuery("#gawd_goal_name");
|
265 |
+
var gawd_goal_name = jQuery("#gawd_goal_name");
|
266 |
+
if(gawd_goal_name.val()=== ""){
|
267 |
+
gawd_goal_name.addClass('gawd_invalid');
|
268 |
+
submit_form = false;
|
269 |
+
}
|
270 |
+
else if(
|
271 |
+
(jQuery('input[name="gawd_page_sessions"]').val() === '' && jQuery('.gawd_goal_type :selected').val() == 'VISIT_NUM_PAGES') ||
|
272 |
+
(jQuery('input[name="gawd_page_url"]').val() === '' && jQuery('.gawd_goal_type :selected').val() == 'URL_DESTINATION') ||
|
273 |
+
((jQuery('input[name="gawd_visit_hour"]').val() === '' || jQuery('input[name="gawd_visit_minute"]').val() === '' || jQuery('input[name="gawd_visit_second"]').val() === '') && jQuery('.gawd_goal_type :selected').val() == 'VISIT_TIME_ON_SITE')){
|
274 |
+
jQuery('input[name="gawd_page_url"]').addClass('gawd_invalid');
|
275 |
+
jQuery('input[name="gawd_page_sessions"]').addClass('gawd_invalid');
|
276 |
+
jQuery('input[name="gawd_visit_hour"]').addClass('gawd_invalid');
|
277 |
+
jQuery('input[name="gawd_visit_minute"]').addClass('gawd_invalid');
|
278 |
+
jQuery('input[name="gawd_visit_second"]').addClass('gawd_invalid');
|
279 |
+
submit_form = false;
|
280 |
+
}
|
281 |
+
else{
|
282 |
+
gawd_goal_name.removeClass('gawd_invalid');
|
283 |
+
jQuery('input[name="gawd_page_url"]').removeClass('gawd_invalid');
|
284 |
+
jQuery('input[name="gawd_page_sessions"]').removeClass('gawd_invalid');
|
285 |
+
jQuery('input[name="gawd_visit_hour"]').removeClass('gawd_invalid');
|
286 |
+
jQuery('input[name="gawd_visit_minute"]').removeClass('gawd_invalid');
|
287 |
+
jQuery('input[name="gawd_visit_second"]').removeClass('gawd_invalid');
|
288 |
+
}
|
289 |
+
|
290 |
if(jQuery('.gawd_table tr').length -1 >= 20){
|
291 |
alert('You have reached the maximum number of goals.')
|
292 |
return;
|
293 |
}
|
294 |
jQuery('#goal_max_id').val(jQuery('.gawd_rows').length);
|
295 |
+
if(submit_form){
|
296 |
+
jQuery('#gawd_goal_form').submit();
|
297 |
+
return false;
|
298 |
+
}
|
299 |
});
|
300 |
jQuery('.gawd_goal_profile').on('change', function(){
|
301 |
jQuery('.gawd_table').each(function(){
|
admin/pages/overview.php
CHANGED
@@ -13,8 +13,8 @@ $new_buttons_full = '<button data-hint="Click to navigate to Real Time report on
|
|
13 |
|
14 |
<?php screen_icon('options-general'); ?>
|
15 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
16 |
-
This section lets you check the audience overview of your website.
|
17 |
-
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/quick-start/overview.html">Read
|
18 |
</div>
|
19 |
<h2 style="margin-top:10px" class="gawd_page_titles"><?php echo get_admin_page_title(); ?></h2>
|
20 |
<div class="gawd_wrap">
|
13 |
|
14 |
<?php screen_icon('options-general'); ?>
|
15 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
16 |
+
This section lets you check the audience overview of your website.
|
17 |
+
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/quick-start/overview.html">Read more in User Guide.</a>
|
18 |
</div>
|
19 |
<h2 style="margin-top:10px" class="gawd_page_titles"><?php echo get_admin_page_title(); ?></h2>
|
20 |
<div class="gawd_wrap">
|
admin/pages/settings.php
CHANGED
@@ -43,8 +43,8 @@ $post_page_chart = isset($gawd_settings['post_page_chart']) ? $gawd_settings['po
|
|
43 |
|
44 |
<div id="gawd_body">
|
45 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
46 |
-
Authenticate your Google account and customize Google Analytics settings in this section.
|
47 |
-
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/settings.html">Read
|
48 |
</div>
|
49 |
<div class="resp_menu"><div class="menu_img"></div><div class="button_label">SETTINGS</div><div class="clear"></div></div>
|
50 |
<div class="gawd_menu_coteiner gawd_settings_menu_coteiner">
|
@@ -103,7 +103,7 @@ $post_page_chart = isset($gawd_settings['post_page_chart']) ? $gawd_settings['po
|
|
103 |
<div class="gawd_goal_input">
|
104 |
<input type="text" value="<?php echo isset($own_cliend_id) ? $own_cliend_id : '';?>" name="gawd_own_client_id"/>
|
105 |
</div>
|
106 |
-
<div class="gawd_info" title="Paste Client ID key. For more information about getting project keys please check the plugin
|
107 |
<div class='clear'></div>
|
108 |
</div>
|
109 |
<div class="gawd_goal_row">
|
@@ -111,7 +111,7 @@ $post_page_chart = isset($gawd_settings['post_page_chart']) ? $gawd_settings['po
|
|
111 |
<div class="gawd_goal_input">
|
112 |
<input type="text" value="<?php echo isset($own_cliend_secret) ? $own_cliend_secret : '';?>" name="gawd_own_client_secret"/>
|
113 |
</div>
|
114 |
-
<div class="gawd_info" title="Paste Client Secret key. For more information about getting project keys please check the plugin
|
115 |
<div class='clear'></div>
|
116 |
</div>
|
117 |
</div>
|
@@ -322,7 +322,7 @@ $post_page_chart = isset($gawd_settings['post_page_chart']) ? $gawd_settings['po
|
|
322 |
<span class="onoffswitch-switch"></span>
|
323 |
</label>
|
324 |
</div>
|
325 |
-
<div class="gawd_info" title="Turn this option on to get AdSense tracking reports. Make sure to link your Google AdSense to Google Analytics first (find out more in plugin
|
326 |
<div class="onoffswitch_text">
|
327 |
Enable AdSense link tracking <a target="_blank" href="https://web-dorado.com/products/wordpress-google-analytics-plugin.html" class="gawd_pro"> ( This feature is available in Google Analytics WD Pro. )</a>
|
328 |
</div>
|
@@ -533,7 +533,7 @@ $post_page_chart = isset($gawd_settings['post_page_chart']) ? $gawd_settings['po
|
|
533 |
</div>
|
534 |
</div>
|
535 |
<div class="gawd_submit">
|
536 |
-
<input type="button" class="button_gawd" id="gawd_settings_button"value="
|
537 |
<input type="button" style="display:none;" class="button_gawd" id="gawd_settings_logout"value="Logout"/>
|
538 |
</div>
|
539 |
<input type='hidden' name="gawd_alert_remove" id="gawd_alert_remove"/>
|
43 |
|
44 |
<div id="gawd_body">
|
45 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
46 |
+
Authenticate your Google account and customize Google Analytics settings in this section.
|
47 |
+
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/settings.html">Read more in User Guide.</a>
|
48 |
</div>
|
49 |
<div class="resp_menu"><div class="menu_img"></div><div class="button_label">SETTINGS</div><div class="clear"></div></div>
|
50 |
<div class="gawd_menu_coteiner gawd_settings_menu_coteiner">
|
103 |
<div class="gawd_goal_input">
|
104 |
<input type="text" value="<?php echo isset($own_cliend_id) ? $own_cliend_id : '';?>" name="gawd_own_client_id"/>
|
105 |
</div>
|
106 |
+
<div class="gawd_info" title="Paste Client ID key. For more information about getting project keys please check the plugin User Guide."></div>
|
107 |
<div class='clear'></div>
|
108 |
</div>
|
109 |
<div class="gawd_goal_row">
|
111 |
<div class="gawd_goal_input">
|
112 |
<input type="text" value="<?php echo isset($own_cliend_secret) ? $own_cliend_secret : '';?>" name="gawd_own_client_secret"/>
|
113 |
</div>
|
114 |
+
<div class="gawd_info" title="Paste Client Secret key. For more information about getting project keys please check the plugin User Guide."></div>
|
115 |
<div class='clear'></div>
|
116 |
</div>
|
117 |
</div>
|
322 |
<span class="onoffswitch-switch"></span>
|
323 |
</label>
|
324 |
</div>
|
325 |
+
<div class="gawd_info" title="Turn this option on to get AdSense tracking reports. Make sure to link your Google AdSense to Google Analytics first (find out more in plugin User Guide)"></div>
|
326 |
<div class="onoffswitch_text">
|
327 |
Enable AdSense link tracking <a target="_blank" href="https://web-dorado.com/products/wordpress-google-analytics-plugin.html" class="gawd_pro"> ( This feature is available in Google Analytics WD Pro. )</a>
|
328 |
</div>
|
533 |
</div>
|
534 |
</div>
|
535 |
<div class="gawd_submit">
|
536 |
+
<input type="button" class="button_gawd" id="gawd_settings_button"value="Save"/>
|
537 |
<input type="button" style="display:none;" class="button_gawd" id="gawd_settings_logout"value="Logout"/>
|
538 |
</div>
|
539 |
<input type='hidden' name="gawd_alert_remove" id="gawd_alert_remove"/>
|
admin/pages/tracking.php
CHANGED
@@ -28,8 +28,8 @@ $domain = GAWD::get_domain(esc_html(get_option('siteurl')));
|
|
28 |
|
29 |
<div id="gawd_body">
|
30 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
31 |
-
Create a web property and manage tracking settings in this section.
|
32 |
-
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/tracking.html">Read
|
33 |
</div>
|
34 |
<div class="resp_menu"><div class="menu_img"></div><div class="button_label">TRACKING</div><div class="clear"></div></div>
|
35 |
<div class="gawd_menu_coteiner gawd_settings_menu_coteiner">
|
@@ -85,7 +85,7 @@ $domain = GAWD::get_domain(esc_html(get_option('siteurl')));
|
|
85 |
<span class="onoffswitch-switch"></span>
|
86 |
</label>
|
87 |
</div>
|
88 |
-
<div class="gawd_info" title="Enable this option to track multiple links with the same destination. Get information for buttons, menus, as well as elements with multiple destinations, e.g. search boxes. You can find out more about Enhanced Link Attribution in the plugin
|
89 |
<div class="onoffswitch_text">
|
90 |
Enhanced Link Attribution
|
91 |
</div>
|
28 |
|
29 |
<div id="gawd_body">
|
30 |
<div style="font-size: 14px; font-weight: bold; margin:15px 0">
|
31 |
+
Create a web property and manage tracking settings in this section.
|
32 |
+
<a style="color: #00A0D2; text-decoration: none;" target="_blank" href="https://web-dorado.com/wordpress-google-analytics/tracking.html">Read more in User Guide.</a>
|
33 |
</div>
|
34 |
<div class="resp_menu"><div class="menu_img"></div><div class="button_label">TRACKING</div><div class="clear"></div></div>
|
35 |
<div class="gawd_menu_coteiner gawd_settings_menu_coteiner">
|
85 |
<span class="onoffswitch-switch"></span>
|
86 |
</label>
|
87 |
</div>
|
88 |
+
<div class="gawd_info" title="Enable this option to track multiple links with the same destination. Get information for buttons, menus, as well as elements with multiple destinations, e.g. search boxes. You can find out more about Enhanced Link Attribution in the plugin User Guide."></div>
|
89 |
<div class="onoffswitch_text">
|
90 |
Enhanced Link Attribution
|
91 |
</div>
|
assets/freePages/alerts.png
CHANGED
Binary file
|
assets/freePages/custom_dimensions.png
CHANGED
Binary file
|
assets/freePages/custom_reports.png
CHANGED
Binary file
|
assets/freePages/exclude_tracking.png
CHANGED
Binary file
|
assets/freePages/pushovers.png
CHANGED
Binary file
|
gawd_class.php
CHANGED
@@ -51,6 +51,10 @@ class GAWD {
|
|
51 |
add_action( 'gawd_email_gawd_monthly', array( $this, 'gawd_monthly_email' ) );
|
52 |
//add_action('init', array($this, 'gawd_daily_email'));
|
53 |
add_action( 'wp_head', array( $this, 'gawd_tracking_code' ), 99 );
|
|
|
|
|
|
|
|
|
54 |
$gawd_settings = get_option( 'gawd_settings' );
|
55 |
$gawd_post_page_roles = isset( $gawd_settings['gawd_post_page_roles'] ) ? $gawd_settings['gawd_post_page_roles'] : array();
|
56 |
$roles = $this->get_current_user_role();
|
@@ -1200,7 +1204,8 @@ class GAWD {
|
|
1200 |
global $gawd_user_data;
|
1201 |
if ( isset( $gawd_user_data['default_webPropertyId'] ) && $gawd_user_data['default_webPropertyId'] ) {
|
1202 |
return 'done';
|
1203 |
-
}
|
|
|
1204 |
$gawd_client = GAWD_google_client::get_instance();
|
1205 |
$property = $gawd_client->property_exists();
|
1206 |
if ( $property == 'no_matches' ) {
|
@@ -1233,7 +1238,7 @@ class GAWD {
|
|
1233 |
</div>
|
1234 |
<div class='gawd_add_prop gawd_submit'>
|
1235 |
<a href='" . admin_url() . "admin.php?page=gawd_analytics' class='gawd_later button_gawd'>Later</a>
|
1236 |
-
<input type='button' id='gawd_add_property' class='button_gawd' value='
|
1237 |
<input type='hidden' id='add_property' name='add_property'/>
|
1238 |
</div>
|
1239 |
</form>";
|
@@ -1629,6 +1634,7 @@ class GAWD {
|
|
1629 |
//echo '<script>window.location.href="'.$redirect_url.'";</script>';
|
1630 |
return;
|
1631 |
}
|
|
|
1632 |
|
1633 |
if ( $add_dimension_value == 'add_dimension_Logged_in' ) {
|
1634 |
$id = isset( $_POST['gawd_custom_dimension_id'] ) ? ( $_POST['gawd_custom_dimension_id'] + 1 ) : 1;
|
@@ -1718,7 +1724,6 @@ class GAWD {
|
|
1718 |
}
|
1719 |
$gawd_excluded_roles = isset( $_POST['gawd_excluded_roles'] ) ? $_POST['gawd_excluded_roles'] : array();
|
1720 |
$gawd_excluded_users = isset( $_POST['gawd_excluded_users'] ) ? $_POST['gawd_excluded_users'] : array();
|
1721 |
-
$gawd_settings = get_option( 'gawd_settings' );
|
1722 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
1723 |
$gawd_settings['gawd_anonymize'] = $gawd_anonymize;
|
1724 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
@@ -1734,7 +1739,6 @@ class GAWD {
|
|
1734 |
$this->gawd_admin_notice( 'Your changes have been saved successfully.', 'success is-dismissible' );
|
1735 |
}
|
1736 |
delete_option( 'gawd_save_tracking' );
|
1737 |
-
$gawd_settings = get_option( 'gawd_settings' );
|
1738 |
if ( $add_dimension_value != '' ) {
|
1739 |
$redirect_url = admin_url() . 'admin.php?page=gawd_tracking';
|
1740 |
echo '<script>window.location.href="' . $redirect_url . '";</script>';
|
@@ -2237,6 +2241,7 @@ class GAWD {
|
|
2237 |
update_option( 'gawd_menu_items', $tabs );
|
2238 |
}
|
2239 |
|
|
|
2240 |
public function remove_zoom_message() {
|
2241 |
check_ajax_referer( 'gawd_admin_page_nonce', 'security' );
|
2242 |
$got_it = isset( $_REQUEST["got_it"] ) ? sanitize_text_field( $_REQUEST["got_it"] ) : '';
|
@@ -2244,6 +2249,25 @@ class GAWD {
|
|
2244 |
add_option( 'gawd_zoom_message', $got_it );
|
2245 |
}
|
2246 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2247 |
/**
|
2248 |
* Checks if the protocol is secure.
|
2249 |
*
|
51 |
add_action( 'gawd_email_gawd_monthly', array( $this, 'gawd_monthly_email' ) );
|
52 |
//add_action('init', array($this, 'gawd_daily_email'));
|
53 |
add_action( 'wp_head', array( $this, 'gawd_tracking_code' ), 99 );
|
54 |
+
include_once(GAWD_DIR . '/include/gawd-notices-class.php');
|
55 |
+
|
56 |
+
add_action( 'admin_notices', array( $this, 'check_property_delete' ));
|
57 |
+
|
58 |
$gawd_settings = get_option( 'gawd_settings' );
|
59 |
$gawd_post_page_roles = isset( $gawd_settings['gawd_post_page_roles'] ) ? $gawd_settings['gawd_post_page_roles'] : array();
|
60 |
$roles = $this->get_current_user_role();
|
1204 |
global $gawd_user_data;
|
1205 |
if ( isset( $gawd_user_data['default_webPropertyId'] ) && $gawd_user_data['default_webPropertyId'] ) {
|
1206 |
return 'done';
|
1207 |
+
}
|
1208 |
+
else {
|
1209 |
$gawd_client = GAWD_google_client::get_instance();
|
1210 |
$property = $gawd_client->property_exists();
|
1211 |
if ( $property == 'no_matches' ) {
|
1238 |
</div>
|
1239 |
<div class='gawd_add_prop gawd_submit'>
|
1240 |
<a href='" . admin_url() . "admin.php?page=gawd_analytics' class='gawd_later button_gawd'>Later</a>
|
1241 |
+
<input type='button' id='gawd_add_property' class='button_gawd' value='Add'/>
|
1242 |
<input type='hidden' id='add_property' name='add_property'/>
|
1243 |
</div>
|
1244 |
</form>";
|
1634 |
//echo '<script>window.location.href="'.$redirect_url.'";</script>';
|
1635 |
return;
|
1636 |
}
|
1637 |
+
$gawd_settings = get_option( 'gawd_settings' );
|
1638 |
|
1639 |
if ( $add_dimension_value == 'add_dimension_Logged_in' ) {
|
1640 |
$id = isset( $_POST['gawd_custom_dimension_id'] ) ? ( $_POST['gawd_custom_dimension_id'] + 1 ) : 1;
|
1724 |
}
|
1725 |
$gawd_excluded_roles = isset( $_POST['gawd_excluded_roles'] ) ? $_POST['gawd_excluded_roles'] : array();
|
1726 |
$gawd_excluded_users = isset( $_POST['gawd_excluded_users'] ) ? $_POST['gawd_excluded_users'] : array();
|
|
|
1727 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
1728 |
$gawd_settings['gawd_anonymize'] = $gawd_anonymize;
|
1729 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
1739 |
$this->gawd_admin_notice( 'Your changes have been saved successfully.', 'success is-dismissible' );
|
1740 |
}
|
1741 |
delete_option( 'gawd_save_tracking' );
|
|
|
1742 |
if ( $add_dimension_value != '' ) {
|
1743 |
$redirect_url = admin_url() . 'admin.php?page=gawd_tracking';
|
1744 |
echo '<script>window.location.href="' . $redirect_url . '";</script>';
|
2241 |
update_option( 'gawd_menu_items', $tabs );
|
2242 |
}
|
2243 |
|
2244 |
+
|
2245 |
public function remove_zoom_message() {
|
2246 |
check_ajax_referer( 'gawd_admin_page_nonce', 'security' );
|
2247 |
$got_it = isset( $_REQUEST["got_it"] ) ? sanitize_text_field( $_REQUEST["got_it"] ) : '';
|
2249 |
add_option( 'gawd_zoom_message', $got_it );
|
2250 |
}
|
2251 |
}
|
2252 |
+
|
2253 |
+
public function check_property_delete(){
|
2254 |
+
global $gawd_client;
|
2255 |
+
$gawd_client = GAWD_google_client::get_instance();
|
2256 |
+
$accountId = $gawd_client->get_default_accountId();
|
2257 |
+
$webPropertyId = $gawd_client->get_default_webPropertyId();
|
2258 |
+
$screen = get_current_screen();
|
2259 |
+
if ( strpos( $screen->base, 'gawd' ) !== false && $accountId != null && $webPropertyId != null) {
|
2260 |
+
try{
|
2261 |
+
$deleted = $gawd_client->analytics_member->management_webproperties->get($accountId, $webPropertyId);
|
2262 |
+
}
|
2263 |
+
catch (Exception $e){
|
2264 |
+
if(strpos($e->getMessage(), 'not found.') !==false){
|
2265 |
+
echo '<div class="notice notice-error"><p>You have deleted your web-properties with current site url, please <a href="'.admin_url() . 'admin.php?page=gawd_settings">reauthenticate</a>. </p></div>';
|
2266 |
+
}
|
2267 |
+
}
|
2268 |
+
}
|
2269 |
+
}
|
2270 |
+
|
2271 |
/**
|
2272 |
* Checks if the protocol is secure.
|
2273 |
*
|
google-analytics-wd.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Plugin Name:
|
5 |
* Plugin URI: https://web-dorado.com/products/wordpress-google-analytics-plugin.html
|
6 |
-
* Description:
|
7 |
-
* Version: 1.0.
|
8 |
* Author: WebDorado
|
9 |
* Author URI: https://web-dorado.com
|
10 |
* License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Plugin Name: Google Analytics
|
5 |
* Plugin URI: https://web-dorado.com/products/wordpress-google-analytics-plugin.html
|
6 |
+
* Description: Google Analytics WD is a user-friendly all in one plugin, which allows to manage and monitor your website analytics from WordPress dashboard.
|
7 |
+
* Version: 1.0.6
|
8 |
* Author: WebDorado
|
9 |
* Author URI: https://web-dorado.com
|
10 |
* License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
inc/css/bootstrap.css
CHANGED
@@ -6491,7 +6491,7 @@ button.close {
|
|
6491 |
border: 0;
|
6492 |
}
|
6493 |
.hidden {
|
6494 |
-
display: none !important;
|
6495 |
}
|
6496 |
.affix {
|
6497 |
position: fixed;
|
6491 |
border: 0;
|
6492 |
}
|
6493 |
.hidden {
|
6494 |
+
//display: none !important;
|
6495 |
}
|
6496 |
.affix {
|
6497 |
position: fixed;
|
inc/css/gawd_admin.css
CHANGED
@@ -429,18 +429,20 @@
|
|
429 |
background-color:#7DB5D8;
|
430 |
color:#fff;
|
431 |
font-size: 13px;
|
432 |
-
line-height:
|
433 |
-
|
|
|
434 |
margin: 0;
|
435 |
padding: 0 10px 1px;
|
436 |
cursor: pointer;
|
437 |
-
border-width:
|
438 |
border-style: solid;
|
439 |
-webkit-appearance: none;
|
440 |
white-space: nowrap;
|
441 |
-webkit-box-sizing: border-box;
|
442 |
-moz-box-sizing: border-box;
|
443 |
box-sizing: border-box;
|
|
|
444 |
}
|
445 |
.button_gawd_add{
|
446 |
background-color:#7DB5D8;
|
@@ -1799,7 +1801,8 @@ Original highlight.js style (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
|
|
1799 |
.page_chart_div .gawd_btn{
|
1800 |
right: -21px;
|
1801 |
top: -21px;
|
1802 |
-
position:absolute
|
|
|
1803 |
}
|
1804 |
.gawd_btn:hover {
|
1805 |
background: #caced1;
|
@@ -2390,7 +2393,7 @@ th.ui-th-column div{
|
|
2390 |
display: inline-block;
|
2391 |
width: 19px !important;
|
2392 |
height: 15px !important;
|
2393 |
-
z-index:
|
2394 |
line-height: 16px;
|
2395 |
top: 8px;
|
2396 |
right: 35px;
|
@@ -2423,4 +2426,24 @@ th.ui-th-column div{
|
|
2423 |
|
2424 |
.gawd_auth_button:hover{
|
2425 |
background-color:rgba(125,181,216,0.7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2426 |
}
|
429 |
background-color:#7DB5D8;
|
430 |
color:#fff;
|
431 |
font-size: 13px;
|
432 |
+
line-height: 24px;
|
433 |
+
width:60px;
|
434 |
+
height: 26px;
|
435 |
margin: 0;
|
436 |
padding: 0 10px 1px;
|
437 |
cursor: pointer;
|
438 |
+
border-width: 0px;
|
439 |
border-style: solid;
|
440 |
-webkit-appearance: none;
|
441 |
white-space: nowrap;
|
442 |
-webkit-box-sizing: border-box;
|
443 |
-moz-box-sizing: border-box;
|
444 |
box-sizing: border-box;
|
445 |
+
border-radius:2px
|
446 |
}
|
447 |
.button_gawd_add{
|
448 |
background-color:#7DB5D8;
|
1801 |
.page_chart_div .gawd_btn{
|
1802 |
right: -21px;
|
1803 |
top: -21px;
|
1804 |
+
position:absolute;
|
1805 |
+
border:0;
|
1806 |
}
|
1807 |
.gawd_btn:hover {
|
1808 |
background: #caced1;
|
2393 |
display: inline-block;
|
2394 |
width: 19px !important;
|
2395 |
height: 15px !important;
|
2396 |
+
z-index: 100;
|
2397 |
line-height: 16px;
|
2398 |
top: 8px;
|
2399 |
right: 35px;
|
2426 |
|
2427 |
.gawd_auth_button:hover{
|
2428 |
background-color:rgba(125,181,216,0.7)
|
2429 |
+
}
|
2430 |
+
|
2431 |
+
#gbox_griddiv{
|
2432 |
+
border-radius:2px
|
2433 |
+
}
|
2434 |
+
|
2435 |
+
.button_gawd:hover{
|
2436 |
+
background-color:rgba(125,181,216,0.7)
|
2437 |
+
}
|
2438 |
+
|
2439 |
+
#gawd_export_buttons{
|
2440 |
+
margin-right:3px
|
2441 |
+
}
|
2442 |
+
|
2443 |
+
#gawd_got_it{
|
2444 |
+
width:initial
|
2445 |
+
}
|
2446 |
+
|
2447 |
+
#gawd_settings_logout:hover{
|
2448 |
+
background-color:#c9cdd0
|
2449 |
}
|
inc/css/notices.css
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wd-admin-notice {
|
2 |
+
background: #fff;
|
3 |
+
border: 4px;
|
4 |
+
display: block;
|
5 |
+
min-height: 68px;
|
6 |
+
padding: 10px 40px 10px 125px;
|
7 |
+
position: relative;
|
8 |
+
}
|
9 |
+
.wd-admin-notice a {
|
10 |
+
color: #10738B;
|
11 |
+
}
|
12 |
+
.gawd-notice-logo {
|
13 |
+
clear: both;
|
14 |
+
content: "";
|
15 |
+
display: block;
|
16 |
+
background-image: url("https://d27sb3x2z8tu4g.cloudfront.net/images/productlogos/google_analytics.png?1463122703");
|
17 |
+
background-size: 108px auto;
|
18 |
+
background-repeat: no-repeat;
|
19 |
+
background-position: 0 45%;
|
20 |
+
width: 125px;
|
21 |
+
position: absolute;
|
22 |
+
top: 0;
|
23 |
+
bottom: 0;
|
24 |
+
left: 5px;
|
25 |
+
}
|
26 |
+
.wd-admin-notice > .dashicons {
|
27 |
+
color: #424242;
|
28 |
+
position: absolute;
|
29 |
+
right: 20px;
|
30 |
+
top: 40%;
|
31 |
+
}
|
32 |
+
.wd-notice-title {
|
33 |
+
font-size: 24px;
|
34 |
+
margin: 0;
|
35 |
+
}
|
36 |
+
.wd-notice-body {
|
37 |
+
font-weight: normal;
|
38 |
+
margin: 5px 0;
|
39 |
+
}
|
40 |
+
.wd-notice-body:after {
|
41 |
+
clear: both;
|
42 |
+
content: "";
|
43 |
+
display: block;
|
44 |
+
}
|
45 |
+
.wd-notice-body li {
|
46 |
+
float: left;
|
47 |
+
margin-right: 20px;
|
48 |
+
}
|
49 |
+
.wd-notice-body .dashicons {
|
50 |
+
font-size: 17px;
|
51 |
+
}
|
52 |
+
.wd-blue {
|
53 |
+
color: #10738B;
|
54 |
+
}
|
55 |
+
|
56 |
+
.admin-notice-promo {
|
57 |
+
background: #fff;
|
58 |
+
border-top: 4px;
|
59 |
+
display: block;
|
60 |
+
min-height: 68px;
|
61 |
+
padding: 10px 40px 0px 10px;
|
62 |
+
margin: 10px 0;
|
63 |
+
position: relative;
|
64 |
+
}
|
65 |
+
|
66 |
+
.admin-notice-promo:after {
|
67 |
+
content: '';
|
68 |
+
display: table;
|
69 |
+
clear: both;
|
70 |
+
}
|
71 |
+
|
72 |
+
.close-promo {
|
73 |
+
position: absolute;
|
74 |
+
top: 5px;
|
75 |
+
right: 5px;
|
76 |
+
}
|
77 |
+
|
78 |
+
.promo {
|
79 |
+
background-position: center;
|
80 |
+
background-repeat: no-repeat;
|
81 |
+
background-size: 972px 200px;
|
82 |
+
height: 200px;
|
83 |
+
max-width: 100%;
|
84 |
+
}
|
85 |
+
|
86 |
+
.promo a {
|
87 |
+
display: block;
|
88 |
+
height: 100%;
|
89 |
+
}
|
inc/js/daterangepicker.js
CHANGED
@@ -1,1545 +1,1561 @@
|
|
1 |
-
/**
|
2 |
-
* @version: 2.1.19
|
3 |
-
* @author: Dan Grossman http://www.dangrossman.info/
|
4 |
-
* @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
|
5 |
-
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
|
6 |
-
* @website: https://www.improvely.com/
|
7 |
-
*/
|
8 |
-
|
9 |
-
(function(root, factory) {
|
10 |
-
|
11 |
-
if (typeof define === 'function' && define.amd) {
|
12 |
-
define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) {
|
13 |
-
root.daterangepicker = factory(root, exports, momentjs, $);
|
14 |
-
});
|
15 |
-
|
16 |
-
} else if (typeof exports !== 'undefined') {
|
17 |
-
var momentjs = require('moment');
|
18 |
-
var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined; //isomorphic issue
|
19 |
-
if (!jQuery) {
|
20 |
-
try {
|
21 |
-
jQuery = require('jquery');
|
22 |
-
if (!jQuery.fn) jQuery.fn = {}; //isomorphic issue
|
23 |
-
} catch (err) {
|
24 |
-
if (!jQuery) throw new Error('jQuery dependency not found');
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
factory(root, exports, momentjs, jQuery);
|
29 |
-
|
30 |
-
// Finally, as a browser global.
|
31 |
-
} else {
|
32 |
-
root.daterangepicker = factory(root, {}, root.moment || moment, (root.jQuery || root.Zepto || root.ender || root.$));
|
33 |
-
}
|
34 |
-
|
35 |
-
}(this || {}, function(root, daterangepicker, moment, $) { // 'this' doesn't exist on a server
|
36 |
-
|
37 |
-
var DateRangePicker = function(element, options, cb) {
|
38 |
-
|
39 |
-
//default settings for options
|
40 |
-
this.parentEl = 'body';
|
41 |
-
this.element = $(element);
|
42 |
-
this.startDate = moment().startOf('day');
|
43 |
-
this.endDate = moment().endOf('day');
|
44 |
-
this.minDate = false;
|
45 |
-
this.maxDate = false;
|
46 |
-
this.dateLimit = false;
|
47 |
-
this.autoApply = false;
|
48 |
-
this.singleDatePicker = false;
|
49 |
-
this.showDropdowns = false;
|
50 |
-
this.showWeekNumbers = false;
|
51 |
-
this.showISOWeekNumbers = false;
|
52 |
-
this.timePicker = false;
|
53 |
-
this.timePicker24Hour = false;
|
54 |
-
this.timePickerIncrement = 1;
|
55 |
-
this.timePickerSeconds = false;
|
56 |
-
this.linkedCalendars = true;
|
57 |
-
this.autoUpdateInput = true;
|
58 |
-
this.alwaysShowCalendars = false;
|
59 |
-
this.ranges = {};
|
60 |
-
|
61 |
-
this.opens = 'right';
|
62 |
-
if (this.element.hasClass('pull-right'))
|
63 |
-
this.opens = 'left';
|
64 |
-
|
65 |
-
this.drops = 'down';
|
66 |
-
if (this.element.hasClass('dropup'))
|
67 |
-
this.drops = 'up';
|
68 |
-
|
69 |
-
this.buttonClasses = 'btn btn-sm';
|
70 |
-
this.applyClass = 'btn-success';
|
71 |
-
this.cancelClass = 'btn-default';
|
72 |
-
|
73 |
-
this.locale = {
|
74 |
-
format: 'MM/DD/YYYY',
|
75 |
-
separator: ' - ',
|
76 |
-
applyLabel: 'Apply',
|
77 |
-
cancelLabel: 'Cancel',
|
78 |
-
weekLabel: 'W',
|
79 |
-
customRangeLabel: 'Custom Range',
|
80 |
-
daysOfWeek: moment.weekdaysMin(),
|
81 |
-
monthNames: moment.monthsShort(),
|
82 |
-
firstDay: moment.localeData().firstDayOfWeek()
|
83 |
-
};
|
84 |
-
|
85 |
-
this.callback = function() { };
|
86 |
-
|
87 |
-
//some state information
|
88 |
-
this.isShowing = false;
|
89 |
-
this.leftCalendar = {};
|
90 |
-
this.rightCalendar = {};
|
91 |
-
|
92 |
-
//custom options from user
|
93 |
-
if (typeof options !== 'object' || options === null)
|
94 |
-
options = {};
|
95 |
-
|
96 |
-
//allow setting options with data attributes
|
97 |
-
//data-api options will be overwritten with custom javascript options
|
98 |
-
options = $.extend(this.element.data(), options);
|
99 |
-
|
100 |
-
//html template for the picker UI
|
101 |
-
if (typeof options.template !== 'string' && !(options.template instanceof $))
|
102 |
-
options.template = '<div class="daterangepicker dropdown-menu">' +
|
103 |
-
'<div class="calendar left">' +
|
104 |
-
'<div class="daterangepicker_input">' +
|
105 |
-
'<input class="input-mini" type="text" name="daterangepicker_start" value="" />' +
|
106 |
-
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
107 |
-
'<div class="calendar-time">' +
|
108 |
-
'<div></div>' +
|
109 |
-
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
110 |
-
'</div>' +
|
111 |
-
'</div>' +
|
112 |
-
'<div class="calendar-table"></div>' +
|
113 |
-
'</div>' +
|
114 |
-
'<div class="calendar right">' +
|
115 |
-
'<div class="daterangepicker_input">' +
|
116 |
-
'<input class="input-mini" type="text" name="daterangepicker_end" value="" />' +
|
117 |
-
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
118 |
-
'<div class="calendar-time">' +
|
119 |
-
'<div></div>' +
|
120 |
-
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
121 |
-
'</div>' +
|
122 |
-
'</div>' +
|
123 |
-
'<div class="calendar-table"></div>' +
|
124 |
-
'</div>' +
|
125 |
-
'<div class="ranges">' +
|
126 |
-
'<div class="range_inputs">' +
|
127 |
-
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
128 |
-
'<button class="cancelBtn" type="button"></button>' +
|
129 |
-
'</div>' +
|
130 |
-
'</div>' +
|
131 |
-
'</div>';
|
132 |
-
|
133 |
-
this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
|
134 |
-
this.container = $(options.template).appendTo(this.parentEl);
|
135 |
-
|
136 |
-
//
|
137 |
-
// handle all the possible options overriding defaults
|
138 |
-
//
|
139 |
-
|
140 |
-
if (typeof options.locale === 'object') {
|
141 |
-
|
142 |
-
if (typeof options.locale.format === 'string')
|
143 |
-
this.locale.format = options.locale.format;
|
144 |
-
|
145 |
-
if (typeof options.locale.separator === 'string')
|
146 |
-
this.locale.separator = options.locale.separator;
|
147 |
-
|
148 |
-
if (typeof options.locale.daysOfWeek === 'object')
|
149 |
-
this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
|
150 |
-
|
151 |
-
if (typeof options.locale.monthNames === 'object')
|
152 |
-
this.locale.monthNames = options.locale.monthNames.slice();
|
153 |
-
|
154 |
-
if (typeof options.locale.firstDay === 'number')
|
155 |
-
this.locale.firstDay = options.locale.firstDay;
|
156 |
-
|
157 |
-
if (typeof options.locale.applyLabel === 'string')
|
158 |
-
this.locale.applyLabel = options.locale.applyLabel;
|
159 |
-
|
160 |
-
if (typeof options.locale.cancelLabel === 'string')
|
161 |
-
this.locale.cancelLabel = options.locale.cancelLabel;
|
162 |
-
|
163 |
-
if (typeof options.locale.weekLabel === 'string')
|
164 |
-
this.locale.weekLabel = options.locale.weekLabel;
|
165 |
-
|
166 |
-
if (typeof options.locale.customRangeLabel === 'string')
|
167 |
-
this.locale.customRangeLabel = options.locale.customRangeLabel;
|
168 |
-
|
169 |
-
}
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
this.singleDatePicker
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
//
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
//
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
list += '
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
this.callback = cb;
|
347 |
-
}
|
348 |
-
|
349 |
-
if (!this.timePicker) {
|
350 |
-
this.startDate = this.startDate.startOf('day');
|
351 |
-
this.endDate = this.endDate.endOf('day');
|
352 |
-
this.container.find('.calendar-time').hide();
|
353 |
-
}
|
354 |
-
|
355 |
-
//can't be used together for now
|
356 |
-
if (this.timePicker && this.autoApply)
|
357 |
-
this.autoApply = false;
|
358 |
-
|
359 |
-
if (this.autoApply && typeof options.ranges !== 'object') {
|
360 |
-
this.container.find('.ranges').hide();
|
361 |
-
} else if (this.autoApply) {
|
362 |
-
this.container.find('.applyBtn, .cancelBtn').addClass('hide');
|
363 |
-
}
|
364 |
-
|
365 |
-
if (this.singleDatePicker) {
|
366 |
-
|
367 |
-
this.container.
|
368 |
-
this.container.find('.calendar.left').
|
369 |
-
this.container.find('.calendar.
|
370 |
-
this.container.find('.
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
var
|
386 |
-
ranges.
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
this.container.find('.
|
398 |
-
|
399 |
-
|
400 |
-
//
|
401 |
-
//
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
.on('click.daterangepicker', '.
|
406 |
-
.on('click.daterangepicker', '
|
407 |
-
.on('
|
408 |
-
.on('
|
409 |
-
.on('
|
410 |
-
.on('change.daterangepicker', 'select.
|
411 |
-
.on('change.daterangepicker', 'select.
|
412 |
-
.on('
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
.on('click.daterangepicker', 'button.
|
419 |
-
.on('click.daterangepicker', '
|
420 |
-
.on('
|
421 |
-
.on('
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
'
|
427 |
-
'
|
428 |
-
'
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
//
|
436 |
-
//
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
this.element.
|
441 |
-
|
442 |
-
|
443 |
-
this.element.
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
if (
|
502 |
-
this.
|
503 |
-
|
504 |
-
this.
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
this.
|
523 |
-
this.
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
this.
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
this.leftCalendar.month
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
this.rightCalendar.month = this.
|
556 |
-
}
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
var
|
616 |
-
var
|
617 |
-
var
|
618 |
-
var
|
619 |
-
var
|
620 |
-
|
621 |
-
|
622 |
-
var
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
this.
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
//
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
if (this.
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
}
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
html += '<
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
html += '<th
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
//
|
776 |
-
if (calendar[row][col].
|
777 |
-
classes.push('
|
778 |
-
|
779 |
-
//
|
780 |
-
if (
|
781 |
-
classes.push('
|
782 |
-
|
783 |
-
//
|
784 |
-
if (
|
785 |
-
classes.push('off'
|
786 |
-
|
787 |
-
//don't allow selection of
|
788 |
-
if (this.
|
789 |
-
classes.push('off', 'disabled');
|
790 |
-
|
791 |
-
//
|
792 |
-
if (calendar[row][col].
|
793 |
-
classes.push('
|
794 |
-
|
795 |
-
//
|
796 |
-
if (this.
|
797 |
-
classes.push('
|
798 |
-
|
799 |
-
//highlight
|
800 |
-
if (
|
801 |
-
classes.push('
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
if (
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
html += '
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
if (this.
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
this.move();
|
1083 |
-
|
1084 |
-
this.
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
this.
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
},
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
this.hide()
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
this.
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
this.
|
1196 |
-
}
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
this.container.find('
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
if (
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
var
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
this.setEndDate(
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
},
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
this.
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
this.
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
if (
|
1502 |
-
|
1503 |
-
this.
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
}
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
}
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1545 |
}));
|
1 |
+
/**
|
2 |
+
* @version: 2.1.19
|
3 |
+
* @author: Dan Grossman http://www.dangrossman.info/
|
4 |
+
* @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved.
|
5 |
+
* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php
|
6 |
+
* @website: https://www.improvely.com/
|
7 |
+
*/
|
8 |
+
|
9 |
+
(function(root, factory) {
|
10 |
+
|
11 |
+
if (typeof define === 'function' && define.amd) {
|
12 |
+
define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) {
|
13 |
+
root.daterangepicker = factory(root, exports, momentjs, $);
|
14 |
+
});
|
15 |
+
|
16 |
+
} else if (typeof exports !== 'undefined') {
|
17 |
+
var momentjs = require('moment');
|
18 |
+
var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined; //isomorphic issue
|
19 |
+
if (!jQuery) {
|
20 |
+
try {
|
21 |
+
jQuery = require('jquery');
|
22 |
+
if (!jQuery.fn) jQuery.fn = {}; //isomorphic issue
|
23 |
+
} catch (err) {
|
24 |
+
if (!jQuery) throw new Error('jQuery dependency not found');
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
factory(root, exports, momentjs, jQuery);
|
29 |
+
|
30 |
+
// Finally, as a browser global.
|
31 |
+
} else {
|
32 |
+
root.daterangepicker = factory(root, {}, root.moment || moment, (root.jQuery || root.Zepto || root.ender || root.$));
|
33 |
+
}
|
34 |
+
|
35 |
+
}(this || {}, function(root, daterangepicker, moment, $) { // 'this' doesn't exist on a server
|
36 |
+
|
37 |
+
var DateRangePicker = function(element, options, cb) {
|
38 |
+
|
39 |
+
//default settings for options
|
40 |
+
this.parentEl = 'body';
|
41 |
+
this.element = $(element);
|
42 |
+
this.startDate = moment().startOf('day');
|
43 |
+
this.endDate = moment().endOf('day');
|
44 |
+
this.minDate = false;
|
45 |
+
this.maxDate = false;
|
46 |
+
this.dateLimit = false;
|
47 |
+
this.autoApply = false;
|
48 |
+
this.singleDatePicker = false;
|
49 |
+
this.showDropdowns = false;
|
50 |
+
this.showWeekNumbers = false;
|
51 |
+
this.showISOWeekNumbers = false;
|
52 |
+
this.timePicker = false;
|
53 |
+
this.timePicker24Hour = false;
|
54 |
+
this.timePickerIncrement = 1;
|
55 |
+
this.timePickerSeconds = false;
|
56 |
+
this.linkedCalendars = true;
|
57 |
+
this.autoUpdateInput = true;
|
58 |
+
this.alwaysShowCalendars = false;
|
59 |
+
this.ranges = {};
|
60 |
+
|
61 |
+
this.opens = 'right';
|
62 |
+
if (this.element.hasClass('pull-right'))
|
63 |
+
this.opens = 'left';
|
64 |
+
|
65 |
+
this.drops = 'down';
|
66 |
+
if (this.element.hasClass('dropup'))
|
67 |
+
this.drops = 'up';
|
68 |
+
|
69 |
+
this.buttonClasses = 'btn btn-sm';
|
70 |
+
this.applyClass = 'btn-success';
|
71 |
+
this.cancelClass = 'btn-default';
|
72 |
+
|
73 |
+
this.locale = {
|
74 |
+
format: 'MM/DD/YYYY',
|
75 |
+
separator: ' - ',
|
76 |
+
applyLabel: 'Apply',
|
77 |
+
cancelLabel: 'Cancel',
|
78 |
+
weekLabel: 'W',
|
79 |
+
customRangeLabel: 'Custom Range',
|
80 |
+
daysOfWeek: moment.weekdaysMin(),
|
81 |
+
monthNames: moment.monthsShort(),
|
82 |
+
firstDay: moment.localeData().firstDayOfWeek()
|
83 |
+
};
|
84 |
+
|
85 |
+
this.callback = function() { };
|
86 |
+
|
87 |
+
//some state information
|
88 |
+
this.isShowing = false;
|
89 |
+
this.leftCalendar = {};
|
90 |
+
this.rightCalendar = {};
|
91 |
+
|
92 |
+
//custom options from user
|
93 |
+
if (typeof options !== 'object' || options === null)
|
94 |
+
options = {};
|
95 |
+
|
96 |
+
//allow setting options with data attributes
|
97 |
+
//data-api options will be overwritten with custom javascript options
|
98 |
+
options = $.extend(this.element.data(), options);
|
99 |
+
|
100 |
+
//html template for the picker UI
|
101 |
+
if (typeof options.template !== 'string' && !(options.template instanceof $))
|
102 |
+
options.template = '<div class="daterangepicker dropdown-menu">' +
|
103 |
+
'<div class="calendar left">' +
|
104 |
+
'<div class="daterangepicker_input">' +
|
105 |
+
'<input class="input-mini" type="text" name="daterangepicker_start" value="" />' +
|
106 |
+
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
107 |
+
'<div class="calendar-time">' +
|
108 |
+
'<div></div>' +
|
109 |
+
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
110 |
+
'</div>' +
|
111 |
+
'</div>' +
|
112 |
+
'<div class="calendar-table"></div>' +
|
113 |
+
'</div>' +
|
114 |
+
'<div class="calendar right">' +
|
115 |
+
'<div class="daterangepicker_input">' +
|
116 |
+
'<input class="input-mini" type="text" name="daterangepicker_end" value="" />' +
|
117 |
+
'<i class="fa fa-calendar glyphicon glyphicon-calendar"></i>' +
|
118 |
+
'<div class="calendar-time">' +
|
119 |
+
'<div></div>' +
|
120 |
+
'<i class="fa fa-clock-o glyphicon glyphicon-time"></i>' +
|
121 |
+
'</div>' +
|
122 |
+
'</div>' +
|
123 |
+
'<div class="calendar-table"></div>' +
|
124 |
+
'</div>' +
|
125 |
+
'<div class="ranges">' +
|
126 |
+
'<div class="range_inputs">' +
|
127 |
+
'<button class="applyBtn" disabled="disabled" type="button"></button> ' +
|
128 |
+
'<button class="cancelBtn" type="button"></button>' +
|
129 |
+
'</div>' +
|
130 |
+
'</div>' +
|
131 |
+
'</div>';
|
132 |
+
|
133 |
+
this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl);
|
134 |
+
this.container = $(options.template).appendTo(this.parentEl);
|
135 |
+
|
136 |
+
//
|
137 |
+
// handle all the possible options overriding defaults
|
138 |
+
//
|
139 |
+
|
140 |
+
if (typeof options.locale === 'object') {
|
141 |
+
|
142 |
+
if (typeof options.locale.format === 'string')
|
143 |
+
this.locale.format = options.locale.format;
|
144 |
+
|
145 |
+
if (typeof options.locale.separator === 'string')
|
146 |
+
this.locale.separator = options.locale.separator;
|
147 |
+
|
148 |
+
if (typeof options.locale.daysOfWeek === 'object')
|
149 |
+
this.locale.daysOfWeek = options.locale.daysOfWeek.slice();
|
150 |
+
|
151 |
+
if (typeof options.locale.monthNames === 'object')
|
152 |
+
this.locale.monthNames = options.locale.monthNames.slice();
|
153 |
+
|
154 |
+
if (typeof options.locale.firstDay === 'number')
|
155 |
+
this.locale.firstDay = options.locale.firstDay;
|
156 |
+
|
157 |
+
if (typeof options.locale.applyLabel === 'string')
|
158 |
+
this.locale.applyLabel = options.locale.applyLabel;
|
159 |
+
|
160 |
+
if (typeof options.locale.cancelLabel === 'string')
|
161 |
+
this.locale.cancelLabel = options.locale.cancelLabel;
|
162 |
+
|
163 |
+
if (typeof options.locale.weekLabel === 'string')
|
164 |
+
this.locale.weekLabel = options.locale.weekLabel;
|
165 |
+
|
166 |
+
if (typeof options.locale.customRangeLabel === 'string')
|
167 |
+
this.locale.customRangeLabel = options.locale.customRangeLabel;
|
168 |
+
|
169 |
+
}
|
170 |
+
if (typeof options.startDate === 'string')
|
171 |
+
this.startDate = moment(options.startDate, this.locale.format);
|
172 |
+
|
173 |
+
if (typeof options.endDate === 'string')
|
174 |
+
this.endDate = moment(options.endDate, this.locale.format);
|
175 |
+
|
176 |
+
if (typeof options.minDate === 'string')
|
177 |
+
this.minDate = moment(options.minDate, this.locale.format);
|
178 |
+
|
179 |
+
if (typeof options.maxDate === 'string')
|
180 |
+
this.maxDate = moment(options.maxDate, this.locale.format);
|
181 |
+
|
182 |
+
if (typeof options.startDate === 'object')
|
183 |
+
this.startDate = moment(options.startDate);
|
184 |
+
|
185 |
+
if (typeof options.endDate === 'object')
|
186 |
+
this.endDate = moment(options.endDate);
|
187 |
+
|
188 |
+
if (typeof options.minDate === 'object')
|
189 |
+
this.minDate = moment(options.minDate);
|
190 |
+
|
191 |
+
if (typeof options.maxDate === 'object')
|
192 |
+
this.maxDate = moment(options.maxDate);
|
193 |
+
|
194 |
+
// sanity check for bad options
|
195 |
+
if (this.minDate && this.startDate.isBefore(this.minDate))
|
196 |
+
this.startDate = this.minDate.clone();
|
197 |
+
|
198 |
+
// sanity check for bad options
|
199 |
+
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
200 |
+
this.endDate = this.maxDate.clone();
|
201 |
+
|
202 |
+
if (typeof options.applyClass === 'string')
|
203 |
+
this.applyClass = options.applyClass;
|
204 |
+
|
205 |
+
if (typeof options.cancelClass === 'string')
|
206 |
+
this.cancelClass = options.cancelClass;
|
207 |
+
|
208 |
+
if (typeof options.dateLimit === 'object')
|
209 |
+
this.dateLimit = options.dateLimit;
|
210 |
+
|
211 |
+
if (typeof options.opens === 'string')
|
212 |
+
this.opens = options.opens;
|
213 |
+
|
214 |
+
if (typeof options.drops === 'string')
|
215 |
+
this.drops = options.drops;
|
216 |
+
|
217 |
+
if (typeof options.showWeekNumbers === 'boolean')
|
218 |
+
this.showWeekNumbers = options.showWeekNumbers;
|
219 |
+
|
220 |
+
if (typeof options.showISOWeekNumbers === 'boolean')
|
221 |
+
this.showISOWeekNumbers = options.showISOWeekNumbers;
|
222 |
+
|
223 |
+
if (typeof options.buttonClasses === 'string')
|
224 |
+
this.buttonClasses = options.buttonClasses;
|
225 |
+
|
226 |
+
if (typeof options.buttonClasses === 'object')
|
227 |
+
this.buttonClasses = options.buttonClasses.join(' ');
|
228 |
+
|
229 |
+
if (typeof options.showDropdowns === 'boolean')
|
230 |
+
this.showDropdowns = options.showDropdowns;
|
231 |
+
|
232 |
+
if (typeof options.singleDatePicker === 'boolean') {
|
233 |
+
this.singleDatePicker = options.singleDatePicker;
|
234 |
+
if (this.singleDatePicker)
|
235 |
+
this.endDate = this.startDate.clone();
|
236 |
+
}
|
237 |
+
|
238 |
+
if (typeof options.timePicker === 'boolean')
|
239 |
+
this.timePicker = options.timePicker;
|
240 |
+
|
241 |
+
if (typeof options.timePickerSeconds === 'boolean')
|
242 |
+
this.timePickerSeconds = options.timePickerSeconds;
|
243 |
+
|
244 |
+
if (typeof options.timePickerIncrement === 'number')
|
245 |
+
this.timePickerIncrement = options.timePickerIncrement;
|
246 |
+
|
247 |
+
if (typeof options.timePicker24Hour === 'boolean')
|
248 |
+
this.timePicker24Hour = options.timePicker24Hour;
|
249 |
+
|
250 |
+
if (typeof options.autoApply === 'boolean')
|
251 |
+
this.autoApply = options.autoApply;
|
252 |
+
|
253 |
+
if (typeof options.autoUpdateInput === 'boolean')
|
254 |
+
this.autoUpdateInput = options.autoUpdateInput;
|
255 |
+
|
256 |
+
if (typeof options.linkedCalendars === 'boolean')
|
257 |
+
this.linkedCalendars = options.linkedCalendars;
|
258 |
+
|
259 |
+
if (typeof options.isInvalidDate === 'function')
|
260 |
+
this.isInvalidDate = options.isInvalidDate;
|
261 |
+
|
262 |
+
if (typeof options.alwaysShowCalendars === 'boolean')
|
263 |
+
this.alwaysShowCalendars = options.alwaysShowCalendars;
|
264 |
+
|
265 |
+
// update day names order to firstDay
|
266 |
+
if (this.locale.firstDay != 0) {
|
267 |
+
var iterator = this.locale.firstDay;
|
268 |
+
while (iterator > 0) {
|
269 |
+
this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift());
|
270 |
+
iterator--;
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
var start, end, range;
|
275 |
+
//if no start/end dates set, check if an input element contains initial values
|
276 |
+
if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') {
|
277 |
+
if ($(this.element).is('input[type=text]')) {
|
278 |
+
var val = $(this.element).val(),
|
279 |
+
split = val.split(this.locale.separator);
|
280 |
+
|
281 |
+
start = end = null;
|
282 |
+
|
283 |
+
if (split.length == 2) {
|
284 |
+
start = moment(split[0], this.locale.format);
|
285 |
+
end = moment(split[1], this.locale.format);
|
286 |
+
} else if (this.singleDatePicker && val !== "") {
|
287 |
+
start = moment(val, this.locale.format);
|
288 |
+
end = moment(val, this.locale.format);
|
289 |
+
}
|
290 |
+
if (start !== null && end !== null) {
|
291 |
+
this.setStartDate(start);
|
292 |
+
this.setEndDate(end);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
}
|
296 |
+
|
297 |
+
if (typeof options.ranges === 'object') {
|
298 |
+
|
299 |
+
for (range in options.ranges) {
|
300 |
+
|
301 |
+
if (typeof options.ranges[range][0] === 'string')
|
302 |
+
start = moment(options.ranges[range][0], this.locale.format);
|
303 |
+
else
|
304 |
+
start = moment(options.ranges[range][0]);
|
305 |
+
|
306 |
+
if (typeof options.ranges[range][1] === 'string')
|
307 |
+
end = moment(options.ranges[range][1], this.locale.format);
|
308 |
+
else
|
309 |
+
end = moment(options.ranges[range][1]);
|
310 |
+
|
311 |
+
// If the start or end date exceed those allowed by the minDate or dateLimit
|
312 |
+
// options, shorten the range to the allowable period.
|
313 |
+
if (this.minDate && start.isBefore(this.minDate))
|
314 |
+
start = this.minDate.clone();
|
315 |
+
|
316 |
+
var maxDate = this.maxDate;
|
317 |
+
if (this.dateLimit && start.clone().add(this.dateLimit).isAfter(maxDate))
|
318 |
+
maxDate = start.clone().add(this.dateLimit);
|
319 |
+
if (maxDate && end.isAfter(maxDate))
|
320 |
+
end = maxDate.clone();
|
321 |
+
|
322 |
+
// If the end of the range is before the minimum or the start of the range is
|
323 |
+
// after the maximum, don't display this range option at all.
|
324 |
+
if ((this.minDate && end.isBefore(this.minDate)) || (maxDate && start.isAfter(maxDate)))
|
325 |
+
continue;
|
326 |
+
|
327 |
+
//Support unicode chars in the range names.
|
328 |
+
var elem = document.createElement('textarea');
|
329 |
+
elem.innerHTML = range;
|
330 |
+
var rangeHtml = elem.value;
|
331 |
+
|
332 |
+
this.ranges[rangeHtml] = [start, end];
|
333 |
+
}
|
334 |
+
|
335 |
+
var list = '<ul>';
|
336 |
+
for (range in this.ranges) {
|
337 |
+
list += '<li>' + range + '</li>';
|
338 |
+
}
|
339 |
+
list += '<li>' + this.locale.customRangeLabel + '</li>';
|
340 |
+
list += '</ul>';
|
341 |
+
this.container.find('.ranges').prepend(list);
|
342 |
+
}
|
343 |
+
|
344 |
+
if (typeof cb === 'function') {
|
345 |
+
|
346 |
+
this.callback = cb;
|
347 |
+
}
|
348 |
+
|
349 |
+
if (!this.timePicker) {
|
350 |
+
this.startDate = this.startDate.startOf('day');
|
351 |
+
this.endDate = this.endDate.endOf('day');
|
352 |
+
this.container.find('.calendar-time').hide();
|
353 |
+
}
|
354 |
+
|
355 |
+
//can't be used together for now
|
356 |
+
if (this.timePicker && this.autoApply)
|
357 |
+
this.autoApply = false;
|
358 |
+
|
359 |
+
if (this.autoApply && typeof options.ranges !== 'object') {
|
360 |
+
this.container.find('.ranges').hide();
|
361 |
+
} else if (this.autoApply) {
|
362 |
+
this.container.find('.applyBtn, .cancelBtn').addClass('hide');
|
363 |
+
}
|
364 |
+
|
365 |
+
if (this.singleDatePicker) {
|
366 |
+
|
367 |
+
this.container.addClass('single');
|
368 |
+
this.container.find('.calendar.left').addClass('single');
|
369 |
+
this.container.find('.calendar.left').show();
|
370 |
+
this.container.find('.calendar.right').hide();
|
371 |
+
this.container.find('.daterangepicker_input input, .daterangepicker_input i').hide();
|
372 |
+
if (!this.timePicker) {
|
373 |
+
this.container.find('.ranges').hide();
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) {
|
378 |
+
this.container.addClass('show-calendar');
|
379 |
+
}
|
380 |
+
|
381 |
+
this.container.addClass('opens' + this.opens);
|
382 |
+
|
383 |
+
//swap the position of the predefined ranges if opens right
|
384 |
+
if (typeof options.ranges !== 'undefined' && this.opens == 'right') {
|
385 |
+
var ranges = this.container.find('.ranges');
|
386 |
+
var html = ranges.clone();
|
387 |
+
ranges.remove();
|
388 |
+
this.container.find('.calendar.left').parent().prepend(html);
|
389 |
+
}
|
390 |
+
|
391 |
+
//apply CSS classes and labels to buttons
|
392 |
+
this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses);
|
393 |
+
if (this.applyClass.length)
|
394 |
+
this.container.find('.applyBtn').addClass(this.applyClass);
|
395 |
+
if (this.cancelClass.length)
|
396 |
+
this.container.find('.cancelBtn').addClass(this.cancelClass);
|
397 |
+
this.container.find('.applyBtn').html(this.locale.applyLabel);
|
398 |
+
this.container.find('.cancelBtn').html(this.locale.cancelLabel);
|
399 |
+
|
400 |
+
//
|
401 |
+
// event listeners
|
402 |
+
//
|
403 |
+
|
404 |
+
this.container.find('.calendar')
|
405 |
+
.on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this))
|
406 |
+
.on('click.daterangepicker', '.next', $.proxy(this.clickNext, this))
|
407 |
+
.on('click.daterangepicker', 'td.available', $.proxy(this.clickDate, this))
|
408 |
+
.on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this))
|
409 |
+
.on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this))
|
410 |
+
.on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this))
|
411 |
+
.on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this))
|
412 |
+
.on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this))
|
413 |
+
.on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this))
|
414 |
+
//.on('keyup.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this))
|
415 |
+
.on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this));
|
416 |
+
|
417 |
+
this.container.find('.ranges')
|
418 |
+
.on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this))
|
419 |
+
.on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this))
|
420 |
+
.on('click.daterangepicker', 'li', $.proxy(this.clickRange, this))
|
421 |
+
.on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this))
|
422 |
+
.on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this));
|
423 |
+
|
424 |
+
if (this.element.is('input')) {
|
425 |
+
this.element.on({
|
426 |
+
'click.daterangepicker': $.proxy(this.show, this),
|
427 |
+
'focus.daterangepicker': $.proxy(this.show, this),
|
428 |
+
'keyup.daterangepicker': $.proxy(this.elementChanged, this),
|
429 |
+
'keydown.daterangepicker': $.proxy(this.keydown, this)
|
430 |
+
});
|
431 |
+
} else {
|
432 |
+
this.element.on('click.daterangepicker', $.proxy(this.toggle, this));
|
433 |
+
}
|
434 |
+
|
435 |
+
//
|
436 |
+
// if attached to a text input, set the initial value
|
437 |
+
//
|
438 |
+
|
439 |
+
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
|
440 |
+
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
441 |
+
this.element.trigger('change');
|
442 |
+
} else if (this.element.is('input') && this.autoUpdateInput) {
|
443 |
+
this.element.val(this.startDate.format(this.locale.format));
|
444 |
+
this.element.trigger('change');
|
445 |
+
}
|
446 |
+
|
447 |
+
};
|
448 |
+
|
449 |
+
DateRangePicker.prototype = {
|
450 |
+
|
451 |
+
constructor: DateRangePicker,
|
452 |
+
|
453 |
+
setStartDate: function(startDate) {
|
454 |
+
if (typeof startDate === 'string')
|
455 |
+
this.startDate = moment(startDate, this.locale.format);
|
456 |
+
|
457 |
+
if (typeof startDate === 'object')
|
458 |
+
this.startDate = moment(startDate);
|
459 |
+
|
460 |
+
if (!this.timePicker)
|
461 |
+
this.startDate = this.startDate.startOf('day');
|
462 |
+
|
463 |
+
if (this.timePicker && this.timePickerIncrement)
|
464 |
+
this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
|
465 |
+
|
466 |
+
if (this.minDate && this.startDate.isBefore(this.minDate))
|
467 |
+
this.startDate = this.minDate;
|
468 |
+
|
469 |
+
if (this.maxDate && this.startDate.isAfter(this.maxDate))
|
470 |
+
this.startDate = this.maxDate;
|
471 |
+
|
472 |
+
if (!this.isShowing)
|
473 |
+
this.updateElement();
|
474 |
+
|
475 |
+
this.updateMonthsInView();
|
476 |
+
},
|
477 |
+
|
478 |
+
setEndDate: function(endDate) {
|
479 |
+
if (typeof endDate === 'string')
|
480 |
+
this.endDate = moment(endDate, this.locale.format);
|
481 |
+
|
482 |
+
if (typeof endDate === 'object')
|
483 |
+
this.endDate = moment(endDate);
|
484 |
+
|
485 |
+
if (!this.timePicker)
|
486 |
+
this.endDate = this.endDate.endOf('day');
|
487 |
+
|
488 |
+
if (this.timePicker && this.timePickerIncrement)
|
489 |
+
this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement);
|
490 |
+
|
491 |
+
if (this.endDate.isBefore(this.startDate)){
|
492 |
+
var a = this.endDate;
|
493 |
+
this.endDate = this.startDate.clone();
|
494 |
+
this.startDate = a;
|
495 |
+
}
|
496 |
+
|
497 |
+
if(new Date(this.startDate).getTime() == new Date(endDate).getTime()){
|
498 |
+
this.endDate = this.startDate.clone();
|
499 |
+
}
|
500 |
+
|
501 |
+
if (this.maxDate && this.endDate.isAfter(this.maxDate))
|
502 |
+
this.endDate = this.maxDate;
|
503 |
+
|
504 |
+
if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate))
|
505 |
+
this.endDate = this.startDate.clone().add(this.dateLimit);
|
506 |
+
|
507 |
+
this.previousRightTime = this.endDate.clone();
|
508 |
+
|
509 |
+
if (!this.isShowing)
|
510 |
+
this.updateElement();
|
511 |
+
|
512 |
+
this.updateMonthsInView();
|
513 |
+
},
|
514 |
+
|
515 |
+
isInvalidDate: function() {
|
516 |
+
return false;
|
517 |
+
},
|
518 |
+
|
519 |
+
updateView: function() {
|
520 |
+
if (this.timePicker) {
|
521 |
+
this.renderTimePicker('left');
|
522 |
+
this.renderTimePicker('right');
|
523 |
+
if (!this.endDate) {
|
524 |
+
this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled');
|
525 |
+
} else {
|
526 |
+
this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled');
|
527 |
+
}
|
528 |
+
}
|
529 |
+
if (this.endDate) {
|
530 |
+
this.container.find('input[name="daterangepicker_end"]').removeClass('active');
|
531 |
+
this.container.find('input[name="daterangepicker_start"]').addClass('active');
|
532 |
+
} else {
|
533 |
+
this.container.find('input[name="daterangepicker_end"]').addClass('active');
|
534 |
+
this.container.find('input[name="daterangepicker_start"]').removeClass('active');
|
535 |
+
}
|
536 |
+
this.updateMonthsInView();
|
537 |
+
this.updateCalendars();
|
538 |
+
this.updateFormInputs();
|
539 |
+
},
|
540 |
+
|
541 |
+
updateMonthsInView: function() {
|
542 |
+
if (this.endDate) {
|
543 |
+
|
544 |
+
//if both dates are visible already, do nothing
|
545 |
+
if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month &&
|
546 |
+
(this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
|
547 |
+
&&
|
548 |
+
(this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM'))
|
549 |
+
) {
|
550 |
+
return;
|
551 |
+
}
|
552 |
+
|
553 |
+
this.leftCalendar.month = this.startDate.clone().date(2);
|
554 |
+
if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) {
|
555 |
+
this.rightCalendar.month = this.endDate.clone().date(2);
|
556 |
+
} else {
|
557 |
+
this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
|
558 |
+
}
|
559 |
+
|
560 |
+
} else {
|
561 |
+
if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) {
|
562 |
+
this.leftCalendar.month = this.startDate.clone().date(2);
|
563 |
+
this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month');
|
564 |
+
}
|
565 |
+
}
|
566 |
+
},
|
567 |
+
|
568 |
+
updateCalendars: function() {
|
569 |
+
|
570 |
+
if (this.timePicker) {
|
571 |
+
var hour, minute, second;
|
572 |
+
if (this.endDate) {
|
573 |
+
hour = parseInt(this.container.find('.left .hourselect').val(), 10);
|
574 |
+
minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
|
575 |
+
second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
|
576 |
+
if (!this.timePicker24Hour) {
|
577 |
+
var ampm = this.container.find('.left .ampmselect').val();
|
578 |
+
if (ampm === 'PM' && hour < 12)
|
579 |
+
hour += 12;
|
580 |
+
if (ampm === 'AM' && hour === 12)
|
581 |
+
hour = 0;
|
582 |
+
}
|
583 |
+
} else {
|
584 |
+
hour = parseInt(this.container.find('.right .hourselect').val(), 10);
|
585 |
+
minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
|
586 |
+
second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
|
587 |
+
if (!this.timePicker24Hour) {
|
588 |
+
var ampm = this.container.find('.right .ampmselect').val();
|
589 |
+
if (ampm === 'PM' && hour < 12)
|
590 |
+
hour += 12;
|
591 |
+
if (ampm === 'AM' && hour === 12)
|
592 |
+
hour = 0;
|
593 |
+
}
|
594 |
+
}
|
595 |
+
this.leftCalendar.month.hour(hour).minute(minute).second(second);
|
596 |
+
this.rightCalendar.month.hour(hour).minute(minute).second(second);
|
597 |
+
}
|
598 |
+
|
599 |
+
this.renderCalendar('left');
|
600 |
+
this.renderCalendar('right');
|
601 |
+
|
602 |
+
//highlight any predefined range matching the current start and end dates
|
603 |
+
this.container.find('.ranges li').removeClass('active');
|
604 |
+
if (this.endDate == null) return;
|
605 |
+
|
606 |
+
this.calculateChosenLabel();
|
607 |
+
},
|
608 |
+
|
609 |
+
renderCalendar: function(side) {
|
610 |
+
|
611 |
+
//
|
612 |
+
// Build the matrix of dates that will populate the calendar
|
613 |
+
//
|
614 |
+
|
615 |
+
var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar;
|
616 |
+
var month = calendar.month.month();
|
617 |
+
var year = calendar.month.year();
|
618 |
+
var hour = calendar.month.hour();
|
619 |
+
var minute = calendar.month.minute();
|
620 |
+
var second = calendar.month.second();
|
621 |
+
var daysInMonth = moment([year, month]).daysInMonth();
|
622 |
+
var firstDay = moment([year, month, 1]);
|
623 |
+
var lastDay = moment([year, month, daysInMonth]);
|
624 |
+
var lastMonth = moment(firstDay).subtract(1, 'month').month();
|
625 |
+
var lastYear = moment(firstDay).subtract(1, 'month').year();
|
626 |
+
var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth();
|
627 |
+
var dayOfWeek = firstDay.day();
|
628 |
+
|
629 |
+
//initialize a 6 rows x 7 columns array for the calendar
|
630 |
+
var calendar = [];
|
631 |
+
calendar.firstDay = firstDay;
|
632 |
+
calendar.lastDay = lastDay;
|
633 |
+
|
634 |
+
for (var i = 0; i < 6; i++) {
|
635 |
+
calendar[i] = [];
|
636 |
+
}
|
637 |
+
|
638 |
+
//populate the calendar with date objects
|
639 |
+
var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1;
|
640 |
+
if (startDay > daysInLastMonth)
|
641 |
+
startDay -= 7;
|
642 |
+
|
643 |
+
if (dayOfWeek == this.locale.firstDay)
|
644 |
+
startDay = daysInLastMonth - 6;
|
645 |
+
|
646 |
+
var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]);
|
647 |
+
|
648 |
+
var col, row;
|
649 |
+
for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) {
|
650 |
+
if (i > 0 && col % 7 === 0) {
|
651 |
+
col = 0;
|
652 |
+
row++;
|
653 |
+
}
|
654 |
+
calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second);
|
655 |
+
curDate.hour(12);
|
656 |
+
|
657 |
+
if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') {
|
658 |
+
calendar[row][col] = this.minDate.clone();
|
659 |
+
}
|
660 |
+
|
661 |
+
if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') {
|
662 |
+
calendar[row][col] = this.maxDate.clone();
|
663 |
+
}
|
664 |
+
|
665 |
+
}
|
666 |
+
|
667 |
+
//make the calendar object available to hoverDate/clickDate
|
668 |
+
if (side == 'left') {
|
669 |
+
this.leftCalendar.calendar = calendar;
|
670 |
+
} else {
|
671 |
+
this.rightCalendar.calendar = calendar;
|
672 |
+
}
|
673 |
+
|
674 |
+
//
|
675 |
+
// Display the calendar
|
676 |
+
//
|
677 |
+
|
678 |
+
var minDate = side == 'left' ? this.minDate : this.startDate;
|
679 |
+
var maxDate = this.maxDate;
|
680 |
+
var selected = side == 'left' ? this.startDate : this.endDate;
|
681 |
+
|
682 |
+
var html = '<table class="table-condensed">';
|
683 |
+
html += '<thead>';
|
684 |
+
html += '<tr>';
|
685 |
+
|
686 |
+
// add empty cell for week number
|
687 |
+
if (this.showWeekNumbers || this.showISOWeekNumbers)
|
688 |
+
html += '<th></th>';
|
689 |
+
|
690 |
+
if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) {
|
691 |
+
html += '<th class="prev available"><i class="fa fa-chevron-left glyphicon glyphicon-chevron-left"></i></th>';
|
692 |
+
} else {
|
693 |
+
html += '<th></th>';
|
694 |
+
}
|
695 |
+
|
696 |
+
var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY");
|
697 |
+
|
698 |
+
if (this.showDropdowns) {
|
699 |
+
var currentMonth = calendar[1][1].month();
|
700 |
+
var currentYear = calendar[1][1].year();
|
701 |
+
var maxYear = (maxDate && maxDate.year()) || (currentYear + 5);
|
702 |
+
var minYear = (minDate && minDate.year()) || (currentYear - 50);
|
703 |
+
var inMinYear = currentYear == minYear;
|
704 |
+
var inMaxYear = currentYear == maxYear;
|
705 |
+
|
706 |
+
var monthHtml = '<select class="monthselect">';
|
707 |
+
for (var m = 0; m < 12; m++) {
|
708 |
+
if ((!inMinYear || m >= minDate.month()) && (!inMaxYear || m <= maxDate.month())) {
|
709 |
+
monthHtml += "<option value='" + m + "'" +
|
710 |
+
(m === currentMonth ? " selected='selected'" : "") +
|
711 |
+
">" + this.locale.monthNames[m] + "</option>";
|
712 |
+
} else {
|
713 |
+
monthHtml += "<option value='" + m + "'" +
|
714 |
+
(m === currentMonth ? " selected='selected'" : "") +
|
715 |
+
" disabled='disabled'>" + this.locale.monthNames[m] + "</option>";
|
716 |
+
}
|
717 |
+
}
|
718 |
+
monthHtml += "</select>";
|
719 |
+
|
720 |
+
var yearHtml = '<select class="yearselect">';
|
721 |
+
for (var y = minYear; y <= maxYear; y++) {
|
722 |
+
yearHtml += '<option value="' + y + '"' +
|
723 |
+
(y === currentYear ? ' selected="selected"' : '') +
|
724 |
+
'>' + y + '</option>';
|
725 |
+
}
|
726 |
+
yearHtml += '</select>';
|
727 |
+
|
728 |
+
dateHtml = monthHtml + yearHtml;
|
729 |
+
}
|
730 |
+
|
731 |
+
html += '<th colspan="5" class="month">' + dateHtml + '</th>';
|
732 |
+
if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) {
|
733 |
+
html += '<th class="next available"><i class="fa fa-chevron-right glyphicon glyphicon-chevron-right"></i></th>';
|
734 |
+
} else {
|
735 |
+
html += '<th></th>';
|
736 |
+
}
|
737 |
+
|
738 |
+
html += '</tr>';
|
739 |
+
html += '<tr>';
|
740 |
+
|
741 |
+
// add week number label
|
742 |
+
if (this.showWeekNumbers || this.showISOWeekNumbers)
|
743 |
+
html += '<th class="week">' + this.locale.weekLabel + '</th>';
|
744 |
+
|
745 |
+
$.each(this.locale.daysOfWeek, function(index, dayOfWeek) {
|
746 |
+
html += '<th>' + dayOfWeek + '</th>';
|
747 |
+
});
|
748 |
+
|
749 |
+
html += '</tr>';
|
750 |
+
html += '</thead>';
|
751 |
+
html += '<tbody>';
|
752 |
+
|
753 |
+
//adjust maxDate to reflect the dateLimit setting in order to
|
754 |
+
//grey out end dates beyond the dateLimit
|
755 |
+
if (this.endDate == null && this.dateLimit) {
|
756 |
+
var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day');
|
757 |
+
if (!maxDate || maxLimit.isBefore(maxDate)) {
|
758 |
+
maxDate = maxLimit;
|
759 |
+
}
|
760 |
+
}
|
761 |
+
|
762 |
+
for (var row = 0; row < 6; row++) {
|
763 |
+
html += '<tr>';
|
764 |
+
|
765 |
+
// add week number
|
766 |
+
if (this.showWeekNumbers)
|
767 |
+
html += '<td class="week">' + calendar[row][0].week() + '</td>';
|
768 |
+
else if (this.showISOWeekNumbers)
|
769 |
+
html += '<td class="week">' + calendar[row][0].isoWeek() + '</td>';
|
770 |
+
|
771 |
+
for (var col = 0; col < 7; col++) {
|
772 |
+
|
773 |
+
var classes = [];
|
774 |
+
|
775 |
+
//highlight today's date
|
776 |
+
if (calendar[row][col].isSame(new Date(), "day"))
|
777 |
+
classes.push('today');
|
778 |
+
|
779 |
+
//highlight weekends
|
780 |
+
if (calendar[row][col].isoWeekday() > 5)
|
781 |
+
classes.push('weekend');
|
782 |
+
|
783 |
+
//grey out the dates in other months displayed at beginning and end of this calendar
|
784 |
+
if (calendar[row][col].month() != calendar[1][1].month())
|
785 |
+
classes.push('off');
|
786 |
+
|
787 |
+
//don't allow selection of dates before the minimum date
|
788 |
+
if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day'))
|
789 |
+
classes.push('off', 'disabled');
|
790 |
+
|
791 |
+
//don't allow selection of dates after the maximum date
|
792 |
+
if (maxDate && calendar[row][col].isAfter(maxDate, 'day'))
|
793 |
+
classes.push('off', 'disabled');
|
794 |
+
|
795 |
+
//don't allow selection of date if a custom function decides it's invalid
|
796 |
+
if (this.isInvalidDate(calendar[row][col]))
|
797 |
+
classes.push('off', 'disabled');
|
798 |
+
|
799 |
+
//highlight the currently selected start date
|
800 |
+
if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD'))
|
801 |
+
classes.push('active', 'start-date');
|
802 |
+
|
803 |
+
//highlight the currently selected end date
|
804 |
+
if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD'))
|
805 |
+
classes.push('active', 'end-date');
|
806 |
+
|
807 |
+
//highlight dates in-between the selected dates
|
808 |
+
if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate)
|
809 |
+
classes.push('in-range');
|
810 |
+
|
811 |
+
var cname = '', disabled = false;
|
812 |
+
for (var i = 0; i < classes.length; i++) {
|
813 |
+
cname += classes[i] + ' ';
|
814 |
+
if (classes[i] == 'disabled')
|
815 |
+
disabled = true;
|
816 |
+
}
|
817 |
+
if (!disabled)
|
818 |
+
cname += 'available';
|
819 |
+
|
820 |
+
html += '<td class="' + cname.replace(/^\s+|\s+$/g, '') + '" data-title="' + 'r' + row + 'c' + col + '">' + calendar[row][col].date() + '</td>';
|
821 |
+
|
822 |
+
}
|
823 |
+
html += '</tr>';
|
824 |
+
}
|
825 |
+
|
826 |
+
html += '</tbody>';
|
827 |
+
html += '</table>';
|
828 |
+
|
829 |
+
this.container.find('.calendar.' + side + ' .calendar-table').html(html);
|
830 |
+
|
831 |
+
},
|
832 |
+
|
833 |
+
renderTimePicker: function(side) {
|
834 |
+
|
835 |
+
var html, selected, minDate, maxDate = this.maxDate;
|
836 |
+
|
837 |
+
if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)))
|
838 |
+
maxDate = this.startDate.clone().add(this.dateLimit);
|
839 |
+
|
840 |
+
if (side == 'left') {
|
841 |
+
selected = this.startDate.clone();
|
842 |
+
minDate = this.minDate;
|
843 |
+
} else if (side == 'right') {
|
844 |
+
selected = this.endDate ? this.endDate.clone() : this.previousRightTime.clone();
|
845 |
+
minDate = this.startDate;
|
846 |
+
|
847 |
+
//Preserve the time already selected
|
848 |
+
var timeSelector = this.container.find('.calendar.right .calendar-time div');
|
849 |
+
if (timeSelector.html() != '') {
|
850 |
+
|
851 |
+
selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour());
|
852 |
+
selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute());
|
853 |
+
selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second());
|
854 |
+
|
855 |
+
if (!this.timePicker24Hour) {
|
856 |
+
var ampm = timeSelector.find('.ampmselect option:selected').val();
|
857 |
+
if (ampm === 'PM' && selected.hour() < 12)
|
858 |
+
selected.hour(selected.hour() + 12);
|
859 |
+
if (ampm === 'AM' && selected.hour() === 12)
|
860 |
+
selected.hour(0);
|
861 |
+
}
|
862 |
+
|
863 |
+
if (selected.isBefore(this.startDate))
|
864 |
+
selected = this.startDate.clone();
|
865 |
+
|
866 |
+
if (selected.isAfter(maxDate))
|
867 |
+
selected = maxDate.clone();
|
868 |
+
|
869 |
+
}
|
870 |
+
}
|
871 |
+
|
872 |
+
//
|
873 |
+
// hours
|
874 |
+
//
|
875 |
+
|
876 |
+
html = '<select class="hourselect">';
|
877 |
+
|
878 |
+
var start = this.timePicker24Hour ? 0 : 1;
|
879 |
+
var end = this.timePicker24Hour ? 23 : 12;
|
880 |
+
|
881 |
+
for (var i = start; i <= end; i++) {
|
882 |
+
var i_in_24 = i;
|
883 |
+
if (!this.timePicker24Hour)
|
884 |
+
i_in_24 = selected.hour() >= 12 ? (i == 12 ? 12 : i + 12) : (i == 12 ? 0 : i);
|
885 |
+
|
886 |
+
var time = selected.clone().hour(i_in_24);
|
887 |
+
var disabled = false;
|
888 |
+
if (minDate && time.minute(59).isBefore(minDate))
|
889 |
+
disabled = true;
|
890 |
+
if (maxDate && time.minute(0).isAfter(maxDate))
|
891 |
+
disabled = true;
|
892 |
+
|
893 |
+
if (i_in_24 == selected.hour() && !disabled) {
|
894 |
+
html += '<option value="' + i + '" selected="selected">' + i + '</option>';
|
895 |
+
} else if (disabled) {
|
896 |
+
html += '<option value="' + i + '" disabled="disabled" class="disabled">' + i + '</option>';
|
897 |
+
} else {
|
898 |
+
html += '<option value="' + i + '">' + i + '</option>';
|
899 |
+
}
|
900 |
+
}
|
901 |
+
|
902 |
+
html += '</select> ';
|
903 |
+
|
904 |
+
//
|
905 |
+
// minutes
|
906 |
+
//
|
907 |
+
|
908 |
+
html += ': <select class="minuteselect">';
|
909 |
+
|
910 |
+
for (var i = 0; i < 60; i += this.timePickerIncrement) {
|
911 |
+
var padded = i < 10 ? '0' + i : i;
|
912 |
+
var time = selected.clone().minute(i);
|
913 |
+
|
914 |
+
var disabled = false;
|
915 |
+
if (minDate && time.second(59).isBefore(minDate))
|
916 |
+
disabled = true;
|
917 |
+
if (maxDate && time.second(0).isAfter(maxDate))
|
918 |
+
disabled = true;
|
919 |
+
|
920 |
+
if (selected.minute() == i && !disabled) {
|
921 |
+
html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
|
922 |
+
} else if (disabled) {
|
923 |
+
html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
|
924 |
+
} else {
|
925 |
+
html += '<option value="' + i + '">' + padded + '</option>';
|
926 |
+
}
|
927 |
+
}
|
928 |
+
|
929 |
+
html += '</select> ';
|
930 |
+
|
931 |
+
//
|
932 |
+
// seconds
|
933 |
+
//
|
934 |
+
|
935 |
+
if (this.timePickerSeconds) {
|
936 |
+
html += ': <select class="secondselect">';
|
937 |
+
|
938 |
+
for (var i = 0; i < 60; i++) {
|
939 |
+
var padded = i < 10 ? '0' + i : i;
|
940 |
+
var time = selected.clone().second(i);
|
941 |
+
|
942 |
+
var disabled = false;
|
943 |
+
if (minDate && time.isBefore(minDate))
|
944 |
+
disabled = true;
|
945 |
+
if (maxDate && time.isAfter(maxDate))
|
946 |
+
disabled = true;
|
947 |
+
|
948 |
+
if (selected.second() == i && !disabled) {
|
949 |
+
html += '<option value="' + i + '" selected="selected">' + padded + '</option>';
|
950 |
+
} else if (disabled) {
|
951 |
+
html += '<option value="' + i + '" disabled="disabled" class="disabled">' + padded + '</option>';
|
952 |
+
} else {
|
953 |
+
html += '<option value="' + i + '">' + padded + '</option>';
|
954 |
+
}
|
955 |
+
}
|
956 |
+
|
957 |
+
html += '</select> ';
|
958 |
+
}
|
959 |
+
|
960 |
+
//
|
961 |
+
// AM/PM
|
962 |
+
//
|
963 |
+
|
964 |
+
if (!this.timePicker24Hour) {
|
965 |
+
html += '<select class="ampmselect">';
|
966 |
+
|
967 |
+
var am_html = '';
|
968 |
+
var pm_html = '';
|
969 |
+
|
970 |
+
if (minDate && selected.clone().hour(12).minute(0).second(0).isBefore(minDate))
|
971 |
+
am_html = ' disabled="disabled" class="disabled"';
|
972 |
+
|
973 |
+
if (maxDate && selected.clone().hour(0).minute(0).second(0).isAfter(maxDate))
|
974 |
+
pm_html = ' disabled="disabled" class="disabled"';
|
975 |
+
|
976 |
+
if (selected.hour() >= 12) {
|
977 |
+
html += '<option value="AM"' + am_html + '>AM</option><option value="PM" selected="selected"' + pm_html + '>PM</option>';
|
978 |
+
} else {
|
979 |
+
html += '<option value="AM" selected="selected"' + am_html + '>AM</option><option value="PM"' + pm_html + '>PM</option>';
|
980 |
+
}
|
981 |
+
|
982 |
+
html += '</select>';
|
983 |
+
}
|
984 |
+
|
985 |
+
this.container.find('.calendar.' + side + ' .calendar-time div').html(html);
|
986 |
+
|
987 |
+
},
|
988 |
+
|
989 |
+
updateFormInputs: function() {
|
990 |
+
|
991 |
+
//ignore mouse movements while an above-calendar text input has focus
|
992 |
+
if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
993 |
+
return;
|
994 |
+
|
995 |
+
this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format));
|
996 |
+
if (this.endDate)
|
997 |
+
this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format));
|
998 |
+
|
999 |
+
if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) {
|
1000 |
+
this.container.find('button.applyBtn').removeAttr('disabled');
|
1001 |
+
} else {
|
1002 |
+
this.container.find('button.applyBtn').attr('disabled', 'disabled');
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
},
|
1006 |
+
|
1007 |
+
move: function() {
|
1008 |
+
var parentOffset = { top: 0, left: 0 },
|
1009 |
+
containerTop;
|
1010 |
+
var parentRightEdge = $(window).width();
|
1011 |
+
if (!this.parentEl.is('body')) {
|
1012 |
+
parentOffset = {
|
1013 |
+
top: this.parentEl.offset().top - this.parentEl.scrollTop(),
|
1014 |
+
left: this.parentEl.offset().left - this.parentEl.scrollLeft()
|
1015 |
+
};
|
1016 |
+
parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left;
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
if (this.drops == 'up')
|
1020 |
+
containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top;
|
1021 |
+
else
|
1022 |
+
containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top;
|
1023 |
+
this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup');
|
1024 |
+
|
1025 |
+
if (this.opens == 'left') {
|
1026 |
+
this.container.css({
|
1027 |
+
top: containerTop,
|
1028 |
+
right: parentRightEdge - this.element.offset().left - this.element.outerWidth() - 11,
|
1029 |
+
left: 'auto'
|
1030 |
+
});
|
1031 |
+
if (this.container.offset().left < 0) {
|
1032 |
+
this.container.css({
|
1033 |
+
right: 'auto',
|
1034 |
+
left: 9
|
1035 |
+
});
|
1036 |
+
}
|
1037 |
+
} else if (this.opens == 'center') {
|
1038 |
+
this.container.css({
|
1039 |
+
top: containerTop,
|
1040 |
+
left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2
|
1041 |
+
- this.container.outerWidth() / 2,
|
1042 |
+
right: 'auto'
|
1043 |
+
});
|
1044 |
+
if (this.container.offset().left < 0) {
|
1045 |
+
this.container.css({
|
1046 |
+
right: 'auto',
|
1047 |
+
left: 9
|
1048 |
+
});
|
1049 |
+
}
|
1050 |
+
} else {
|
1051 |
+
this.container.css({
|
1052 |
+
top: containerTop,
|
1053 |
+
left: this.element.offset().left - parentOffset.left,
|
1054 |
+
right: 'auto'
|
1055 |
+
});
|
1056 |
+
if (this.container.offset().left + this.container.outerWidth() > $(window).width()) {
|
1057 |
+
this.container.css({
|
1058 |
+
left: 'auto',
|
1059 |
+
right: 0
|
1060 |
+
});
|
1061 |
+
}
|
1062 |
+
}
|
1063 |
+
},
|
1064 |
+
|
1065 |
+
show: function(e) {
|
1066 |
+
if (this.isShowing) return;
|
1067 |
+
|
1068 |
+
// Create a click proxy that is private to this instance of datepicker, for unbinding
|
1069 |
+
this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this);
|
1070 |
+
|
1071 |
+
// Bind global datepicker mousedown for hiding and
|
1072 |
+
$(document)
|
1073 |
+
.on('mousedown.daterangepicker', this._outsideClickProxy)
|
1074 |
+
// also support mobile devices
|
1075 |
+
.on('touchend.daterangepicker', this._outsideClickProxy)
|
1076 |
+
// also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them
|
1077 |
+
.on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy)
|
1078 |
+
// and also close when focus changes to outside the picker (eg. tabbing between controls)
|
1079 |
+
.on('focusin.daterangepicker', this._outsideClickProxy);
|
1080 |
+
|
1081 |
+
// Reposition the picker if the window is resized while it's open
|
1082 |
+
$(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this));
|
1083 |
+
|
1084 |
+
this.oldStartDate = this.startDate.clone();
|
1085 |
+
this.oldEndDate = this.endDate.clone();
|
1086 |
+
this.previousRightTime = this.endDate.clone();
|
1087 |
+
|
1088 |
+
this.updateView();
|
1089 |
+
this.container.show();
|
1090 |
+
this.move();
|
1091 |
+
this.element.trigger('show.daterangepicker', this);
|
1092 |
+
this.isShowing = true;
|
1093 |
+
},
|
1094 |
+
|
1095 |
+
hide: function(e) {
|
1096 |
+
if (!this.isShowing) return;
|
1097 |
+
|
1098 |
+
//incomplete date selection, revert to last values
|
1099 |
+
if (!this.endDate) {
|
1100 |
+
this.startDate = this.oldStartDate.clone();
|
1101 |
+
this.endDate = this.oldEndDate.clone();
|
1102 |
+
}
|
1103 |
+
|
1104 |
+
//if a new date range was selected, invoke the user callback function
|
1105 |
+
if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate))
|
1106 |
+
this.callback(this.startDate, this.endDate, this.chosenLabel);
|
1107 |
+
|
1108 |
+
//if picker is attached to a text input, update it
|
1109 |
+
this.updateElement();
|
1110 |
+
|
1111 |
+
$(document).off('.daterangepicker');
|
1112 |
+
$(window).off('.daterangepicker');
|
1113 |
+
this.container.hide();
|
1114 |
+
this.element.trigger('hide.daterangepicker', this);
|
1115 |
+
this.isShowing = false;
|
1116 |
+
},
|
1117 |
+
|
1118 |
+
toggle: function(e) {
|
1119 |
+
if (this.isShowing) {
|
1120 |
+
this.hide();
|
1121 |
+
} else {
|
1122 |
+
this.show();
|
1123 |
+
}
|
1124 |
+
},
|
1125 |
+
|
1126 |
+
outsideClick: function(e) {
|
1127 |
+
var target = $(e.target);
|
1128 |
+
// if the page is clicked anywhere except within the daterangerpicker/button
|
1129 |
+
// itself then call this.hide()
|
1130 |
+
if (
|
1131 |
+
// ie modal dialog fix
|
1132 |
+
e.type == "focusin" ||
|
1133 |
+
target.closest(this.element).length ||
|
1134 |
+
target.closest(this.container).length ||
|
1135 |
+
target.closest('.calendar-table').length
|
1136 |
+
) return;
|
1137 |
+
this.hide();
|
1138 |
+
},
|
1139 |
+
|
1140 |
+
showCalendars: function() {
|
1141 |
+
this.container.addClass('show-calendar');
|
1142 |
+
this.move();
|
1143 |
+
this.element.trigger('showCalendar.daterangepicker', this);
|
1144 |
+
},
|
1145 |
+
|
1146 |
+
hideCalendars: function() {
|
1147 |
+
this.container.removeClass('show-calendar');
|
1148 |
+
this.element.trigger('hideCalendar.daterangepicker', this);
|
1149 |
+
},
|
1150 |
+
|
1151 |
+
hoverRange: function(e) {
|
1152 |
+
|
1153 |
+
//ignore mouse movements while an above-calendar text input has focus
|
1154 |
+
if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
1155 |
+
return;
|
1156 |
+
|
1157 |
+
var label = e.target.innerHTML;
|
1158 |
+
if (label == this.locale.customRangeLabel) {
|
1159 |
+
this.updateView();
|
1160 |
+
} else {
|
1161 |
+
var dates = this.ranges[label];
|
1162 |
+
this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format));
|
1163 |
+
this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format));
|
1164 |
+
}
|
1165 |
+
|
1166 |
+
},
|
1167 |
+
|
1168 |
+
clickRange: function(e) {
|
1169 |
+
var label = e.target.innerHTML;
|
1170 |
+
this.chosenLabel = label;
|
1171 |
+
if (label == this.locale.customRangeLabel) {
|
1172 |
+
this.showCalendars();
|
1173 |
+
} else {
|
1174 |
+
var dates = this.ranges[label];
|
1175 |
+
this.startDate = dates[0];
|
1176 |
+
this.endDate = dates[1];
|
1177 |
+
|
1178 |
+
if (!this.timePicker) {
|
1179 |
+
this.startDate.startOf('day');
|
1180 |
+
this.endDate.endOf('day');
|
1181 |
+
}
|
1182 |
+
if (!this.alwaysShowCalendars)
|
1183 |
+
this.hideCalendars();
|
1184 |
+
this.clickApply_custom();
|
1185 |
+
}
|
1186 |
+
},
|
1187 |
+
|
1188 |
+
clickPrev: function(e) {
|
1189 |
+
var cal = $(e.target).parents('.calendar');
|
1190 |
+
if (cal.hasClass('left')) {
|
1191 |
+
this.leftCalendar.month.subtract(1, 'month');
|
1192 |
+
if (this.linkedCalendars)
|
1193 |
+
this.rightCalendar.month.subtract(1, 'month');
|
1194 |
+
} else {
|
1195 |
+
this.rightCalendar.month.subtract(1, 'month');
|
1196 |
+
}
|
1197 |
+
this.updateCalendars();
|
1198 |
+
},
|
1199 |
+
|
1200 |
+
clickNext: function(e) {
|
1201 |
+
var cal = $(e.target).parents('.calendar');
|
1202 |
+
if (cal.hasClass('left')) {
|
1203 |
+
this.leftCalendar.month.add(1, 'month');
|
1204 |
+
} else {
|
1205 |
+
this.rightCalendar.month.add(1, 'month');
|
1206 |
+
if (this.linkedCalendars)
|
1207 |
+
this.leftCalendar.month.add(1, 'month');
|
1208 |
+
}
|
1209 |
+
this.updateCalendars();
|
1210 |
+
},
|
1211 |
+
|
1212 |
+
hoverDate: function(e) {
|
1213 |
+
|
1214 |
+
//ignore mouse movements while an above-calendar text input has focus
|
1215 |
+
if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus"))
|
1216 |
+
return;
|
1217 |
+
|
1218 |
+
//ignore dates that can't be selected
|
1219 |
+
if (!$(e.target).hasClass('available')) return;
|
1220 |
+
|
1221 |
+
//have the text inputs above calendars reflect the date being hovered over
|
1222 |
+
var title = $(e.target).attr('data-title');
|
1223 |
+
var row = title.substr(1, 1);
|
1224 |
+
var col = title.substr(3, 1);
|
1225 |
+
var cal = $(e.target).parents('.calendar');
|
1226 |
+
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
1227 |
+
|
1228 |
+
if (this.endDate) {
|
1229 |
+
this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format));
|
1230 |
+
} else {
|
1231 |
+
this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format));
|
1232 |
+
}
|
1233 |
+
|
1234 |
+
//highlight the dates between the start date and the date being hovered as a potential end date
|
1235 |
+
var leftCalendar = this.leftCalendar;
|
1236 |
+
var rightCalendar = this.rightCalendar;
|
1237 |
+
var startDate = this.startDate;
|
1238 |
+
if (!this.endDate) {
|
1239 |
+
this.container.find('.calendar td').each(function(index, el) {
|
1240 |
+
|
1241 |
+
//skip week numbers, only look at dates
|
1242 |
+
if ($(el).hasClass('week')) return;
|
1243 |
+
|
1244 |
+
var title = $(el).attr('data-title');
|
1245 |
+
var row = title.substr(1, 1);
|
1246 |
+
var col = title.substr(3, 1);
|
1247 |
+
var cal = $(el).parents('.calendar');
|
1248 |
+
var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col];
|
1249 |
+
|
1250 |
+
if (dt.isAfter(startDate) && dt.isBefore(date)) {
|
1251 |
+
$(el).addClass('in-range');
|
1252 |
+
} else {
|
1253 |
+
$(el).removeClass('in-range');
|
1254 |
+
}
|
1255 |
+
|
1256 |
+
});
|
1257 |
+
}
|
1258 |
+
|
1259 |
+
},
|
1260 |
+
|
1261 |
+
clickDate: function(e) {
|
1262 |
+
|
1263 |
+
if (!$(e.target).hasClass('available')) return;
|
1264 |
+
|
1265 |
+
var title = $(e.target).attr('data-title');
|
1266 |
+
var row = title.substr(1, 1);
|
1267 |
+
var col = title.substr(3, 1);
|
1268 |
+
var cal = $(e.target).parents('.calendar');
|
1269 |
+
var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col];
|
1270 |
+
|
1271 |
+
//
|
1272 |
+
// this function needs to do a few things:
|
1273 |
+
// * alternate between selecting a start and end date for the range,
|
1274 |
+
// * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date
|
1275 |
+
// * if autoapply is enabled, and an end date was chosen, apply the selection
|
1276 |
+
// * if single date picker mode, and time picker isn't enabled, apply the selection immediately
|
1277 |
+
//
|
1278 |
+
|
1279 |
+
|
1280 |
+
if (this.endDate) {
|
1281 |
+
if (this.timePicker) {
|
1282 |
+
var hour = parseInt(this.container.find('.left .hourselect').val(), 10);
|
1283 |
+
if (!this.timePicker24Hour) {
|
1284 |
+
var ampm = this.container.find('.left .ampmselect').val();
|
1285 |
+
if (ampm === 'PM' && hour < 12)
|
1286 |
+
hour += 12;
|
1287 |
+
if (ampm === 'AM' && hour === 12)
|
1288 |
+
hour = 0;
|
1289 |
+
}
|
1290 |
+
var minute = parseInt(this.container.find('.left .minuteselect').val(), 10);
|
1291 |
+
var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0;
|
1292 |
+
date = date.clone().hour(hour).minute(minute).second(second);
|
1293 |
+
}
|
1294 |
+
this.endDate = null;
|
1295 |
+
this.setStartDate(date.clone());
|
1296 |
+
}
|
1297 |
+
else if (!this.endDate && date.isBefore(this.startDate, 'day')) {
|
1298 |
+
//special case: clicking the same date for start/end,
|
1299 |
+
//but the time of the end date is before the start date
|
1300 |
+
this.setEndDate(date.clone());
|
1301 |
+
}
|
1302 |
+
else if (!this.endDate && new Date(this.startDate).getTime() == new Date(date._d).getTime()) {
|
1303 |
+
//special case: clicking the same date for start/end,
|
1304 |
+
//but the time of the end date is before the start date
|
1305 |
+
this.setEndDate(this.startDate.clone());
|
1306 |
+
}
|
1307 |
+
else {
|
1308 |
+
if (this.timePicker) {
|
1309 |
+
var hour = parseInt(this.container.find('.right .hourselect').val(), 10);
|
1310 |
+
if (!this.timePicker24Hour) {
|
1311 |
+
var ampm = this.container.find('.right .ampmselect').val();
|
1312 |
+
if (ampm === 'PM' && hour < 12)
|
1313 |
+
hour += 12;
|
1314 |
+
if (ampm === 'AM' && hour === 12)
|
1315 |
+
hour = 0;
|
1316 |
+
}
|
1317 |
+
var minute = parseInt(this.container.find('.right .minuteselect').val(), 10);
|
1318 |
+
var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0;
|
1319 |
+
date = date.clone().hour(hour).minute(minute).second(second);
|
1320 |
+
}
|
1321 |
+
this.setEndDate(date.clone());
|
1322 |
+
if (this.autoApply) {
|
1323 |
+
this.calculateChosenLabel();
|
1324 |
+
this.clickApply();
|
1325 |
+
}
|
1326 |
+
}
|
1327 |
+
|
1328 |
+
if (this.singleDatePicker) {
|
1329 |
+
this.setEndDate(this.startDate);
|
1330 |
+
if (!this.timePicker)
|
1331 |
+
this.clickApply();
|
1332 |
+
}
|
1333 |
+
|
1334 |
+
this.updateView();
|
1335 |
+
|
1336 |
+
},
|
1337 |
+
|
1338 |
+
calculateChosenLabel: function() {
|
1339 |
+
var customRange = true;
|
1340 |
+
var i = 0;
|
1341 |
+
for (var range in this.ranges) {
|
1342 |
+
if (this.timePicker) {
|
1343 |
+
if (this.startDate.isSame(this.ranges[range][0]) && this.endDate.isSame(this.ranges[range][1])) {
|
1344 |
+
customRange = false;
|
1345 |
+
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
|
1346 |
+
break;
|
1347 |
+
}
|
1348 |
+
} else {
|
1349 |
+
//ignore times when comparing dates if time picker is not enabled
|
1350 |
+
if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) {
|
1351 |
+
customRange = false;
|
1352 |
+
this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html();
|
1353 |
+
break;
|
1354 |
+
}
|
1355 |
+
}
|
1356 |
+
i++;
|
1357 |
+
}
|
1358 |
+
if (customRange) {
|
1359 |
+
this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html();
|
1360 |
+
this.showCalendars();
|
1361 |
+
}
|
1362 |
+
},
|
1363 |
+
|
1364 |
+
clickApply: function(e) {
|
1365 |
+
this.hide();
|
1366 |
+
this.element.trigger('apply.daterangepicker', this);
|
1367 |
+
},
|
1368 |
+
clickApply_custom: function(e) {
|
1369 |
+
this.container.find('.ranges li:last').mouseenter();
|
1370 |
+
this.element.trigger('apply.daterangepicker', this);
|
1371 |
+
},
|
1372 |
+
|
1373 |
+
clickCancel: function(e) {
|
1374 |
+
this.startDate = this.oldStartDate;
|
1375 |
+
this.endDate = this.oldEndDate;
|
1376 |
+
this.hide();
|
1377 |
+
this.element.trigger('cancel.daterangepicker', this);
|
1378 |
+
},
|
1379 |
+
|
1380 |
+
monthOrYearChanged: function(e) {
|
1381 |
+
var isLeft = $(e.target).closest('.calendar').hasClass('left'),
|
1382 |
+
leftOrRight = isLeft ? 'left' : 'right',
|
1383 |
+
cal = this.container.find('.calendar.'+leftOrRight);
|
1384 |
+
|
1385 |
+
// Month must be Number for new moment versions
|
1386 |
+
var month = parseInt(cal.find('.monthselect').val(), 10);
|
1387 |
+
var year = cal.find('.yearselect').val();
|
1388 |
+
|
1389 |
+
if (!isLeft) {
|
1390 |
+
if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) {
|
1391 |
+
month = this.startDate.month();
|
1392 |
+
year = this.startDate.year();
|
1393 |
+
}
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
if (this.minDate) {
|
1397 |
+
if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) {
|
1398 |
+
month = this.minDate.month();
|
1399 |
+
year = this.minDate.year();
|
1400 |
+
}
|
1401 |
+
}
|
1402 |
+
|
1403 |
+
if (this.maxDate) {
|
1404 |
+
if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) {
|
1405 |
+
month = this.maxDate.month();
|
1406 |
+
year = this.maxDate.year();
|
1407 |
+
}
|
1408 |
+
}
|
1409 |
+
|
1410 |
+
if (isLeft) {
|
1411 |
+
this.leftCalendar.month.month(month).year(year);
|
1412 |
+
if (this.linkedCalendars)
|
1413 |
+
this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month');
|
1414 |
+
} else {
|
1415 |
+
this.rightCalendar.month.month(month).year(year);
|
1416 |
+
if (this.linkedCalendars)
|
1417 |
+
this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month');
|
1418 |
+
}
|
1419 |
+
this.updateCalendars();
|
1420 |
+
},
|
1421 |
+
|
1422 |
+
timeChanged: function(e) {
|
1423 |
+
|
1424 |
+
var cal = $(e.target).closest('.calendar'),
|
1425 |
+
isLeft = cal.hasClass('left');
|
1426 |
+
|
1427 |
+
var hour = parseInt(cal.find('.hourselect').val(), 10);
|
1428 |
+
var minute = parseInt(cal.find('.minuteselect').val(), 10);
|
1429 |
+
var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0;
|
1430 |
+
|
1431 |
+
if (!this.timePicker24Hour) {
|
1432 |
+
var ampm = cal.find('.ampmselect').val();
|
1433 |
+
if (ampm === 'PM' && hour < 12)
|
1434 |
+
hour += 12;
|
1435 |
+
if (ampm === 'AM' && hour === 12)
|
1436 |
+
hour = 0;
|
1437 |
+
}
|
1438 |
+
|
1439 |
+
if (isLeft) {
|
1440 |
+
var start = this.startDate.clone();
|
1441 |
+
start.hour(hour);
|
1442 |
+
start.minute(minute);
|
1443 |
+
start.second(second);
|
1444 |
+
this.setStartDate(start);
|
1445 |
+
if (this.singleDatePicker) {
|
1446 |
+
this.endDate = this.startDate.clone();
|
1447 |
+
} else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) {
|
1448 |
+
this.setEndDate(start.clone());
|
1449 |
+
}
|
1450 |
+
} else if (this.endDate) {
|
1451 |
+
var end = this.endDate.clone();
|
1452 |
+
end.hour(hour);
|
1453 |
+
end.minute(minute);
|
1454 |
+
end.second(second);
|
1455 |
+
this.setEndDate(end);
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
//update the calendars so all clickable dates reflect the new time component
|
1459 |
+
this.updateCalendars();
|
1460 |
+
|
1461 |
+
//update the form inputs above the calendars with the new time
|
1462 |
+
this.updateFormInputs();
|
1463 |
+
|
1464 |
+
//re-render the time pickers because changing one selection can affect what's enabled in another
|
1465 |
+
this.renderTimePicker('left');
|
1466 |
+
this.renderTimePicker('right');
|
1467 |
+
|
1468 |
+
},
|
1469 |
+
|
1470 |
+
formInputsChanged: function(e) {
|
1471 |
+
var isRight = $(e.target).closest('.calendar').hasClass('right');
|
1472 |
+
var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format);
|
1473 |
+
var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format);
|
1474 |
+
|
1475 |
+
if (start.isValid() && end.isValid()) {
|
1476 |
+
|
1477 |
+
if (isRight && end.isBefore(start))
|
1478 |
+
start = end.clone();
|
1479 |
+
|
1480 |
+
this.setStartDate(start);
|
1481 |
+
this.setEndDate(end);
|
1482 |
+
|
1483 |
+
if (isRight) {
|
1484 |
+
this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format));
|
1485 |
+
} else {
|
1486 |
+
this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format));
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
}
|
1490 |
+
|
1491 |
+
this.updateCalendars();
|
1492 |
+
if (this.timePicker) {
|
1493 |
+
this.renderTimePicker('left');
|
1494 |
+
this.renderTimePicker('right');
|
1495 |
+
}
|
1496 |
+
},
|
1497 |
+
|
1498 |
+
elementChanged: function() {
|
1499 |
+
if (!this.element.is('input')) return;
|
1500 |
+
if (!this.element.val().length) return;
|
1501 |
+
if (this.element.val().length < this.locale.format.length) return;
|
1502 |
+
|
1503 |
+
var dateString = this.element.val().split(this.locale.separator),
|
1504 |
+
start = null,
|
1505 |
+
end = null;
|
1506 |
+
|
1507 |
+
if (dateString.length === 2) {
|
1508 |
+
start = moment(dateString[0], this.locale.format);
|
1509 |
+
end = moment(dateString[1], this.locale.format);
|
1510 |
+
}
|
1511 |
+
|
1512 |
+
if (this.singleDatePicker || start === null || end === null) {
|
1513 |
+
start = moment(this.element.val(), this.locale.format);
|
1514 |
+
end = start;
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
if (!start.isValid() || !end.isValid()) return;
|
1518 |
+
|
1519 |
+
this.setStartDate(start);
|
1520 |
+
this.setEndDate(end);
|
1521 |
+
this.updateView();
|
1522 |
+
},
|
1523 |
+
|
1524 |
+
keydown: function(e) {
|
1525 |
+
//hide on tab or enter
|
1526 |
+
if ((e.keyCode === 9) || (e.keyCode === 13)) {
|
1527 |
+
this.hide();
|
1528 |
+
}
|
1529 |
+
},
|
1530 |
+
|
1531 |
+
updateElement: function() {
|
1532 |
+
if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) {
|
1533 |
+
this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format));
|
1534 |
+
this.element.trigger('change');
|
1535 |
+
} else if (this.element.is('input') && this.autoUpdateInput) {
|
1536 |
+
this.element.val(this.startDate.format(this.locale.format));
|
1537 |
+
this.element.trigger('change');
|
1538 |
+
}
|
1539 |
+
},
|
1540 |
+
|
1541 |
+
remove: function() {
|
1542 |
+
this.container.remove();
|
1543 |
+
this.element.off('.daterangepicker');
|
1544 |
+
this.element.removeData();
|
1545 |
+
}
|
1546 |
+
|
1547 |
+
};
|
1548 |
+
|
1549 |
+
$.fn.daterangepicker = function(options, callback) {
|
1550 |
+
this.each(function() {
|
1551 |
+
var el = $(this);
|
1552 |
+
if (el.data('daterangepicker'))
|
1553 |
+
el.data('daterangepicker').remove();
|
1554 |
+
el.data('daterangepicker', new DateRangePicker(el, options, callback));
|
1555 |
+
});
|
1556 |
+
return this;
|
1557 |
+
};
|
1558 |
+
|
1559 |
+
return DateRangePicker;
|
1560 |
+
|
1561 |
}));
|
inc/js/gawd_admin.js
CHANGED
@@ -2046,7 +2046,7 @@ function gawd_pie_chart_post_page(uri, divID) {
|
|
2046 |
var dimension = 'date';
|
2047 |
var timezone = -(new Date().getTimezoneOffset() / 60);
|
2048 |
if (divID == 'gawd_post_page_popup') {
|
2049 |
-
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="' + gawd_admin.gawd_plugin_url + '/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div class="close_button_cont"><
|
2050 |
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date">';
|
2051 |
chart_div += '<option value="'+date_7+'">Last 7 Days</option><option value="'+date_30+'">Last 30 Days</option>';
|
2052 |
chart_div += '<option value="'+date_last_month+'">Last month</option><option value="'+date_last_week+'">Last week</option>';
|
@@ -2276,7 +2276,7 @@ function post_page_stats(uri, divID) {
|
|
2276 |
var end_date = start_end_date[1];
|
2277 |
var timezone = -(new Date().getTimezoneOffset() / 60);
|
2278 |
if (divID == 'gawd_post_page_popup') {
|
2279 |
-
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="' + gawd_admin.gawd_plugin_url + '/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div class="close_button_cont"><
|
2280 |
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date">';
|
2281 |
chart_div += '<option value="'+date_7+'">Last 7 Days</option><option value="'+date_30+'">Last 30 Days</option>';
|
2282 |
chart_div += '<option value="'+date_last_month+'">Last month</option><option value="'+date_last_week+'">Last week</option>';
|
2046 |
var dimension = 'date';
|
2047 |
var timezone = -(new Date().getTimezoneOffset() / 60);
|
2048 |
if (divID == 'gawd_post_page_popup') {
|
2049 |
+
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="' + gawd_admin.gawd_plugin_url + '/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div class="close_button_cont"><button class="gawd_btn">X</button>';
|
2050 |
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date">';
|
2051 |
chart_div += '<option value="'+date_7+'">Last 7 Days</option><option value="'+date_30+'">Last 30 Days</option>';
|
2052 |
chart_div += '<option value="'+date_last_month+'">Last month</option><option value="'+date_last_week+'">Last week</option>';
|
2276 |
var end_date = start_end_date[1];
|
2277 |
var timezone = -(new Date().getTimezoneOffset() / 60);
|
2278 |
if (divID == 'gawd_post_page_popup') {
|
2279 |
+
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="' + gawd_admin.gawd_plugin_url + '/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div class="close_button_cont"><button class="gawd_btn">X</button>';
|
2280 |
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date">';
|
2281 |
chart_div += '<option value="'+date_7+'">Last 7 Days</option><option value="'+date_30+'">Last 30 Days</option>';
|
2282 |
chart_div += '<option value="'+date_last_month+'">Last month</option><option value="'+date_last_week+'">Last week</option>';
|
inc/js/gawd_front.js
CHANGED
@@ -1,276 +1,276 @@
|
|
1 |
-
jQuery(document).ready(function(){
|
2 |
-
jQuery('#wp-admin-bar-gawd a').on('click', function(){
|
3 |
-
var uri = '#' + jQuery('#wp-admin-bar-gawd a span').attr('data-url');
|
4 |
-
var uri = jQuery('header h1').text();
|
5 |
-
gawd_chart_type_post_page_front(uri, 'gawd_post_page_popup');
|
6 |
-
})
|
7 |
-
})
|
8 |
-
function gawd_chart_type_post_page_front(uri,divID){
|
9 |
-
if(jQuery("#gawd_chart_type_post_page").val() == 'pie'){
|
10 |
-
gawd_pie_chart_post_page_front(uri,divID);
|
11 |
-
}
|
12 |
-
else{
|
13 |
-
post_page_stats_front(uri,divID);
|
14 |
-
}
|
15 |
-
}
|
16 |
-
function gawd_pie_chart_post_page_front(uri,divID){
|
17 |
-
//jQuery("#chart").empty();
|
18 |
-
//jQuery("#metric_compare").hide();
|
19 |
-
//jQuery(".vs_image").hide();
|
20 |
-
jQuery(".opacity_div_compact").show();
|
21 |
-
jQuery(".loading_div_compact").show();
|
22 |
-
if(typeof divID == 'undefined'){
|
23 |
-
divID = 'gawd_post_page_popup';
|
24 |
-
}
|
25 |
-
var chartType = 'pie';
|
26 |
-
var fillAlphas = 0;
|
27 |
-
|
28 |
-
var metric = typeof jQuery("#gawd_metric_post_page").val() != 'undefined' ? jQuery("#gawd_metric_post_page").val() : (typeof jQuery("#gawd_metric_post_page_popup").val() != 'undefined' ? jQuery("#gawd_metric_post_page_popup").val() : 'sessions');
|
29 |
-
var date_30 = gawd_front.date_30;
|
30 |
-
var date_7 = gawd_front.date_7;
|
31 |
-
var date_yesterday = gawd_front.date_yesterday;
|
32 |
-
var date_today = gawd_front.date_today;
|
33 |
-
var date_this_month = gawd_front.date_this_month;
|
34 |
-
var date_last_month = gawd_front.date_last_month;
|
35 |
-
var date_last_week = gawd_front.date_last_week;
|
36 |
-
|
37 |
-
start_date = typeof jQuery("#gawd_post_page_date").val() != 'undefined' ? jQuery("#gawd_post_page_date").val() : (typeof jQuery("#gawd_post_page_popup_date").val() != 'undefined' ? jQuery("#gawd_post_page_popup_date").val() : date_30);
|
38 |
-
var dimension = 'date';
|
39 |
-
var timezone = -(new Date().getTimezoneOffset()/60);
|
40 |
-
if(divID == 'gawd_post_page_popup'){
|
41 |
-
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="'+gawd_front.gawd_plugin_url+'/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div style="width:100%; height:100%; position:relative;" class="close_button_cont"><
|
42 |
-
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date" class="gawd_draw_analytics_front">';
|
43 |
-
chart_div += '<option value="'+date_30+'">Last 30 Days</option><option value="'+date_7+'">Last 7 Days</option>';
|
44 |
-
chart_div += '<option value="'+date_last_month+'">Last month</option><option value="'+date_last_week+'">Last week</option>';
|
45 |
-
chart_div += '<option value="'+date_this_month+'">This month</option><option value="'+date_yesterday+'">Yesterday</option>';
|
46 |
-
chart_div += '<option value="'+date_today+'">Today</option>';
|
47 |
-
chart_div += '</select>';
|
48 |
-
chart_div += '<select name="gawd_metric_post_page_popup" id="gawd_metric_post_page_popup" class="gawd_draw_analytics_front">';
|
49 |
-
chart_div += '<option value="sessions" >Sessions</option><option value="users" >Users</option><option value="bounceRate" >Bounce Rate</option><option value="pageviews" >Pageviews</option><option value="percentNewSessions">% New Sessions</option><option value="avgSessionDuration">Avg Session Duration</option>';
|
50 |
-
chart_div += '</select>';
|
51 |
-
chart_div += '<select name="gawd_chart_type_post_page" id="gawd_chart_type_post_page" class="gawd_draw_analytics_front">';
|
52 |
-
chart_div += '<option value="line">Line Chart</option><option value="pie">Pie Cart</option><option value="column">Column Chart</option>';
|
53 |
-
chart_div += '</select>';
|
54 |
-
chart_div += '<div id="gawd_post_page_popup"></div></div>';
|
55 |
-
jQuery(".page_chart_div").remove();
|
56 |
-
jQuery('#opacity_div').remove();
|
57 |
-
jQuery( "body" ).append(chart_div);
|
58 |
-
jQuery("#gawd_metric_post_page_popup").val(metric);
|
59 |
-
jQuery("#gawd_chart_type_post_page").val(chartType);
|
60 |
-
jQuery("#gawd_post_page_popup_date").val(start_date);
|
61 |
-
jQuery( "#loading_div" ).show();
|
62 |
-
jQuery( "#opacity_div" ).show();
|
63 |
-
jQuery('#gawd_post_page_popup').height('400');
|
64 |
-
jQuery('#gawd_metric_post_page_popup, #gawd_post_page_popup_date, #gawd_chart_type_post_page').on('change',function(){
|
65 |
-
gawd_chart_type_post_page_front(uri,'gawd_post_page_popup');
|
66 |
-
})
|
67 |
-
}
|
68 |
-
var dates = start_date.split('/-/');
|
69 |
-
|
70 |
-
jQuery("#gawd_post_page_meta").empty();
|
71 |
-
jQuery('#gawd_post_page_meta').height('300');
|
72 |
-
jQuery.post(gawd_front.ajaxurl, {
|
73 |
-
action: 'show_page_post_data',
|
74 |
-
metric: metric,
|
75 |
-
start_date: dates[0],
|
76 |
-
end_date: dates[1],
|
77 |
-
dimension: dimension,
|
78 |
-
timezone: timezone,
|
79 |
-
chart: 'pie',
|
80 |
-
security: gawd_front.ajaxnonce,
|
81 |
-
filter: uri,
|
82 |
-
}).done(function (data) {
|
83 |
-
jQuery(".opacity_div_compact").hide();
|
84 |
-
jQuery(".loading_div_compact").hide();
|
85 |
-
if(divID == 'gawd_post_page_popup'){
|
86 |
-
jQuery( "#loading_div" ).remove();
|
87 |
-
jQuery( ".gawd_btn" ).show();
|
88 |
-
jQuery('#opacity_div, .gawd_btn').on('click', function(){
|
89 |
-
jQuery('#opacity_div').remove();
|
90 |
-
jQuery( ".gawd_btn" ).remove();
|
91 |
-
jQuery( ".page_chart_div" ).remove();
|
92 |
-
jQuery( "#loading_div" ).remove();
|
93 |
-
})
|
94 |
-
}
|
95 |
-
var result = JSON.parse(data);
|
96 |
-
result = result.chart_data
|
97 |
-
var diff = ((Date.parse(dates[1]).getTime() - Date.parse(dates[0]).getTime()) / 3600 / 24 / 1000)+1;
|
98 |
-
if(diff > 8){
|
99 |
-
dimension = 'Week';
|
100 |
-
metric = metric.replace(/([A-Z])/g, " $1").trim();
|
101 |
-
metric = metric.charAt(0).toUpperCase() + metric.slice(1);
|
102 |
-
metric = metric.replace(/ +/g, ' ');
|
103 |
-
}
|
104 |
-
var chart = AmCharts.makeChart( divID, {
|
105 |
-
"type": "pie",
|
106 |
-
"theme": "light",
|
107 |
-
'sequencedAnimation': false,
|
108 |
-
"dataProvider": result,
|
109 |
-
"valueField": metric,
|
110 |
-
"titleField": dimension,
|
111 |
-
"depth3D": 15,
|
112 |
-
"angle": 30,
|
113 |
-
"minRadius": 70,
|
114 |
-
"startDuration": 0,
|
115 |
-
"percentPrecision": 1,
|
116 |
-
"precision": 0,
|
117 |
-
"balloon":{
|
118 |
-
"fixedPosition":true
|
119 |
-
},
|
120 |
-
'groupPercent': 1,
|
121 |
-
'marginTop': 0,
|
122 |
-
"export": {
|
123 |
-
"enabled": true
|
124 |
-
},
|
125 |
-
"legend": {
|
126 |
-
"enabled": true,
|
127 |
-
"align": "center",
|
128 |
-
"markerType": "circle",
|
129 |
-
},
|
130 |
-
} );
|
131 |
-
jQuery("#"+divID).find('a').remove();
|
132 |
-
//jQuery("#gbox_griddiv").remove();
|
133 |
-
//var grid = '<table id="griddiv"></table><div id="pager"></div>';
|
134 |
-
//jQuery('.gawd_chart_conteiner').append(grid);
|
135 |
-
//gawd_draw_table(result,metric,metric_compare,dimension);
|
136 |
-
})
|
137 |
-
}
|
138 |
-
function post_page_stats_front(uri,divID){
|
139 |
-
if(typeof divID == 'undefined'){
|
140 |
-
divID = 'gawd_post_page_popup';
|
141 |
-
}
|
142 |
-
var chartType = 'line';
|
143 |
-
var fillAlphas = 0;
|
144 |
-
var checked_line = "";
|
145 |
-
var checked_column = "";
|
146 |
-
if(jQuery("#gawd_chart_type_post_page").val() == 'line'){
|
147 |
-
chartType = 'line';
|
148 |
-
var checked = 'selected="selected"';
|
149 |
-
fillAlphas = 0;
|
150 |
-
}
|
151 |
-
else if(jQuery("#gawd_chart_type_post_page").val() == 'column'){
|
152 |
-
chartType = 'column';
|
153 |
-
checked_column = 'selected="selected"';
|
154 |
-
fillAlphas = 1;
|
155 |
-
}
|
156 |
-
var metric = typeof jQuery("#gawd_metric_post_page_popup").val() != 'undefined' ? jQuery("#gawd_metric_post_page_popup").val() : 'sessions';
|
157 |
-
var date_30 = gawd_front.date_30;
|
158 |
-
var date_7 = gawd_front.date_7;
|
159 |
-
var date_yesterday = gawd_front.date_yesterday;
|
160 |
-
var date_today = gawd_front.date_today;
|
161 |
-
var date_this_month = gawd_front.date_this_month;
|
162 |
-
var date_last_month = gawd_front.date_last_month;
|
163 |
-
var date_last_week = gawd_front.date_last_week;
|
164 |
-
|
165 |
-
start_date = typeof jQuery("#gawd_post_page_date").val() != 'undefined' ? jQuery("#gawd_post_page_date").val() : (typeof jQuery("#gawd_post_page_popup_date").val() != 'undefined' ? jQuery("#gawd_post_page_popup_date").val() : date_30);
|
166 |
-
var dimension = 'date';
|
167 |
-
var timezone = -(new Date().getTimezoneOffset()/60);
|
168 |
-
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="'+gawd_front.gawd_plugin_url+'/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div style="width:100%; height:100%; position:relative;" class="close_button_cont"><
|
169 |
-
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date" class="gawd_draw_analytics_front">';
|
170 |
-
chart_div += '<option value="'+date_30+'">Last 30 Days</option><option value="'+date_7+'">Last 7 Days</option>';
|
171 |
-
chart_div += '<option value="'+date_last_week+'">Last week</option><option value="'+date_last_month+'">Last month</option>';
|
172 |
-
chart_div += '<option value="'+date_this_month+'">This month</option><option value="'+date_yesterday+'">Yesterday</option>';
|
173 |
-
chart_div += '<option value="'+date_today+'">Today</option>';
|
174 |
-
chart_div += '</select>';
|
175 |
-
chart_div += '<select name="gawd_metric_post_page_popup" id="gawd_metric_post_page_popup" class="gawd_draw_analytics_front">';
|
176 |
-
chart_div += '<option value="sessions" >Sessions</option><option value="users" >Users</option><option value="bounceRate" >Bounce Rate</option><option value="pageviews" >Pageviews</option><option value="percentNewSessions">% New Sessions</option><option value="avgSessionDuration">Avg Session Duration</option><option value="pageviewsPerSession" >Pages/Session</option>';
|
177 |
-
chart_div += '</select>';
|
178 |
-
chart_div += '<select name="gawd_chart_type_post_page" id="gawd_chart_type_post_page" class="gawd_draw_analytics_front">';
|
179 |
-
chart_div += '<option '+checked_line+' value="line">Line Chart</option><option value="pie">Pie Cart</option><option '+checked_column+' value="column">Column Chart</option>';
|
180 |
-
chart_div += '</select>';
|
181 |
-
chart_div += '<div id="gawd_post_page_popup"></div></div></div>';
|
182 |
-
jQuery(".page_chart_div").remove();
|
183 |
-
jQuery('#opacity_div').remove();
|
184 |
-
|
185 |
-
jQuery( "body" ).append(chart_div);
|
186 |
-
jQuery("#gawd_metric_post_page_popup").val(metric)
|
187 |
-
jQuery("#gawd_post_page_popup_date").val(start_date)
|
188 |
-
jQuery( "#loading_div" ).show();
|
189 |
-
jQuery( "#opacity_div" ).show();
|
190 |
-
jQuery('#gawd_post_page_popup').height('400');
|
191 |
-
jQuery('#gawd_metric_post_page_popup, #gawd_post_page_popup_date, #gawd_chart_type_post_page').on('change',function(){
|
192 |
-
gawd_chart_type_post_page_front(uri,'gawd_post_page_popup');
|
193 |
-
})
|
194 |
-
jQuery("#gawd_post_page_meta").empty();
|
195 |
-
jQuery('#gawd_post_page_meta').height('300');
|
196 |
-
var dates = start_date.split('/-/');
|
197 |
-
jQuery.post(gawd_front.ajaxurl, {
|
198 |
-
action: 'show_page_post_data',
|
199 |
-
metric: metric,
|
200 |
-
start_date: dates[0],
|
201 |
-
end_date: dates[1],
|
202 |
-
dimension: dimension,
|
203 |
-
timezone: timezone,
|
204 |
-
chart: 'line',
|
205 |
-
security: gawd_front.ajaxnonce,
|
206 |
-
filter: uri,
|
207 |
-
|
208 |
-
}).done(function (data) {
|
209 |
-
var data = JSON.parse(data);
|
210 |
-
data = data.chart_data;
|
211 |
-
if(divID == 'gawd_post_page_popup'){
|
212 |
-
jQuery( "#loading_div" ).remove();
|
213 |
-
jQuery( ".gawd_btn" ).show();
|
214 |
-
jQuery('#opacity_div, .gawd_btn').on('click', function(){
|
215 |
-
jQuery('#opacity_div').remove();
|
216 |
-
jQuery( ".gawd_btn" ).remove();
|
217 |
-
jQuery( ".page_chart_div" ).remove();
|
218 |
-
jQuery( "#loading_div" ).remove();
|
219 |
-
})
|
220 |
-
|
221 |
-
}
|
222 |
-
|
223 |
-
var chart = AmCharts.makeChart(divID, {
|
224 |
-
"dataProvider": data,
|
225 |
-
"type": "serial",
|
226 |
-
"theme": "light",
|
227 |
-
"percentPrecision": 1,
|
228 |
-
"precision": 0,
|
229 |
-
"export": {
|
230 |
-
"enabled": true
|
231 |
-
},
|
232 |
-
"dataDateFormat": "YYYY-MM-DD",
|
233 |
-
"valueAxes": [{
|
234 |
-
"id": "g1",
|
235 |
-
"axisAlpha": 0.4,
|
236 |
-
"position": "left",
|
237 |
-
"title": metric,
|
238 |
-
"ignoreAxisWidth":false
|
239 |
-
|
240 |
-
}],
|
241 |
-
"chartCursor": {
|
242 |
-
"pan": true,
|
243 |
-
"valueLineEnabled": true,
|
244 |
-
"valueLineBalloonEnabled": true,
|
245 |
-
"cursorAlpha": 1,
|
246 |
-
"cursorColor": "#258cbb",
|
247 |
-
"limitToGraph": "g1",
|
248 |
-
"valueLineAlpha": 0.2
|
249 |
-
},
|
250 |
-
"graphs": [{
|
251 |
-
"type": chartType,
|
252 |
-
"valueAxis": "g1",
|
253 |
-
"fillAlphas": fillAlphas,
|
254 |
-
"bullet": "round",
|
255 |
-
"bulletBorderAlpha": 1,
|
256 |
-
"bulletColor": "#FFFFFF",
|
257 |
-
"bulletSize": 5,
|
258 |
-
//"hideBulletsCount": 50,
|
259 |
-
"lineThickness": 2,
|
260 |
-
"title": metric,
|
261 |
-
"useLineColorForBulletBorder": true,
|
262 |
-
"valueField": metric,
|
263 |
-
}],
|
264 |
-
"categoryField": dimension,
|
265 |
-
"categoryAxis": {
|
266 |
-
"parseDates": true,
|
267 |
-
"equalSpacing": true,
|
268 |
-
"dashLength": 2,
|
269 |
-
"minorGridEnabled": true,
|
270 |
-
"boldLabels": true,
|
271 |
-
"labelFrequency": 1,
|
272 |
-
}
|
273 |
-
} )
|
274 |
-
jQuery("#"+divID).find('a').remove();
|
275 |
-
})
|
276 |
-
}
|
1 |
+
jQuery(document).ready(function(){
|
2 |
+
jQuery('#wp-admin-bar-gawd a').on('click', function(){
|
3 |
+
var uri = '#' + jQuery('#wp-admin-bar-gawd a span').attr('data-url');
|
4 |
+
var uri = jQuery('header h1').text();
|
5 |
+
gawd_chart_type_post_page_front(uri, 'gawd_post_page_popup');
|
6 |
+
})
|
7 |
+
})
|
8 |
+
function gawd_chart_type_post_page_front(uri,divID){
|
9 |
+
if(jQuery("#gawd_chart_type_post_page").val() == 'pie'){
|
10 |
+
gawd_pie_chart_post_page_front(uri,divID);
|
11 |
+
}
|
12 |
+
else{
|
13 |
+
post_page_stats_front(uri,divID);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
function gawd_pie_chart_post_page_front(uri,divID){
|
17 |
+
//jQuery("#chart").empty();
|
18 |
+
//jQuery("#metric_compare").hide();
|
19 |
+
//jQuery(".vs_image").hide();
|
20 |
+
jQuery(".opacity_div_compact").show();
|
21 |
+
jQuery(".loading_div_compact").show();
|
22 |
+
if(typeof divID == 'undefined'){
|
23 |
+
divID = 'gawd_post_page_popup';
|
24 |
+
}
|
25 |
+
var chartType = 'pie';
|
26 |
+
var fillAlphas = 0;
|
27 |
+
|
28 |
+
var metric = typeof jQuery("#gawd_metric_post_page").val() != 'undefined' ? jQuery("#gawd_metric_post_page").val() : (typeof jQuery("#gawd_metric_post_page_popup").val() != 'undefined' ? jQuery("#gawd_metric_post_page_popup").val() : 'sessions');
|
29 |
+
var date_30 = gawd_front.date_30;
|
30 |
+
var date_7 = gawd_front.date_7;
|
31 |
+
var date_yesterday = gawd_front.date_yesterday;
|
32 |
+
var date_today = gawd_front.date_today;
|
33 |
+
var date_this_month = gawd_front.date_this_month;
|
34 |
+
var date_last_month = gawd_front.date_last_month;
|
35 |
+
var date_last_week = gawd_front.date_last_week;
|
36 |
+
|
37 |
+
start_date = typeof jQuery("#gawd_post_page_date").val() != 'undefined' ? jQuery("#gawd_post_page_date").val() : (typeof jQuery("#gawd_post_page_popup_date").val() != 'undefined' ? jQuery("#gawd_post_page_popup_date").val() : date_30);
|
38 |
+
var dimension = 'date';
|
39 |
+
var timezone = -(new Date().getTimezoneOffset()/60);
|
40 |
+
if(divID == 'gawd_post_page_popup'){
|
41 |
+
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="'+gawd_front.gawd_plugin_url+'/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div style="width:100%; height:100%; position:relative;" class="close_button_cont"><button class="gawd_btn" >X</button>';
|
42 |
+
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date" class="gawd_draw_analytics_front">';
|
43 |
+
chart_div += '<option value="'+date_30+'">Last 30 Days</option><option value="'+date_7+'">Last 7 Days</option>';
|
44 |
+
chart_div += '<option value="'+date_last_month+'">Last month</option><option value="'+date_last_week+'">Last week</option>';
|
45 |
+
chart_div += '<option value="'+date_this_month+'">This month</option><option value="'+date_yesterday+'">Yesterday</option>';
|
46 |
+
chart_div += '<option value="'+date_today+'">Today</option>';
|
47 |
+
chart_div += '</select>';
|
48 |
+
chart_div += '<select name="gawd_metric_post_page_popup" id="gawd_metric_post_page_popup" class="gawd_draw_analytics_front">';
|
49 |
+
chart_div += '<option value="sessions" >Sessions</option><option value="users" >Users</option><option value="bounceRate" >Bounce Rate</option><option value="pageviews" >Pageviews</option><option value="percentNewSessions">% New Sessions</option><option value="avgSessionDuration">Avg Session Duration</option>';
|
50 |
+
chart_div += '</select>';
|
51 |
+
chart_div += '<select name="gawd_chart_type_post_page" id="gawd_chart_type_post_page" class="gawd_draw_analytics_front">';
|
52 |
+
chart_div += '<option value="line">Line Chart</option><option value="pie">Pie Cart</option><option value="column">Column Chart</option>';
|
53 |
+
chart_div += '</select>';
|
54 |
+
chart_div += '<div id="gawd_post_page_popup"></div></div>';
|
55 |
+
jQuery(".page_chart_div").remove();
|
56 |
+
jQuery('#opacity_div').remove();
|
57 |
+
jQuery( "body" ).append(chart_div);
|
58 |
+
jQuery("#gawd_metric_post_page_popup").val(metric);
|
59 |
+
jQuery("#gawd_chart_type_post_page").val(chartType);
|
60 |
+
jQuery("#gawd_post_page_popup_date").val(start_date);
|
61 |
+
jQuery( "#loading_div" ).show();
|
62 |
+
jQuery( "#opacity_div" ).show();
|
63 |
+
jQuery('#gawd_post_page_popup').height('400');
|
64 |
+
jQuery('#gawd_metric_post_page_popup, #gawd_post_page_popup_date, #gawd_chart_type_post_page').on('change',function(){
|
65 |
+
gawd_chart_type_post_page_front(uri,'gawd_post_page_popup');
|
66 |
+
})
|
67 |
+
}
|
68 |
+
var dates = start_date.split('/-/');
|
69 |
+
|
70 |
+
jQuery("#gawd_post_page_meta").empty();
|
71 |
+
jQuery('#gawd_post_page_meta').height('300');
|
72 |
+
jQuery.post(gawd_front.ajaxurl, {
|
73 |
+
action: 'show_page_post_data',
|
74 |
+
metric: metric,
|
75 |
+
start_date: dates[0],
|
76 |
+
end_date: dates[1],
|
77 |
+
dimension: dimension,
|
78 |
+
timezone: timezone,
|
79 |
+
chart: 'pie',
|
80 |
+
security: gawd_front.ajaxnonce,
|
81 |
+
filter: uri,
|
82 |
+
}).done(function (data) {
|
83 |
+
jQuery(".opacity_div_compact").hide();
|
84 |
+
jQuery(".loading_div_compact").hide();
|
85 |
+
if(divID == 'gawd_post_page_popup'){
|
86 |
+
jQuery( "#loading_div" ).remove();
|
87 |
+
jQuery( ".gawd_btn" ).show();
|
88 |
+
jQuery('#opacity_div, .gawd_btn').on('click', function(){
|
89 |
+
jQuery('#opacity_div').remove();
|
90 |
+
jQuery( ".gawd_btn" ).remove();
|
91 |
+
jQuery( ".page_chart_div" ).remove();
|
92 |
+
jQuery( "#loading_div" ).remove();
|
93 |
+
})
|
94 |
+
}
|
95 |
+
var result = JSON.parse(data);
|
96 |
+
result = result.chart_data
|
97 |
+
var diff = ((Date.parse(dates[1]).getTime() - Date.parse(dates[0]).getTime()) / 3600 / 24 / 1000)+1;
|
98 |
+
if(diff > 8){
|
99 |
+
dimension = 'Week';
|
100 |
+
metric = metric.replace(/([A-Z])/g, " $1").trim();
|
101 |
+
metric = metric.charAt(0).toUpperCase() + metric.slice(1);
|
102 |
+
metric = metric.replace(/ +/g, ' ');
|
103 |
+
}
|
104 |
+
var chart = AmCharts.makeChart( divID, {
|
105 |
+
"type": "pie",
|
106 |
+
"theme": "light",
|
107 |
+
'sequencedAnimation': false,
|
108 |
+
"dataProvider": result,
|
109 |
+
"valueField": metric,
|
110 |
+
"titleField": dimension,
|
111 |
+
"depth3D": 15,
|
112 |
+
"angle": 30,
|
113 |
+
"minRadius": 70,
|
114 |
+
"startDuration": 0,
|
115 |
+
"percentPrecision": 1,
|
116 |
+
"precision": 0,
|
117 |
+
"balloon":{
|
118 |
+
"fixedPosition":true
|
119 |
+
},
|
120 |
+
'groupPercent': 1,
|
121 |
+
'marginTop': 0,
|
122 |
+
"export": {
|
123 |
+
"enabled": true
|
124 |
+
},
|
125 |
+
"legend": {
|
126 |
+
"enabled": true,
|
127 |
+
"align": "center",
|
128 |
+
"markerType": "circle",
|
129 |
+
},
|
130 |
+
} );
|
131 |
+
jQuery("#"+divID).find('a').remove();
|
132 |
+
//jQuery("#gbox_griddiv").remove();
|
133 |
+
//var grid = '<table id="griddiv"></table><div id="pager"></div>';
|
134 |
+
//jQuery('.gawd_chart_conteiner').append(grid);
|
135 |
+
//gawd_draw_table(result,metric,metric_compare,dimension);
|
136 |
+
})
|
137 |
+
}
|
138 |
+
function post_page_stats_front(uri,divID){
|
139 |
+
if(typeof divID == 'undefined'){
|
140 |
+
divID = 'gawd_post_page_popup';
|
141 |
+
}
|
142 |
+
var chartType = 'line';
|
143 |
+
var fillAlphas = 0;
|
144 |
+
var checked_line = "";
|
145 |
+
var checked_column = "";
|
146 |
+
if(jQuery("#gawd_chart_type_post_page").val() == 'line'){
|
147 |
+
chartType = 'line';
|
148 |
+
var checked = 'selected="selected"';
|
149 |
+
fillAlphas = 0;
|
150 |
+
}
|
151 |
+
else if(jQuery("#gawd_chart_type_post_page").val() == 'column'){
|
152 |
+
chartType = 'column';
|
153 |
+
checked_column = 'selected="selected"';
|
154 |
+
fillAlphas = 1;
|
155 |
+
}
|
156 |
+
var metric = typeof jQuery("#gawd_metric_post_page_popup").val() != 'undefined' ? jQuery("#gawd_metric_post_page_popup").val() : 'sessions';
|
157 |
+
var date_30 = gawd_front.date_30;
|
158 |
+
var date_7 = gawd_front.date_7;
|
159 |
+
var date_yesterday = gawd_front.date_yesterday;
|
160 |
+
var date_today = gawd_front.date_today;
|
161 |
+
var date_this_month = gawd_front.date_this_month;
|
162 |
+
var date_last_month = gawd_front.date_last_month;
|
163 |
+
var date_last_week = gawd_front.date_last_week;
|
164 |
+
|
165 |
+
start_date = typeof jQuery("#gawd_post_page_date").val() != 'undefined' ? jQuery("#gawd_post_page_date").val() : (typeof jQuery("#gawd_post_page_popup_date").val() != 'undefined' ? jQuery("#gawd_post_page_popup_date").val() : date_30);
|
166 |
+
var dimension = 'date';
|
167 |
+
var timezone = -(new Date().getTimezoneOffset()/60);
|
168 |
+
var chart_div = '<div id="opacity_div"></div><div id="loading_div" style="display:none; text-align: center; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999;"><img src="'+gawd_front.gawd_plugin_url+'/assets/ajax_loader.gif" style="margin-top: 200px; width:50px;"></div><div class="page_chart_div"><div style="width:100%; height:100%; position:relative;" class="close_button_cont"><button class="gawd_btn" >X</button>';
|
169 |
+
chart_div += '<select name="gawd_post_page_popup_date" id="gawd_post_page_popup_date" class="gawd_draw_analytics_front">';
|
170 |
+
chart_div += '<option value="'+date_30+'">Last 30 Days</option><option value="'+date_7+'">Last 7 Days</option>';
|
171 |
+
chart_div += '<option value="'+date_last_week+'">Last week</option><option value="'+date_last_month+'">Last month</option>';
|
172 |
+
chart_div += '<option value="'+date_this_month+'">This month</option><option value="'+date_yesterday+'">Yesterday</option>';
|
173 |
+
chart_div += '<option value="'+date_today+'">Today</option>';
|
174 |
+
chart_div += '</select>';
|
175 |
+
chart_div += '<select name="gawd_metric_post_page_popup" id="gawd_metric_post_page_popup" class="gawd_draw_analytics_front">';
|
176 |
+
chart_div += '<option value="sessions" >Sessions</option><option value="users" >Users</option><option value="bounceRate" >Bounce Rate</option><option value="pageviews" >Pageviews</option><option value="percentNewSessions">% New Sessions</option><option value="avgSessionDuration">Avg Session Duration</option><option value="pageviewsPerSession" >Pages/Session</option>';
|
177 |
+
chart_div += '</select>';
|
178 |
+
chart_div += '<select name="gawd_chart_type_post_page" id="gawd_chart_type_post_page" class="gawd_draw_analytics_front">';
|
179 |
+
chart_div += '<option '+checked_line+' value="line">Line Chart</option><option value="pie">Pie Cart</option><option '+checked_column+' value="column">Column Chart</option>';
|
180 |
+
chart_div += '</select>';
|
181 |
+
chart_div += '<div id="gawd_post_page_popup"></div></div></div>';
|
182 |
+
jQuery(".page_chart_div").remove();
|
183 |
+
jQuery('#opacity_div').remove();
|
184 |
+
|
185 |
+
jQuery( "body" ).append(chart_div);
|
186 |
+
jQuery("#gawd_metric_post_page_popup").val(metric)
|
187 |
+
jQuery("#gawd_post_page_popup_date").val(start_date)
|
188 |
+
jQuery( "#loading_div" ).show();
|
189 |
+
jQuery( "#opacity_div" ).show();
|
190 |
+
jQuery('#gawd_post_page_popup').height('400');
|
191 |
+
jQuery('#gawd_metric_post_page_popup, #gawd_post_page_popup_date, #gawd_chart_type_post_page').on('change',function(){
|
192 |
+
gawd_chart_type_post_page_front(uri,'gawd_post_page_popup');
|
193 |
+
})
|
194 |
+
jQuery("#gawd_post_page_meta").empty();
|
195 |
+
jQuery('#gawd_post_page_meta').height('300');
|
196 |
+
var dates = start_date.split('/-/');
|
197 |
+
jQuery.post(gawd_front.ajaxurl, {
|
198 |
+
action: 'show_page_post_data',
|
199 |
+
metric: metric,
|
200 |
+
start_date: dates[0],
|
201 |
+
end_date: dates[1],
|
202 |
+
dimension: dimension,
|
203 |
+
timezone: timezone,
|
204 |
+
chart: 'line',
|
205 |
+
security: gawd_front.ajaxnonce,
|
206 |
+
filter: uri,
|
207 |
+
|
208 |
+
}).done(function (data) {
|
209 |
+
var data = JSON.parse(data);
|
210 |
+
data = data.chart_data;
|
211 |
+
if(divID == 'gawd_post_page_popup'){
|
212 |
+
jQuery( "#loading_div" ).remove();
|
213 |
+
jQuery( ".gawd_btn" ).show();
|
214 |
+
jQuery('#opacity_div, .gawd_btn').on('click', function(){
|
215 |
+
jQuery('#opacity_div').remove();
|
216 |
+
jQuery( ".gawd_btn" ).remove();
|
217 |
+
jQuery( ".page_chart_div" ).remove();
|
218 |
+
jQuery( "#loading_div" ).remove();
|
219 |
+
})
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
var chart = AmCharts.makeChart(divID, {
|
224 |
+
"dataProvider": data,
|
225 |
+
"type": "serial",
|
226 |
+
"theme": "light",
|
227 |
+
"percentPrecision": 1,
|
228 |
+
"precision": 0,
|
229 |
+
"export": {
|
230 |
+
"enabled": true
|
231 |
+
},
|
232 |
+
"dataDateFormat": "YYYY-MM-DD",
|
233 |
+
"valueAxes": [{
|
234 |
+
"id": "g1",
|
235 |
+
"axisAlpha": 0.4,
|
236 |
+
"position": "left",
|
237 |
+
"title": metric,
|
238 |
+
"ignoreAxisWidth":false
|
239 |
+
|
240 |
+
}],
|
241 |
+
"chartCursor": {
|
242 |
+
"pan": true,
|
243 |
+
"valueLineEnabled": true,
|
244 |
+
"valueLineBalloonEnabled": true,
|
245 |
+
"cursorAlpha": 1,
|
246 |
+
"cursorColor": "#258cbb",
|
247 |
+
"limitToGraph": "g1",
|
248 |
+
"valueLineAlpha": 0.2
|
249 |
+
},
|
250 |
+
"graphs": [{
|
251 |
+
"type": chartType,
|
252 |
+
"valueAxis": "g1",
|
253 |
+
"fillAlphas": fillAlphas,
|
254 |
+
"bullet": "round",
|
255 |
+
"bulletBorderAlpha": 1,
|
256 |
+
"bulletColor": "#FFFFFF",
|
257 |
+
"bulletSize": 5,
|
258 |
+
//"hideBulletsCount": 50,
|
259 |
+
"lineThickness": 2,
|
260 |
+
"title": metric,
|
261 |
+
"useLineColorForBulletBorder": true,
|
262 |
+
"valueField": metric,
|
263 |
+
}],
|
264 |
+
"categoryField": dimension,
|
265 |
+
"categoryAxis": {
|
266 |
+
"parseDates": true,
|
267 |
+
"equalSpacing": true,
|
268 |
+
"dashLength": 2,
|
269 |
+
"minorGridEnabled": true,
|
270 |
+
"boldLabels": true,
|
271 |
+
"labelFrequency": 1,
|
272 |
+
}
|
273 |
+
} )
|
274 |
+
jQuery("#"+divID).find('a').remove();
|
275 |
+
})
|
276 |
+
}
|
include/gawd-notices-class.php
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (!defined('ABSPATH')) {
|
3 |
+
exit;
|
4 |
+
}
|
5 |
+
|
6 |
+
class GAWD_Notices {
|
7 |
+
protected $prefix = 'gawd';
|
8 |
+
protected $plugin_url = GAWD_URL;
|
9 |
+
protected $plugin_version = "gawd_version";
|
10 |
+
protected $plugin_name = 'WD Google Analytics';
|
11 |
+
protected $promo_link = '';
|
12 |
+
|
13 |
+
public $notice_spam = 0;
|
14 |
+
public $notice_spam_max = 1;
|
15 |
+
|
16 |
+
// Basic actions to run
|
17 |
+
public function __construct() {
|
18 |
+
|
19 |
+
// Runs the admin notice ignore function incase a dismiss button has been clicked
|
20 |
+
add_action('admin_init', array($this, 'admin_notice_ignore'));
|
21 |
+
// Runs the admin notice temp ignore function incase a temp dismiss link has been clicked
|
22 |
+
add_action('admin_init', array($this, 'admin_notice_temp_ignore'));
|
23 |
+
add_action('admin_notices', array($this, 'wd_admin_notices'));
|
24 |
+
}
|
25 |
+
|
26 |
+
// Checks to ensure notices aren't disabled and the user has the correct permissions.
|
27 |
+
public function wd_admin_notice() {
|
28 |
+
$settings = get_option($this->prefix . '_admin_notice');
|
29 |
+
if (!isset($settings['disable_admin_notices']) || (isset($settings['disable_admin_notices']) && $settings['disable_admin_notices'] == 0)) {
|
30 |
+
if (current_user_can('manage_options')) {
|
31 |
+
return true;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
|
37 |
+
// Primary notice function that can be called from an outside function sending necessary variables
|
38 |
+
public function admin_notice($admin_notices) {
|
39 |
+
|
40 |
+
// Check options
|
41 |
+
if (!$this->wd_admin_notice()) {
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
|
45 |
+
foreach ($admin_notices as $slug => $admin_notice) {
|
46 |
+
// Call for spam protection
|
47 |
+
if ($this->anti_notice_spam()) {
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
// Check for proper page to display on
|
52 |
+
if (isset( $admin_notices[$slug]['pages']) && is_array( $admin_notices[$slug]['pages'])) {
|
53 |
+
if (!$this->admin_notice_pages($admin_notices[$slug]['pages'])) {
|
54 |
+
return false;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
// Check for required fields
|
59 |
+
if (!$this->required_fields($admin_notices[$slug])) {
|
60 |
+
|
61 |
+
// Get the current date then set start date to either passed value or current date value and add interval
|
62 |
+
$current_date = current_time("n/j/Y");
|
63 |
+
$start = (isset($admin_notices[$slug]['start']) ? $admin_notices[$slug]['start'] : $current_date);
|
64 |
+
$start = date("n/j/Y", strtotime($start));
|
65 |
+
$date_array = explode('/', $start);
|
66 |
+
$interval = (isset($admin_notices[$slug]['int']) ? $admin_notices[$slug]['int'] : 0);
|
67 |
+
|
68 |
+
$date_array[1] += $interval;
|
69 |
+
$start = date("n/j/Y", mktime(0, 0, 0, $date_array[0], $date_array[1], $date_array[2]));
|
70 |
+
|
71 |
+
// This is the main notices storage option
|
72 |
+
$admin_notices_option = get_option($this->prefix . '_admin_notice', array());
|
73 |
+
// Check if the message is already stored and if so just grab the key otherwise store the message and its associated date information
|
74 |
+
if (!array_key_exists( $slug, $admin_notices_option)) {
|
75 |
+
$admin_notices_option[$slug]['start'] = $start;
|
76 |
+
$admin_notices_option[$slug]['int'] = $interval;
|
77 |
+
update_option($this->prefix . '_admin_notice', $admin_notices_option);
|
78 |
+
}
|
79 |
+
|
80 |
+
// Sanity check to ensure we have accurate information
|
81 |
+
// New date information will not overwrite old date information
|
82 |
+
$admin_display_check = (isset($admin_notices_option[$slug]['dismissed']) ? $admin_notices_option[$slug]['dismissed'] : 0);
|
83 |
+
$admin_display_start = (isset($admin_notices_option[$slug]['start']) ? $admin_notices_option[$slug]['start'] : $start);
|
84 |
+
$admin_display_interval = (isset($admin_notices_option[$slug]['int']) ? $admin_notices_option[$slug]['int'] : $interval);
|
85 |
+
$admin_display_msg = (isset($admin_notices[$slug]['msg']) ? $admin_notices[$slug]['msg'] : '');
|
86 |
+
$admin_display_title = (isset($admin_notices[$slug]['title']) ? $admin_notices[$slug]['title'] : '');
|
87 |
+
$admin_display_link = (isset($admin_notices[$slug]['link']) ? $admin_notices[$slug]['link'] : '');
|
88 |
+
$output_css = false;
|
89 |
+
|
90 |
+
// Ensure the notice hasn't been hidden and that the current date is after the start date
|
91 |
+
if ($admin_display_check == 0 && strtotime($admin_display_start) <= strtotime($current_date)) {
|
92 |
+
|
93 |
+
// Get remaining query string
|
94 |
+
$query_str = (isset($admin_notices[$slug]['later_link']) ? $admin_notices[$slug]['later_link'] : esc_url(add_query_arg($this->prefix . '_admin_notice_ignore', $slug)));
|
95 |
+
if (strpos($slug, 'promo') === FALSE) {
|
96 |
+
// Admin notice display output
|
97 |
+
echo '<div class="update-nag wd-admin-notice">
|
98 |
+
<div class="' . $this->prefix . '-notice-logo"></div>
|
99 |
+
<p class="wd-notice-title">' . $admin_display_title . '</p>
|
100 |
+
<p class="wd-notice-body">' . $admin_display_msg . '</p>
|
101 |
+
<ul class="wd-notice-body wd-blue">' . $admin_display_link . '</ul>
|
102 |
+
<a href="' . $query_str . '" class="dashicons dashicons-dismiss"></a>
|
103 |
+
</div>';
|
104 |
+
}
|
105 |
+
else {
|
106 |
+
echo '<div class="admin-notice-promo">';
|
107 |
+
echo $admin_display_msg;
|
108 |
+
echo '<ul class="notice-body-promo blue">
|
109 |
+
' . $admin_display_link . '
|
110 |
+
</ul>';
|
111 |
+
echo '<a href="' . $query_str . '" class="dashicons dashicons-dismiss close-promo"></a>';
|
112 |
+
echo '</div>';
|
113 |
+
}
|
114 |
+
$this->notice_spam += 1;
|
115 |
+
$output_css = true;
|
116 |
+
}
|
117 |
+
if ($output_css) {
|
118 |
+
wp_enqueue_style('gawd-admin-notices', GAWD_URL . '/inc/css/notices.css', array(), GAWD_VERSION);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
// Spam protection check
|
125 |
+
public function anti_notice_spam() {
|
126 |
+
if ($this->notice_spam >= $this->notice_spam_max) {
|
127 |
+
return true;
|
128 |
+
}
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
|
132 |
+
// Ignore function that gets ran at admin init to ensure any messages that were dismissed get marked
|
133 |
+
public function admin_notice_ignore() {
|
134 |
+
// If user clicks to ignore the notice, update the option to not show it again
|
135 |
+
if (isset($_GET[$this->prefix . '_admin_notice_ignore'])) {
|
136 |
+
$admin_notices_option = get_option($this->prefix . '_admin_notice', array());
|
137 |
+
$admin_notices_option[$_GET[$this->prefix . '_admin_notice_ignore']]['dismissed'] = 1;
|
138 |
+
update_option($this->prefix . '_admin_notice', $admin_notices_option);
|
139 |
+
$query_str = remove_query_arg($this->prefix . '_admin_notice_ignore');
|
140 |
+
wp_redirect($query_str);
|
141 |
+
exit;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
// Temp Ignore function that gets ran at admin init to ensure any messages that were temp dismissed get their start date changed
|
146 |
+
public function admin_notice_temp_ignore() {
|
147 |
+
// If user clicks to temp ignore the notice, update the option to change the start date - default interval of 14 days
|
148 |
+
if (isset($_GET[$this->prefix . '_admin_notice_temp_ignore'])) {
|
149 |
+
$admin_notices_option = get_option($this->prefix . '_admin_notice', array());
|
150 |
+
$current_date = current_time("n/j/Y");
|
151 |
+
$date_array = explode('/', $current_date);
|
152 |
+
$interval = (isset($_GET['wd_int']) ? $_GET['wd_int'] : 14);
|
153 |
+
$date_array[1] += $interval;
|
154 |
+
$new_start = date("n/j/Y", mktime(0, 0, 0, $date_array[0], $date_array[1], $date_array[2]));
|
155 |
+
|
156 |
+
$admin_notices_option[$_GET[$this->prefix . '_admin_notice_temp_ignore']]['start'] = $new_start;
|
157 |
+
$admin_notices_option[$_GET[$this->prefix . '_admin_notice_temp_ignore']]['dismissed'] = 0;
|
158 |
+
update_option($this->prefix . '_admin_notice', $admin_notices_option);
|
159 |
+
$query_str = remove_query_arg(array($this->prefix . '_admin_notice_temp_ignore', 'wd_int'));
|
160 |
+
wp_redirect( $query_str );
|
161 |
+
exit;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
public function admin_notice_pages($pages) {
|
166 |
+
foreach ($pages as $key => $page) {
|
167 |
+
if (is_array($page)) {
|
168 |
+
if (isset($_GET['page']) && $_GET['page'] == $page[0] && isset($_GET['tab']) && $_GET['tab'] == $page[1]) {
|
169 |
+
return true;
|
170 |
+
}
|
171 |
+
}
|
172 |
+
else {
|
173 |
+
if ($page == 'all') {
|
174 |
+
return true;
|
175 |
+
}
|
176 |
+
if (get_current_screen()->id === $page) {
|
177 |
+
return true;
|
178 |
+
}
|
179 |
+
if (isset($_GET['page']) && $_GET['page'] == $page) {
|
180 |
+
return true;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
return false;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
// Required fields check
|
188 |
+
public function required_fields( $fields ) {
|
189 |
+
if (!isset( $fields['msg']) || (isset($fields['msg']) && empty($fields['msg']))) {
|
190 |
+
return true;
|
191 |
+
}
|
192 |
+
if (!isset( $fields['title']) || (isset($fields['title']) && empty($fields['title']))) {
|
193 |
+
return true;
|
194 |
+
}
|
195 |
+
return false;
|
196 |
+
}
|
197 |
+
|
198 |
+
// Special parameters function that is to be used in any extension of this class
|
199 |
+
public function special_parameters($admin_notices) {
|
200 |
+
// Intentionally left blank
|
201 |
+
}
|
202 |
+
|
203 |
+
function wd_admin_notices( $notices ) {
|
204 |
+
$two_week_review_ignore = add_query_arg( array( 'gawd_admin_notice_ignore' => 'two_week_review' ) );
|
205 |
+
$two_week_review_temp = add_query_arg( array( 'gawd_admin_notice_temp_ignore' => 'two_week_review', 'int' => 14 ) );
|
206 |
+
$notices['two_week_review'] = array(
|
207 |
+
'title' => __( 'Leave A Review?', 'gawd' ),
|
208 |
+
'msg' => __( 'We hope you\'ve enjoyed using WD Google Analytics! Would you consider leaving us a review on WordPress.org?', 'gawd' ),
|
209 |
+
'link' => '<li><span class="dashicons dashicons-external"></span><a href="https://wordpress.org/support/view/plugin-reviews/wd-google-analytics?filter=5" target="_blank">' . __( 'Sure! I\'d love to!', 'gawd' ) . '</a></li>
|
210 |
+
<li> <span class="dashicons dashicons-smiley"></span><a href="' . $two_week_review_ignore . '"> ' . __( 'I\'ve already left a review', 'gawd' ) . '</a></li>
|
211 |
+
<li><span class="dashicons dashicons-calendar-alt"></span><a href="' . $two_week_review_temp . '">' . __( 'Maybe Later' ,'gawd' ) . '</a></li>
|
212 |
+
<li><span class="dashicons dashicons-dismiss"></span><a href="' . $two_week_review_ignore . '">' . __( 'Never show again' ,'gawd' ) . '</a></li>',
|
213 |
+
|
214 |
+
'later_link'=>$two_week_review_temp,
|
215 |
+
'int' => 14
|
216 |
+
);
|
217 |
+
|
218 |
+
$one_week_support = add_query_arg( array( 'gawd_admin_notice_ignore' => 'one_week_support' ) );
|
219 |
+
$notices['one_week_support'] = array(
|
220 |
+
'title' => __( 'Hey! How\'s It Going?', 'gawd' ),
|
221 |
+
'msg' => __( 'Thank you for using WD Google Analytics! We hope that you\'ve found everything you need, but if you have any questions:', 'gawd' ),
|
222 |
+
'link' => '<li><span class="dashicons dashicons-media-text"></span><a target="_blank" href="https://web-dorado.com/wordpress-google-analytics/installation.html">' . __( 'Check out User Guide', 'gawd' ) . '</a></li>
|
223 |
+
<li><span class="dashicons dashicons-sos"></span><a target="_blank" href="https://web-dorado.com/forum/google-analytics-wd.html">' . __( 'Get Some Help' ,'gawd' ) . '</a></li>
|
224 |
+
<li><span class="dashicons dashicons-dismiss"></span><a href="' . $one_week_support . '">' . __( 'Never show again' ,'gawd' ) . '</a></li>',
|
225 |
+
'int' => 7
|
226 |
+
);
|
227 |
+
|
228 |
+
$this->admin_notice($notices);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
new GAWD_Notices();
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://web-dorado.com/products/wordpress-google-analytics-plugin.h
|
|
4 |
Tags: google analytics dashboard, google analytics, statistics, tracking, analytics, analytics dashboard, stats, ga, universal analytics, ecommerce tracking, custom dimensions, custom reports
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.6
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -98,6 +98,12 @@ Upgrade to Google Analytics WD Pro for premium features:
|
|
98 |
|
99 |
== Changelog ==
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
= 1.0.5 =
|
102 |
Fixed: PHP version conflict
|
103 |
Added: Pro flags about additional functionality available in Pro version
|
4 |
Tags: google analytics dashboard, google analytics, statistics, tracking, analytics, analytics dashboard, stats, ga, universal analytics, ecommerce tracking, custom dimensions, custom reports
|
5 |
Requires at least: 3.9
|
6 |
Tested up to: 4.6
|
7 |
+
Stable tag: 1.0.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
98 |
|
99 |
== Changelog ==
|
100 |
|
101 |
+
= 1.0.6 =
|
102 |
+
Fixed: User guide links
|
103 |
+
Fixed: Bug on datepicker
|
104 |
+
Fixed: Error when deleting the web property
|
105 |
+
Added: Validation on the form for adding goals
|
106 |
+
|
107 |
= 1.0.5 =
|
108 |
Fixed: PHP version conflict
|
109 |
Added: Pro flags about additional functionality available in Pro version
|