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
product-ordering.js
87 lines
| 1 | /*global ajaxurl, woocommerce_product_ordering_params */ |
| 2 | |
| 3 | /** |
| 4 | * Based on Simple Page Ordering by 10up (https://wordpress.org/plugins/simple-page-ordering/) |
| 5 | * |
| 6 | * Modified - products have no children (non hierarchical) |
| 7 | */ |
| 8 | jQuery( function( $ ) { |
| 9 | $( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' ); |
| 10 | |
| 11 | $( 'table.widefat tbody' ).sortable({ |
| 12 | items: 'tr:not(.inline-edit-row)', |
| 13 | cursor: 'move', |
| 14 | axis: 'y', |
| 15 | containment: 'table.widefat', |
| 16 | scrollSensitivity: 40, |
| 17 | helper: function( event, ui ) { |
| 18 | ui.each( function() { |
| 19 | $( this ).width( $( this ).width() ); |
| 20 | }); |
| 21 | return ui; |
| 22 | }, |
| 23 | start: function( event, ui ) { |
| 24 | ui.item.css( 'background-color', '#ffffff' ); |
| 25 | ui.item.children( 'td, th' ).css( 'border-bottom-width', '0' ); |
| 26 | ui.item.css( 'outline', '1px solid #dfdfdf' ); |
| 27 | }, |
| 28 | stop: function( event, ui ) { |
| 29 | ui.item.removeAttr( 'style' ); |
| 30 | ui.item.children( 'td,th' ).css( 'border-bottom-width', '1px' ); |
| 31 | }, |
| 32 | update: function( event, ui ) { |
| 33 | $( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'default' ); |
| 34 | $( 'table.widefat tbody' ).sortable( 'disable' ); |
| 35 | |
| 36 | var postid = ui.item.find( '.check-column input' ).val(); |
| 37 | var prevpostid = ui.item.prev().find( '.check-column input' ).val(); |
| 38 | var nextpostid = ui.item.next().find( '.check-column input' ).val(); |
| 39 | |
| 40 | // Show Spinner |
| 41 | ui.item |
| 42 | .find( '.check-column input' ) |
| 43 | .hide() |
| 44 | .after( '<img alt="processing" src="images/wpspin_light.gif" class="waiting" style="margin-left: 6px;" />' ); |
| 45 | |
| 46 | // Go do the sorting stuff via ajax |
| 47 | $.post( |
| 48 | ajaxurl, |
| 49 | { |
| 50 | action: 'woocommerce_product_ordering', |
| 51 | security: woocommerce_product_ordering_params.nonce, |
| 52 | id: postid, |
| 53 | previd: prevpostid, |
| 54 | nextid: nextpostid, |
| 55 | }, |
| 56 | function( response ) { |
| 57 | $.each( response, function( key, value ) { |
| 58 | $( '#inline_' + key + ' .menu_order' ).html( value ); |
| 59 | }); |
| 60 | ui.item.find( '.check-column input' ).show().siblings( 'img' ).remove(); |
| 61 | $( 'table.widefat tbody th, table.widefat tbody td' ).css( 'cursor', 'move' ); |
| 62 | $( 'table.widefat tbody' ).sortable( 'enable' ); |
| 63 | } |
| 64 | ); |
| 65 | |
| 66 | // fix cell colors |
| 67 | $( 'table.widefat tbody tr' ).each( function() { |
| 68 | var i = $( 'table.widefat tbody tr' ).index( this ); |
| 69 | if ( i%2 === 0 ) { |
| 70 | $( this ).addClass( 'alternate' ); |
| 71 | } else { |
| 72 | $( this ).removeClass( 'alternate' ); |
| 73 | } |
| 74 | }); |
| 75 | }, |
| 76 | sort: function (e, ui) { |
| 77 | ui.placeholder.find( 'td' ).each( function( key, value ) { |
| 78 | if ( ui.helper.find( 'td' ).eq( key ).is( ':visible' ) ) { |
| 79 | $( this ).show(); |
| 80 | } else { |
| 81 | $( this ).hide(); |
| 82 | } |
| 83 | }); |
| 84 | } |
| 85 | }); |
| 86 | }); |
| 87 |