api-keys.js
5 years ago
api-keys.min.js
2 years ago
backbone-modal.js
2 years ago
backbone-modal.min.js
2 years ago
marketplace-suggestions.js
10 months ago
marketplace-suggestions.min.js
10 months ago
meta-boxes-coupon.js
1 year ago
meta-boxes-coupon.min.js
1 year ago
meta-boxes-order.js
1 month ago
meta-boxes-order.min.js
1 month ago
meta-boxes-product-variation.js
1 year ago
meta-boxes-product-variation.min.js
1 year ago
meta-boxes-product.js
1 month ago
meta-boxes-product.min.js
1 month ago
meta-boxes.js
4 months ago
meta-boxes.min.js
4 months ago
network-orders.js
8 years ago
network-orders.min.js
2 years ago
order-attribution-admin.js
2 years ago
order-attribution-admin.min.js
2 years ago
product-editor.js
11 months ago
product-editor.min.js
11 months ago
product-ordering.js
3 months ago
product-ordering.min.js
3 months ago
quick-edit.js
1 year ago
quick-edit.min.js
1 year ago
reports.js
1 year ago
reports.min.js
1 year ago
settings-views-html-settings-tax.js
1 year ago
settings-views-html-settings-tax.min.js
1 year ago
settings.js
1 year ago
settings.min.js
1 year ago
system-status.js
3 months ago
system-status.min.js
3 months ago
term-ordering.js
3 months ago
term-ordering.min.js
3 months ago
users.js
5 years ago
users.min.js
2 years ago
variation-gallery.js
1 month ago
variation-gallery.min.js
1 month ago
wc-brands-enhanced-select.js
1 year ago
wc-brands-enhanced-select.min.js
1 year ago
wc-clipboard.js
5 years ago
wc-clipboard.min.js
5 years ago
wc-customer-stock-notifications.js
10 months ago
wc-customer-stock-notifications.min.js
10 months ago
wc-enhanced-select.js
2 years ago
wc-enhanced-select.min.js
2 years ago
wc-orders.js
3 years ago
wc-orders.min.js
2 years ago
wc-product-export.js
1 year ago
wc-product-export.min.js
1 year ago
wc-product-import.js
3 years ago
wc-product-import.min.js
2 years ago
wc-recent-reviews-widget-async.js
4 months ago
wc-recent-reviews-widget-async.min.js
4 months ago
wc-setup.js
5 years ago
wc-setup.min.js
2 years ago
wc-shipping-classes.js
1 year ago
wc-shipping-classes.min.js
1 year ago
wc-shipping-providers.js
3 months ago
wc-shipping-providers.min.js
3 months ago
wc-shipping-zone-methods.js
5 months ago
wc-shipping-zone-methods.min.js
5 months ago
wc-shipping-zones.js
1 year ago
wc-shipping-zones.min.js
1 year ago
wc-status-widget-async.js
4 months ago
wc-status-widget-async.min.js
4 months ago
wc-status-widget.js
1 year ago
wc-status-widget.min.js
1 year ago
woocommerce_admin.js
1 month ago
woocommerce_admin.min.js
1 month ago
reports.js
204 lines
| 1 | jQuery(function( $ ) { |
| 2 | |
| 3 | function showTooltip( x, y, contents ) { |
| 4 | $( '<div class="chart-tooltip">' + contents + '</div>' ).css( { |
| 5 | top: y - 16, |
| 6 | left: x + 20 |
| 7 | }).appendTo( 'body' ).fadeIn( 200 ); |
| 8 | } |
| 9 | |
| 10 | var prev_data_index = null; |
| 11 | var prev_series_index = null; |
| 12 | |
| 13 | $( '.chart-placeholder' ).on( 'plothover', function ( event, pos, item ) { |
| 14 | if ( item ) { |
| 15 | if ( prev_data_index !== item.dataIndex || prev_series_index !== item.seriesIndex ) { |
| 16 | prev_data_index = item.dataIndex; |
| 17 | prev_series_index = item.seriesIndex; |
| 18 | |
| 19 | $( '.chart-tooltip' ).remove(); |
| 20 | |
| 21 | if ( item.series.points.show || item.series.enable_tooltip ) { |
| 22 | |
| 23 | var y = item.series.data[item.dataIndex][1], |
| 24 | tooltip_content = ''; |
| 25 | |
| 26 | if ( item.series.prepend_label ) { |
| 27 | tooltip_content = tooltip_content + item.series.label + ': '; |
| 28 | } |
| 29 | |
| 30 | if ( item.series.prepend_tooltip ) { |
| 31 | tooltip_content = tooltip_content + item.series.prepend_tooltip; |
| 32 | } |
| 33 | |
| 34 | tooltip_content = tooltip_content + y; |
| 35 | |
| 36 | if ( item.series.append_tooltip ) { |
| 37 | tooltip_content = tooltip_content + item.series.append_tooltip; |
| 38 | } |
| 39 | |
| 40 | if ( item.series.pie.show ) { |
| 41 | showTooltip( pos.pageX, pos.pageY, tooltip_content ); |
| 42 | } else { |
| 43 | showTooltip( item.pageX, item.pageY, tooltip_content ); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | } else { |
| 48 | $( '.chart-tooltip' ).remove(); |
| 49 | prev_data_index = null; |
| 50 | } |
| 51 | }); |
| 52 | |
| 53 | var dates = $( '.range_datepicker' ).datepicker({ |
| 54 | changeMonth: true, |
| 55 | changeYear: true, |
| 56 | defaultDate: '', |
| 57 | dateFormat: 'yy-mm-dd', |
| 58 | numberOfMonths: 1, |
| 59 | minDate: '-20Y', |
| 60 | maxDate: '+1D', |
| 61 | showButtonPanel: true, |
| 62 | showOn: 'focus', |
| 63 | buttonImageOnly: true, |
| 64 | onSelect: function() { |
| 65 | var option = $( this ).is( '.from' ) ? 'minDate' : 'maxDate', |
| 66 | date = $( this ).datepicker( 'getDate' ); |
| 67 | |
| 68 | dates.not( this ).datepicker( 'option', option, date ); |
| 69 | } |
| 70 | }); |
| 71 | |
| 72 | var a = document.createElement( 'a' ); |
| 73 | |
| 74 | if ( typeof a.download === 'undefined' ) { |
| 75 | $( '.export_csv' ).hide(); |
| 76 | } |
| 77 | |
| 78 | // Export |
| 79 | $( '.export_csv' ).on( 'click', function() { |
| 80 | var exclude_series = $( this ).data( 'exclude_series' ) || ''; |
| 81 | exclude_series = exclude_series.toString(); |
| 82 | exclude_series = exclude_series.split( ',' ); |
| 83 | var xaxes_label = $( this ).data( 'xaxes' ); |
| 84 | var groupby = $( this ) .data( 'groupby' ); |
| 85 | var index_type = $( this ).data( 'index_type' ); |
| 86 | var export_format = $( this ).data( 'export' ); |
| 87 | var csv_data = ''; |
| 88 | var s, series_data, d; |
| 89 | |
| 90 | if ( 'table' === export_format ) { |
| 91 | |
| 92 | $( this ).offsetParent().find( 'thead tr,tbody tr' ).each( function() { |
| 93 | $( this ).find( 'th, td' ).each( function() { |
| 94 | var value = $( this ).text(); |
| 95 | value = value.replace( '[?]', '' ).replace( '#', '' ); |
| 96 | csv_data += '"' + value + '"' + ','; |
| 97 | }); |
| 98 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 99 | csv_data += '\n'; |
| 100 | }); |
| 101 | |
| 102 | $( this ).offsetParent().find( 'tfoot tr' ).each( function() { |
| 103 | $( this ).find( 'th, td' ).each( function() { |
| 104 | var value = $( this ).text(); |
| 105 | value = value.replace( '[?]', '' ).replace( '#', '' ); |
| 106 | csv_data += '"' + value + '"' + ','; |
| 107 | if ( $( this ).attr( 'colspan' ) > 0 ) { |
| 108 | for ( i = 1; i < $(this).attr('colspan'); i++ ) { |
| 109 | csv_data += '"",'; |
| 110 | } |
| 111 | } |
| 112 | }); |
| 113 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 114 | csv_data += '\n'; |
| 115 | }); |
| 116 | |
| 117 | } else { |
| 118 | |
| 119 | if ( ! window.main_chart ) { |
| 120 | return false; |
| 121 | } |
| 122 | |
| 123 | var the_series = window.main_chart.getData(); |
| 124 | var series = []; |
| 125 | csv_data += '"' + xaxes_label + '",'; |
| 126 | |
| 127 | $.each( the_series, function( index, value ) { |
| 128 | if ( ! exclude_series || $.inArray( index.toString(), exclude_series ) === -1 ) { |
| 129 | series.push( value ); |
| 130 | } |
| 131 | }); |
| 132 | |
| 133 | // CSV Headers |
| 134 | for ( s = 0; s < series.length; ++s ) { |
| 135 | csv_data += '"' + series[s].label + '",'; |
| 136 | } |
| 137 | |
| 138 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 139 | csv_data += '\n'; |
| 140 | |
| 141 | // Get x axis values |
| 142 | var xaxis = {}; |
| 143 | |
| 144 | for ( s = 0; s < series.length; ++s ) { |
| 145 | series_data = series[s].data; |
| 146 | for ( d = 0; d < series_data.length; ++d ) { |
| 147 | xaxis[series_data[d][0]] = []; |
| 148 | // Zero values to start |
| 149 | for ( var i = 0; i < series.length; ++i ) { |
| 150 | xaxis[series_data[d][0]].push(0); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // Add chart data |
| 156 | for ( s = 0; s < series.length; ++s ) { |
| 157 | series_data = series[s].data; |
| 158 | for ( d = 0; d < series_data.length; ++d ) { |
| 159 | xaxis[series_data[d][0]][s] = series_data[d][1]; |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // Loop data and output to csv string |
| 164 | $.each( xaxis, function( index, value ) { |
| 165 | var date = new Date( parseInt( index, 10 ) ); |
| 166 | |
| 167 | if ( 'none' === index_type ) { |
| 168 | csv_data += '"' + index + '",'; |
| 169 | } else { |
| 170 | if ( groupby === 'day' ) { |
| 171 | csv_data += '"' + |
| 172 | date.getUTCFullYear() + |
| 173 | '-' + |
| 174 | parseInt( date.getUTCMonth() + 1, 10 ) + |
| 175 | '-' + |
| 176 | date.getUTCDate() + |
| 177 | '",'; |
| 178 | } else { |
| 179 | csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",'; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | for ( var d = 0; d < value.length; ++d ) { |
| 184 | var val = value[d]; |
| 185 | |
| 186 | if ( Math.round( val ) !== val ) { |
| 187 | val = parseFloat( val ); |
| 188 | val = val.toFixed( 2 ); |
| 189 | } |
| 190 | |
| 191 | csv_data += '"' + val + '",'; |
| 192 | } |
| 193 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 194 | csv_data += '\n'; |
| 195 | } ); |
| 196 | } |
| 197 | |
| 198 | csv_data = 'data:text/csv;charset=utf-8,\uFEFF' + encodeURIComponent( csv_data ); |
| 199 | // Set data as href and return |
| 200 | $( this ).attr( 'href', csv_data ); |
| 201 | return true; |
| 202 | }); |
| 203 | }); |
| 204 |