2015-04-30 21:43:01 +00:00
|
|
|
/* global woocommerce_settings_params */
|
2016-04-20 15:38:58 +00:00
|
|
|
( function( $ ) {
|
2013-07-26 14:36:28 +00:00
|
|
|
|
|
|
|
// Countries
|
2016-04-20 15:38:58 +00:00
|
|
|
$( 'select#woocommerce_allowed_countries, select#woocommerce_ship_to_countries' ).change( function() {
|
|
|
|
if ( $( this ).val() === 'specific' ) {
|
|
|
|
$( this ).parent().parent().next( 'tr' ).show();
|
2013-07-26 14:36:28 +00:00
|
|
|
} else {
|
2016-04-20 15:38:58 +00:00
|
|
|
$( this ).parent().parent().next( 'tr' ).hide();
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
}).change();
|
|
|
|
|
|
|
|
// Color picker
|
2016-04-20 15:38:58 +00:00
|
|
|
$( '.colorpick' ).iris({
|
2015-04-30 21:43:01 +00:00
|
|
|
change: function( event, ui ) {
|
2016-04-20 15:38:58 +00:00
|
|
|
$( this ).parent().find( '.colorpickpreview' ).css({ backgroundColor: ui.color.toString() });
|
2013-07-26 14:36:28 +00:00
|
|
|
},
|
|
|
|
hide: true,
|
|
|
|
border: true
|
2015-04-30 21:43:01 +00:00
|
|
|
}).click( function() {
|
2016-04-20 15:38:58 +00:00
|
|
|
$( '.iris-picker' ).hide();
|
|
|
|
$( this ).closest( 'td' ).find( '.iris-picker' ).show();
|
2013-07-26 14:36:28 +00:00
|
|
|
});
|
|
|
|
|
2016-04-20 15:38:58 +00:00
|
|
|
$( 'body' ).click( function() {
|
|
|
|
$( '.iris-picker' ).hide();
|
2013-07-26 14:36:28 +00:00
|
|
|
});
|
|
|
|
|
2016-04-20 15:38:58 +00:00
|
|
|
$( '.colorpick' ).click( function( event ) {
|
2015-04-30 21:43:01 +00:00
|
|
|
event.stopPropagation();
|
2013-07-26 14:36:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Edit prompt
|
2016-04-20 15:38:58 +00:00
|
|
|
$( function() {
|
2013-07-26 14:36:28 +00:00
|
|
|
var changed = false;
|
|
|
|
|
2016-04-20 15:38:58 +00:00
|
|
|
$( 'input, textarea, select, checkbox' ).change( function() {
|
2013-07-26 14:36:28 +00:00
|
|
|
changed = true;
|
|
|
|
});
|
|
|
|
|
2016-04-20 15:38:58 +00:00
|
|
|
$( '.woo-nav-tab-wrapper a' ).click( function() {
|
2015-04-30 21:43:01 +00:00
|
|
|
if ( changed ) {
|
2013-07-26 14:36:28 +00:00
|
|
|
window.onbeforeunload = function() {
|
|
|
|
return woocommerce_settings_params.i18n_nav_warning;
|
2015-04-30 21:43:01 +00:00
|
|
|
};
|
2013-07-26 14:36:28 +00:00
|
|
|
} else {
|
|
|
|
window.onbeforeunload = '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-04-20 15:38:58 +00:00
|
|
|
$( '.submit input' ).click( function() {
|
2013-07-26 14:36:28 +00:00
|
|
|
window.onbeforeunload = '';
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Sorting
|
2016-04-20 15:38:58 +00:00
|
|
|
$( 'table.wc_gateways tbody, table.wc_shipping tbody' ).sortable({
|
2015-04-30 21:43:01 +00:00
|
|
|
items: 'tr',
|
|
|
|
cursor: 'move',
|
|
|
|
axis: 'y',
|
2015-04-13 14:32:54 +00:00
|
|
|
handle: 'td.sort',
|
2015-04-30 21:43:01 +00:00
|
|
|
scrollSensitivity: 40,
|
|
|
|
helper: function( event, ui ) {
|
|
|
|
ui.children().each( function() {
|
2016-04-20 15:38:58 +00:00
|
|
|
$( this ).width( $( this ).width() );
|
2013-07-26 14:36:28 +00:00
|
|
|
});
|
2015-04-30 21:43:01 +00:00
|
|
|
ui.css( 'left', '0' );
|
2013-07-26 14:36:28 +00:00
|
|
|
return ui;
|
|
|
|
},
|
2015-04-30 21:43:01 +00:00
|
|
|
start: function( event, ui ) {
|
|
|
|
ui.item.css( 'background-color', '#f6f6f6' );
|
2013-07-26 14:36:28 +00:00
|
|
|
},
|
2015-04-30 21:43:01 +00:00
|
|
|
stop: function( event, ui ) {
|
|
|
|
ui.item.removeAttr( 'style' );
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Select all/none
|
2016-04-20 15:38:58 +00:00
|
|
|
$( '.woocommerce' ).on( 'click', '.select_all', function() {
|
|
|
|
$( this ).closest( 'td' ).find( 'select option' ).attr( 'selected', 'selected' );
|
|
|
|
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
|
2013-07-26 14:36:28 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2016-04-20 15:38:58 +00:00
|
|
|
$( '.woocommerce' ).on( 'click', '.select_none', function() {
|
|
|
|
$( this ).closest( 'td' ).find( 'select option' ).removeAttr( 'selected' );
|
|
|
|
$( this ).closest( 'td' ).find( 'select' ).trigger( 'change' );
|
2013-07-26 14:36:28 +00:00
|
|
|
return false;
|
|
|
|
});
|
2016-04-20 15:38:58 +00:00
|
|
|
})( jQuery );
|