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
4 years ago
marketplace-suggestions.min.js
2 years ago
meta-boxes-coupon.js
5 years ago
meta-boxes-coupon.min.js
2 years ago
meta-boxes-order.js
2 years ago
meta-boxes-order.min.js
2 years ago
meta-boxes-product-variation.js
2 years ago
meta-boxes-product-variation.min.js
2 years ago
meta-boxes-product.js
2 years ago
meta-boxes-product.min.js
2 years ago
meta-boxes.js
2 years ago
meta-boxes.min.js
2 years 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
3 years ago
product-editor.min.js
2 years ago
product-ordering.js
3 years ago
product-ordering.min.js
2 years ago
quick-edit.js
4 years ago
quick-edit.min.js
2 years ago
reports.js
5 years ago
reports.min.js
2 years ago
settings-views-html-settings-tax.js
3 years ago
settings-views-html-settings-tax.min.js
2 years ago
settings.js
4 years ago
settings.min.js
2 years ago
system-status.js
3 years ago
system-status.min.js
2 years ago
term-ordering.js
3 years ago
term-ordering.min.js
2 years ago
users.js
5 years ago
users.min.js
2 years ago
wc-clipboard.js
5 years ago
wc-clipboard.min.js
5 years 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
5 years ago
wc-product-export.min.js
2 years ago
wc-product-import.js
3 years ago
wc-product-import.min.js
2 years ago
wc-setup.js
5 years ago
wc-setup.min.js
2 years ago
wc-shipping-classes.js
2 years ago
wc-shipping-classes.min.js
2 years ago
wc-shipping-zone-methods.js
2 years ago
wc-shipping-zone-methods.min.js
2 years ago
wc-shipping-zones.js
2 years ago
wc-shipping-zones.min.js
2 years ago
wc-status-widget.js
2 years ago
wc-status-widget.min.js
2 years ago
woocommerce_admin.js
2 years ago
woocommerce_admin.min.js
2 years ago
reports.js
258 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 | $( '.wc_sparkline.bars' ).each( function() { |
| 54 | var chart_data = $( this ).data( 'sparkline' ); |
| 55 | |
| 56 | var options = { |
| 57 | grid: { |
| 58 | show: false |
| 59 | } |
| 60 | }; |
| 61 | |
| 62 | // main series |
| 63 | var series = [{ |
| 64 | data: chart_data, |
| 65 | color: $( this ).data( 'color' ), |
| 66 | bars: { |
| 67 | fillColor: $( this ).data( 'color' ), |
| 68 | fill: true, |
| 69 | show: true, |
| 70 | lineWidth: 1, |
| 71 | barWidth: $( this ).data( 'barwidth' ), |
| 72 | align: 'center' |
| 73 | }, |
| 74 | shadowSize: 0 |
| 75 | }]; |
| 76 | |
| 77 | // draw the sparkline |
| 78 | $.plot( $( this ), series, options ); |
| 79 | }); |
| 80 | |
| 81 | $( '.wc_sparkline.lines' ).each( function() { |
| 82 | var chart_data = $( this ).data( 'sparkline' ); |
| 83 | |
| 84 | var options = { |
| 85 | grid: { |
| 86 | show: false |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | // main series |
| 91 | var series = [{ |
| 92 | data: chart_data, |
| 93 | color: $( this ).data( 'color' ), |
| 94 | lines: { |
| 95 | fill: false, |
| 96 | show: true, |
| 97 | lineWidth: 1, |
| 98 | align: 'center' |
| 99 | }, |
| 100 | shadowSize: 0 |
| 101 | }]; |
| 102 | |
| 103 | // draw the sparkline |
| 104 | $.plot( $( this ), series, options ); |
| 105 | }); |
| 106 | |
| 107 | var dates = $( '.range_datepicker' ).datepicker({ |
| 108 | changeMonth: true, |
| 109 | changeYear: true, |
| 110 | defaultDate: '', |
| 111 | dateFormat: 'yy-mm-dd', |
| 112 | numberOfMonths: 1, |
| 113 | minDate: '-20Y', |
| 114 | maxDate: '+1D', |
| 115 | showButtonPanel: true, |
| 116 | showOn: 'focus', |
| 117 | buttonImageOnly: true, |
| 118 | onSelect: function() { |
| 119 | var option = $( this ).is( '.from' ) ? 'minDate' : 'maxDate', |
| 120 | date = $( this ).datepicker( 'getDate' ); |
| 121 | |
| 122 | dates.not( this ).datepicker( 'option', option, date ); |
| 123 | } |
| 124 | }); |
| 125 | |
| 126 | var a = document.createElement( 'a' ); |
| 127 | |
| 128 | if ( typeof a.download === 'undefined' ) { |
| 129 | $( '.export_csv' ).hide(); |
| 130 | } |
| 131 | |
| 132 | // Export |
| 133 | $( '.export_csv' ).on( 'click', function() { |
| 134 | var exclude_series = $( this ).data( 'exclude_series' ) || ''; |
| 135 | exclude_series = exclude_series.toString(); |
| 136 | exclude_series = exclude_series.split( ',' ); |
| 137 | var xaxes_label = $( this ).data( 'xaxes' ); |
| 138 | var groupby = $( this ) .data( 'groupby' ); |
| 139 | var index_type = $( this ).data( 'index_type' ); |
| 140 | var export_format = $( this ).data( 'export' ); |
| 141 | var csv_data = ''; |
| 142 | var s, series_data, d; |
| 143 | |
| 144 | if ( 'table' === export_format ) { |
| 145 | |
| 146 | $( this ).offsetParent().find( 'thead tr,tbody tr' ).each( function() { |
| 147 | $( this ).find( 'th, td' ).each( function() { |
| 148 | var value = $( this ).text(); |
| 149 | value = value.replace( '[?]', '' ).replace( '#', '' ); |
| 150 | csv_data += '"' + value + '"' + ','; |
| 151 | }); |
| 152 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 153 | csv_data += '\n'; |
| 154 | }); |
| 155 | |
| 156 | $( this ).offsetParent().find( 'tfoot tr' ).each( function() { |
| 157 | $( this ).find( 'th, td' ).each( function() { |
| 158 | var value = $( this ).text(); |
| 159 | value = value.replace( '[?]', '' ).replace( '#', '' ); |
| 160 | csv_data += '"' + value + '"' + ','; |
| 161 | if ( $( this ).attr( 'colspan' ) > 0 ) { |
| 162 | for ( i = 1; i < $(this).attr('colspan'); i++ ) { |
| 163 | csv_data += '"",'; |
| 164 | } |
| 165 | } |
| 166 | }); |
| 167 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 168 | csv_data += '\n'; |
| 169 | }); |
| 170 | |
| 171 | } else { |
| 172 | |
| 173 | if ( ! window.main_chart ) { |
| 174 | return false; |
| 175 | } |
| 176 | |
| 177 | var the_series = window.main_chart.getData(); |
| 178 | var series = []; |
| 179 | csv_data += '"' + xaxes_label + '",'; |
| 180 | |
| 181 | $.each( the_series, function( index, value ) { |
| 182 | if ( ! exclude_series || $.inArray( index.toString(), exclude_series ) === -1 ) { |
| 183 | series.push( value ); |
| 184 | } |
| 185 | }); |
| 186 | |
| 187 | // CSV Headers |
| 188 | for ( s = 0; s < series.length; ++s ) { |
| 189 | csv_data += '"' + series[s].label + '",'; |
| 190 | } |
| 191 | |
| 192 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 193 | csv_data += '\n'; |
| 194 | |
| 195 | // Get x axis values |
| 196 | var xaxis = {}; |
| 197 | |
| 198 | for ( s = 0; s < series.length; ++s ) { |
| 199 | series_data = series[s].data; |
| 200 | for ( d = 0; d < series_data.length; ++d ) { |
| 201 | xaxis[series_data[d][0]] = []; |
| 202 | // Zero values to start |
| 203 | for ( var i = 0; i < series.length; ++i ) { |
| 204 | xaxis[series_data[d][0]].push(0); |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | // Add chart data |
| 210 | for ( s = 0; s < series.length; ++s ) { |
| 211 | series_data = series[s].data; |
| 212 | for ( d = 0; d < series_data.length; ++d ) { |
| 213 | xaxis[series_data[d][0]][s] = series_data[d][1]; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | // Loop data and output to csv string |
| 218 | $.each( xaxis, function( index, value ) { |
| 219 | var date = new Date( parseInt( index, 10 ) ); |
| 220 | |
| 221 | if ( 'none' === index_type ) { |
| 222 | csv_data += '"' + index + '",'; |
| 223 | } else { |
| 224 | if ( groupby === 'day' ) { |
| 225 | csv_data += '"' + |
| 226 | date.getUTCFullYear() + |
| 227 | '-' + |
| 228 | parseInt( date.getUTCMonth() + 1, 10 ) + |
| 229 | '-' + |
| 230 | date.getUTCDate() + |
| 231 | '",'; |
| 232 | } else { |
| 233 | csv_data += '"' + date.getUTCFullYear() + '-' + parseInt( date.getUTCMonth() + 1, 10 ) + '",'; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | for ( var d = 0; d < value.length; ++d ) { |
| 238 | var val = value[d]; |
| 239 | |
| 240 | if ( Math.round( val ) !== val ) { |
| 241 | val = parseFloat( val ); |
| 242 | val = val.toFixed( 2 ); |
| 243 | } |
| 244 | |
| 245 | csv_data += '"' + val + '",'; |
| 246 | } |
| 247 | csv_data = csv_data.substring( 0, csv_data.length - 1 ); |
| 248 | csv_data += '\n'; |
| 249 | } ); |
| 250 | } |
| 251 | |
| 252 | csv_data = 'data:text/csv;charset=utf-8,\uFEFF' + encodeURIComponent( csv_data ); |
| 253 | // Set data as href and return |
| 254 | $( this ).attr( 'href', csv_data ); |
| 255 | return true; |
| 256 | }); |
| 257 | }); |
| 258 |