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
meta-boxes.js
196 lines
| 1 | jQuery( function ( $ ) { |
| 2 | /** |
| 3 | * Function to check if the attribute and variation fields are empty. |
| 4 | */ |
| 5 | jQuery.is_attribute_or_variation_empty = function ( |
| 6 | attributes_and_variations_data |
| 7 | ) { |
| 8 | var has_empty_fields = false; |
| 9 | attributes_and_variations_data.each( function () { |
| 10 | var $this = $( this ); |
| 11 | // Check if the field is checkbox or a search field. |
| 12 | if ( |
| 13 | $this.hasClass( 'checkbox' ) || |
| 14 | $this.filter( '[class*=search__field]' ).length |
| 15 | ) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | var is_empty = $this.is( 'select' ) |
| 20 | ? $this.find( ':selected' ).length === 0 |
| 21 | : ! $this.val(); |
| 22 | if ( is_empty ) { |
| 23 | has_empty_fields = true; |
| 24 | } |
| 25 | } ); |
| 26 | return has_empty_fields; |
| 27 | }; |
| 28 | |
| 29 | /** |
| 30 | * Function to maybe disable the save button. |
| 31 | */ |
| 32 | jQuery.maybe_disable_save_button = function () { |
| 33 | var $tab; |
| 34 | var $save_button; |
| 35 | if ( |
| 36 | $( '.woocommerce_variation_new_attribute_data' ).is( ':visible' ) |
| 37 | ) { |
| 38 | $tab = $( '.woocommerce_variation_new_attribute_data' ); |
| 39 | $save_button = $( 'button.create-variations' ); |
| 40 | } else { |
| 41 | var $tab = $( '.product_attributes' ); |
| 42 | var $save_button = $( 'button.save_attributes' ); |
| 43 | } |
| 44 | |
| 45 | var attributes_and_variations_data = $tab.find( |
| 46 | 'input, select, textarea' |
| 47 | ); |
| 48 | if ( |
| 49 | jQuery.is_attribute_or_variation_empty( |
| 50 | attributes_and_variations_data |
| 51 | ) |
| 52 | ) { |
| 53 | if ( ! $save_button.hasClass( 'disabled' ) ) { |
| 54 | $save_button.addClass( 'disabled' ); |
| 55 | $save_button.attr( 'aria-disabled', true ); |
| 56 | } |
| 57 | } else { |
| 58 | $save_button.removeClass( 'disabled' ); |
| 59 | $save_button.removeAttr( 'aria-disabled' ); |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | // Run tipTip |
| 64 | function runTipTip() { |
| 65 | // Remove any lingering tooltips |
| 66 | $( '#tiptip_holder' ).removeAttr( 'style' ); |
| 67 | $( '#tiptip_arrow' ).removeAttr( 'style' ); |
| 68 | $( '.tips' ).tipTip( { |
| 69 | attribute: 'data-tip', |
| 70 | fadeIn: 50, |
| 71 | fadeOut: 50, |
| 72 | delay: 200, |
| 73 | keepAlive: true, |
| 74 | } ); |
| 75 | } |
| 76 | |
| 77 | runTipTip(); |
| 78 | |
| 79 | $( '.save_attributes' ).tipTip( { |
| 80 | content: function () { |
| 81 | return $( '.save_attributes' ).hasClass( 'disabled' ) |
| 82 | ? woocommerce_admin_meta_boxes.i18n_save_attribute_variation_tip |
| 83 | : ''; |
| 84 | }, |
| 85 | fadeIn: 50, |
| 86 | fadeOut: 50, |
| 87 | delay: 200, |
| 88 | keepAlive: true, |
| 89 | } ); |
| 90 | |
| 91 | $( '.create-variations' ).tipTip( { |
| 92 | content: function () { |
| 93 | return $( '.create-variations' ).hasClass( 'disabled' ) |
| 94 | ? woocommerce_admin_meta_boxes.i18n_save_attribute_variation_tip |
| 95 | : ''; |
| 96 | }, |
| 97 | fadeIn: 50, |
| 98 | fadeOut: 50, |
| 99 | delay: 200, |
| 100 | keepAlive: true, |
| 101 | } ); |
| 102 | |
| 103 | $( '.wc-metaboxes-wrapper' ).on( 'click', '.wc-metabox > h3', function () { |
| 104 | var metabox = $( this ).parent( '.wc-metabox' ); |
| 105 | |
| 106 | if ( metabox.hasClass( 'closed' ) ) { |
| 107 | metabox.removeClass( 'closed' ); |
| 108 | } else { |
| 109 | metabox.addClass( 'closed' ); |
| 110 | } |
| 111 | |
| 112 | if ( metabox.hasClass( 'open' ) ) { |
| 113 | metabox.removeClass( 'open' ); |
| 114 | } else { |
| 115 | metabox.addClass( 'open' ); |
| 116 | } |
| 117 | } ); |
| 118 | |
| 119 | // Tabbed Panels |
| 120 | $( document.body ) |
| 121 | .on( 'wc-init-tabbed-panels', function () { |
| 122 | $( 'ul.wc-tabs' ).show(); |
| 123 | $( 'ul.wc-tabs a' ).on( 'click', function ( e ) { |
| 124 | e.preventDefault(); |
| 125 | var panel_wrap = $( this ).closest( 'div.panel-wrap' ); |
| 126 | $( 'ul.wc-tabs li', panel_wrap ).removeClass( 'active' ); |
| 127 | $( this ).parent().addClass( 'active' ); |
| 128 | $( 'div.panel', panel_wrap ).hide(); |
| 129 | $( $( this ).attr( 'href' ) ).show( 0, function () { |
| 130 | $( this ).trigger( 'woocommerce_tab_shown' ); |
| 131 | } ); |
| 132 | } ); |
| 133 | $( 'div.panel-wrap' ).each( function () { |
| 134 | $( this ) |
| 135 | .find( 'ul.wc-tabs li' ) |
| 136 | .eq( 0 ) |
| 137 | .find( 'a' ) |
| 138 | .trigger( 'click' ); |
| 139 | } ); |
| 140 | } ) |
| 141 | .trigger( 'wc-init-tabbed-panels' ); |
| 142 | |
| 143 | // Date Picker |
| 144 | $( document.body ) |
| 145 | .on( 'wc-init-datepickers', function () { |
| 146 | $( '.date-picker-field, .date-picker' ).datepicker( { |
| 147 | dateFormat: 'yy-mm-dd', |
| 148 | numberOfMonths: 1, |
| 149 | showButtonPanel: true, |
| 150 | } ); |
| 151 | } ) |
| 152 | .trigger( 'wc-init-datepickers' ); |
| 153 | |
| 154 | // Meta-Boxes - Open/close |
| 155 | $( '.wc-metaboxes-wrapper' ) |
| 156 | .on( 'click', '.wc-metabox h3', function ( event ) { |
| 157 | // If the user clicks on some form input inside the h3, like a select list (for variations), the box should not be toggled |
| 158 | if ( $( event.target ).filter( ':input, option, .sort' ).length ) { |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | $( this ).next( '.wc-metabox-content' ).stop().slideToggle(); |
| 163 | } ) |
| 164 | .on( 'click', '.expand_all', function () { |
| 165 | $( this ) |
| 166 | .closest( '.wc-metaboxes-wrapper' ) |
| 167 | .find( '.wc-metabox > .wc-metabox-content' ) |
| 168 | .show(); |
| 169 | return false; |
| 170 | } ) |
| 171 | .on( 'click', '.close_all', function () { |
| 172 | $( this ) |
| 173 | .closest( '.wc-metaboxes-wrapper' ) |
| 174 | .find( '.wc-metabox > .wc-metabox-content' ) |
| 175 | .hide(); |
| 176 | return false; |
| 177 | } ); |
| 178 | $( '.wc-metabox.closed' ).each( function () { |
| 179 | $( this ).find( '.wc-metabox-content' ).hide(); |
| 180 | } ); |
| 181 | |
| 182 | $( '#product_attributes' ).on( |
| 183 | 'change', |
| 184 | 'select.attribute_values', |
| 185 | jQuery.maybe_disable_save_button |
| 186 | ); |
| 187 | $( '#product_attributes, #variable_product_options' ).on( |
| 188 | 'keyup', |
| 189 | 'input, textarea', |
| 190 | jQuery.maybe_disable_save_button |
| 191 | ); |
| 192 | |
| 193 | // Maybe disable save buttons when editing products. |
| 194 | jQuery.maybe_disable_save_button(); |
| 195 | } ); |
| 196 |