api-keys.js
5 years ago
api-keys.min.js
5 years ago
backbone-modal.js
5 years ago
backbone-modal.min.js
5 years ago
marketplace-suggestions.js
4 years ago
marketplace-suggestions.min.js
3 years ago
meta-boxes-coupon.js
5 years ago
meta-boxes-coupon.min.js
3 years ago
meta-boxes-order.js
3 years ago
meta-boxes-order.min.js
3 years ago
meta-boxes-product-variation.js
3 years ago
meta-boxes-product-variation.min.js
3 years ago
meta-boxes-product.js
3 years ago
meta-boxes-product.min.js
3 years ago
meta-boxes.js
3 years ago
meta-boxes.min.js
3 years ago
network-orders.js
8 years ago
network-orders.min.js
3 years ago
product-editor.js
3 years ago
product-editor.min.js
3 years ago
product-ordering.js
3 years ago
product-ordering.min.js
3 years ago
quick-edit.js
4 years ago
quick-edit.min.js
3 years ago
reports.js
5 years ago
reports.min.js
3 years ago
settings-views-html-settings-tax.js
5 years ago
settings-views-html-settings-tax.min.js
3 years ago
settings.js
4 years ago
settings.min.js
3 years ago
system-status.js
3 years ago
system-status.min.js
3 years ago
term-ordering.js
3 years ago
term-ordering.min.js
3 years ago
users.js
5 years ago
users.min.js
3 years ago
wc-clipboard.js
5 years ago
wc-clipboard.min.js
5 years ago
wc-enhanced-select.js
3 years ago
wc-enhanced-select.min.js
3 years ago
wc-orders.js
3 years ago
wc-orders.min.js
3 years ago
wc-product-export.js
5 years ago
wc-product-export.min.js
5 years ago
wc-product-import.js
3 years ago
wc-product-import.min.js
3 years ago
wc-setup.js
5 years ago
wc-setup.min.js
3 years ago
wc-shipping-classes.js
5 years ago
wc-shipping-classes.min.js
3 years ago
wc-shipping-zone-methods.js
4 years ago
wc-shipping-zone-methods.min.js
3 years ago
wc-shipping-zones.js
4 years ago
wc-shipping-zones.min.js
3 years ago
wc-status-widget.js
4 years ago
wc-status-widget.min.js
4 years ago
woocommerce_admin.js
3 years ago
woocommerce_admin.min.js
3 years ago
system-status.js
130 lines
| 1 | /* global jQuery, woocommerce_admin_system_status, wcSetClipboard, wcClearClipboard */ |
| 2 | jQuery( function ( $ ) { |
| 3 | /** |
| 4 | * Users country and state fields |
| 5 | */ |
| 6 | var wcSystemStatus = { |
| 7 | init: function () { |
| 8 | $( document.body ) |
| 9 | .on( |
| 10 | 'click', |
| 11 | 'a.help_tip, a.woocommerce-help-tip, woocommerce-product-type-tip', |
| 12 | this.preventTipTipClick |
| 13 | ) |
| 14 | .on( 'click', 'a.debug-report', this.generateReport ) |
| 15 | .on( 'click', '#copy-for-support', this.copyReport ) |
| 16 | .on( 'aftercopy', '#copy-for-support', this.copySuccess ) |
| 17 | .on( 'aftercopyfailure', '#copy-for-support', this.copyFail ); |
| 18 | }, |
| 19 | |
| 20 | /** |
| 21 | * Prevent anchor behavior when click on TipTip. |
| 22 | * |
| 23 | * @return {Bool} |
| 24 | */ |
| 25 | preventTipTipClick: function() { |
| 26 | return false; |
| 27 | }, |
| 28 | |
| 29 | /** |
| 30 | * Generate system status report. |
| 31 | * |
| 32 | * @return {Bool} |
| 33 | */ |
| 34 | generateReport: function() { |
| 35 | var report = ''; |
| 36 | |
| 37 | $( '.wc_status_table thead, .wc_status_table tbody' ).each( function() { |
| 38 | if ( $( this ).is( 'thead' ) ) { |
| 39 | var label = $( this ).find( 'th:eq(0)' ).data( 'exportLabel' ) || $( this ).text(); |
| 40 | report = report + '\n### ' + label.trim() + ' ###\n\n'; |
| 41 | } else { |
| 42 | $( 'tr', $( this ) ).each( function() { |
| 43 | var label = $( this ).find( 'td:eq(0)' ).data( 'exportLabel' ) || $( this ).find( 'td:eq(0)' ).text(); |
| 44 | var the_name = label.trim().replace( /(<([^>]+)>)/ig, '' ); // Remove HTML. |
| 45 | |
| 46 | // Find value |
| 47 | var $value_html = $( this ).find( 'td:eq(2)' ).clone(); |
| 48 | $value_html.find( '.private' ).remove(); |
| 49 | $value_html.find( '.dashicons-yes' ).replaceWith( '✔' ); |
| 50 | $value_html.find( '.dashicons-no-alt, .dashicons-warning' ).replaceWith( '❌' ); |
| 51 | |
| 52 | // Format value |
| 53 | var the_value = $value_html.text().trim(); |
| 54 | var value_array = the_value.split( ', ' ); |
| 55 | |
| 56 | if ( value_array.length > 1 ) { |
| 57 | // If value have a list of plugins ','. |
| 58 | // Split to add new line. |
| 59 | var temp_line =''; |
| 60 | $.each( value_array, function( key, line ) { |
| 61 | temp_line = temp_line + line + '\n'; |
| 62 | }); |
| 63 | |
| 64 | the_value = temp_line; |
| 65 | } |
| 66 | |
| 67 | report = report + '' + the_name + ': ' + the_value + '\n'; |
| 68 | }); |
| 69 | } |
| 70 | }); |
| 71 | |
| 72 | try { |
| 73 | $( '#debug-report' ).slideDown(); |
| 74 | $( '#debug-report' ).find( 'textarea' ).val( '`' + report + '`' ).trigger( 'focus' ).trigger( 'select' ); |
| 75 | $( this ).fadeOut(); |
| 76 | return false; |
| 77 | } catch ( e ) { |
| 78 | /* jshint devel: true */ |
| 79 | console.log( e ); |
| 80 | } |
| 81 | |
| 82 | return false; |
| 83 | }, |
| 84 | |
| 85 | /** |
| 86 | * Copy for report. |
| 87 | * |
| 88 | * @param {Object} evt Copy event. |
| 89 | */ |
| 90 | copyReport: function( evt ) { |
| 91 | wcClearClipboard(); |
| 92 | wcSetClipboard( $( '#debug-report' ).find( 'textarea' ).val(), $( this ) ); |
| 93 | evt.preventDefault(); |
| 94 | }, |
| 95 | |
| 96 | /** |
| 97 | * Display a "Copied!" tip when success copying |
| 98 | */ |
| 99 | copySuccess: function() { |
| 100 | $( '#copy-for-support' ).tipTip({ |
| 101 | 'attribute': 'data-tip', |
| 102 | 'activation': 'focus', |
| 103 | 'fadeIn': 50, |
| 104 | 'fadeOut': 50, |
| 105 | 'delay': 0 |
| 106 | }).trigger( 'focus' ); |
| 107 | }, |
| 108 | |
| 109 | /** |
| 110 | * Displays the copy error message when failure copying. |
| 111 | */ |
| 112 | copyFail: function() { |
| 113 | $( '.copy-error' ).removeClass( 'hidden' ); |
| 114 | $( '#debug-report' ).find( 'textarea' ).trigger( 'focus' ).trigger( 'select' ); |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | wcSystemStatus.init(); |
| 119 | |
| 120 | $( '.wc_status_table' ).on( 'click', '.run-tool .button', function( evt ) { |
| 121 | evt.stopImmediatePropagation(); |
| 122 | return window.confirm( woocommerce_admin_system_status.run_tool_confirmation ); |
| 123 | }); |
| 124 | |
| 125 | $( '#log-viewer-select' ).on( 'click', 'h2 a.page-title-action', function( evt ) { |
| 126 | evt.stopImmediatePropagation(); |
| 127 | return window.confirm( woocommerce_admin_system_status.delete_log_confirmation ); |
| 128 | }); |
| 129 | }); |
| 130 |